123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <template>
- <view class="nav">
- <view class="navbar">
- <view class="status">{{props.userInfo.workStatus === '0'?"接单中":"暂停接单"}}</view>
- <view class="userinfo">
- <button type="primary" class="lef" @click="handleChange">{{props.userInfo.workStatus === '0'?"暂停接单":"开始接单"}}</button>
- <image class="mid" aspectFill src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/cat-1.png" />
- <view class="rig">
- <text class="name">{{props.userInfo.name?props.userInfo.name:"张三三"}}</text>
- <button size="mini" type="primary" @click="handleLogout" class="logout">退出</button>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: 'NavBar'
- }
- </script>
- <script setup>
- import { onMounted,ref } from 'vue'
- import {updateWorkStatus, updateOnlineStatus } from "@/static/api.js"
- const props = defineProps({
- userInfo: {
- default: function() {
- return {}
- },
- type: Object
- }
- })
- const emit = defineEmits(['updateUser'])
- console.log("props.userInfo.workStatus", props.userInfo.workStatus)
- onMounted(() => {
- // userInfo.value = props.userInfo
- // console.log("props.userInfo.name", props.userInfo.name)
- })
- const handleChange =async()=>{
- console.log("hangdleChange props.userInfo.workStatus", props.userInfo.workStatus)
- const token = uni.getStorageSync('token')
- const userId = uni.getStorageSync('userId')
- if(props.userInfo.workStatus){
- const params = {
- token: token,
- data: {
- pharmacistUserId: userId,
- workStatus: props.userInfo.workStatus ==='1'?'0':'1'
- }
- }
- console.log('params.data.workStatus', params)
-
- const {data:res} = await updateWorkStatus(params)
- if (res.code === 200) {
- emit('updateUser', params.data.workStatus)
- }
- emit('updateUser', props.userInfo.workStatus)
- }
- }
- const handleLogout = async()=>{
- console.log("handleLogout", 555)
- const tokens = uni.getStorageSync('token')
- const userId = uni.getStorageSync('userId')
- const params = {
- token: tokens,
- data: {
- pharmacistUserId: userId,
- onlineStatus: 1
- }
- }
- const {data:res} = await updateOnlineStatus(params)
- uni.redirectTo({
- url:"/pages/login/login"
- })
-
- }
- </script>
- <style lang="scss">
- .nav{
- display:flex;
- justify-content:flex-end;
- align-items:flex-end;
- width: 1200px;
-
- background-color: #cfcfcf;
- padding-bottom: 20rpx;
- // position: fixed;
- .navbar{
- width: 440rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .status{
- font-size: 20rpx;
- }
- .userinfo{
- display: flex;
- justify-content: space-between;
- align-items: center;
- .lef{
- height: 60rpx;
- width: 60rpx;
- padding: 14rpx;
- margin-right: 30rpx;
- font-size: 15rpx;
- line-height: 15rpx;
- }
- .mid{
- height: 50rpx;
- width: 50rpx;
- margin-right: 30rpx;
- }
- .rig{
- margin-right: 10rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- .name{
- margin-bottom: 10rpx;
- width: 50rpx;
- text-align: center;
- }
- .logout{
- width: 50rpx;
- }
- }
- }
- }
- }
- </style>
|