nav-bar.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <view class="nav">
  3. <view class="navbar">
  4. <button class="scanbara" @click="handleScanbara">复核扫码</button>
  5. <view class="status">{{props.userInfo.workStatus === '0'?"接单中":"暂停接单"}}</view>
  6. <view class="userinfo">
  7. <button class="lef" @click="dialogToggle">{{props.userInfo.workStatus === '0'?"暂停接单":"开始接单"}}</button>
  8. <image class="mid" aspectFill src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/cat-1.png" />
  9. <view class="rig">
  10. <text class="name">{{props.userInfo.name?props.userInfo.name:"张三三"}}</text>
  11. <view size="mini" @click="handleLogout" class="logout">退出<uni-icons class="item" type="forward" color="#ff" size="16"></uni-icons></view>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. <view v-if="props.userInfo.workStatus==='0'">
  17. <uni-popup ref="alertDialog" type="dialog">
  18. <uni-popup-dialog type="center" cancelText="取消" confirmText="同意" title="温馨提示" content="你确定要暂停接单吗?" @confirm="dialogConfirm"
  19. @close="dialogClose"></uni-popup-dialog>
  20. </uni-popup>
  21. </view>
  22. <view v-else>
  23. <uni-popup ref="alertDialog" type="dialog">
  24. <uni-popup-dialog type="center" cancelText="取消" confirmText="同意" title="温馨提示" content="你确定要开始接单吗?" @confirm="dialogConfirm"
  25. @close="dialogClose"></uni-popup-dialog>
  26. </uni-popup>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. name: 'NavBar'
  32. }
  33. </script>
  34. <script setup>
  35. import { onMounted,ref, getCurrentInstance } from 'vue'
  36. import {updateWorkStatus, updateOnlineStatus } from "@/static/js/api.js"
  37. const props = defineProps({
  38. userInfo: {
  39. default: function() {
  40. return {
  41. workStatus: '0'
  42. }
  43. },
  44. type: Object
  45. }
  46. })
  47. const {proxy} = getCurrentInstance()
  48. const emit = defineEmits(['updateUser'])
  49. console.log("props.userInfo.workStatus", props.userInfo.workStatus)
  50. onMounted(() => {
  51. // userInfo.value = props.userInfo
  52. // console.log("props.userInfo.name", props.userInfo.name)
  53. })
  54. const dialogToggle = ()=>{
  55. proxy.$refs.alertDialog.open()
  56. }
  57. const dialogConfirm = ()=>{
  58. handleChange()
  59. }
  60. const dialogClose = ()=>{
  61. console.log('guanbi')
  62. }
  63. const handleChange =async()=>{
  64. console.log("props.userInfo.workStatus》》》", props.userInfo.workStatus)
  65. const token = uni.getStorageSync('token')
  66. const userId = uni.getStorageSync('userId')
  67. if(props.userInfo.workStatus){
  68. const params = {
  69. token: uni.getStorageSync('token'),
  70. data: {
  71. pharmacistUserId: userId,
  72. workStatus: props.userInfo.workStatus ==='1'?'0':'1'
  73. }
  74. }
  75. console.log('params.data.workStatus', params)
  76. const {data:res} = await updateWorkStatus(params)
  77. if (res.code === 200) {
  78. uni.setStorageSync('workStatus', params.data.workStatus);
  79. emit('updateUser', params.data.workStatus)
  80. }
  81. emit('updateUser', props.userInfo.workStatus)
  82. }
  83. }
  84. const handleScanbara = ()=>{
  85. uni.scanCode({
  86. scanType: ['barCode'],
  87. success: function (res) {
  88. console.log('条码类型:' + res.scanType);
  89. console.log('条码内容:' + res.result);
  90. if(res.result) {
  91. uni.navigateTo({
  92. url:`/pages/review/review?preNo=${res.result}&depolyStatus=2`
  93. })
  94. }
  95. }
  96. });
  97. }
  98. const handleLogout = async()=>{
  99. console.log("handleLogout", 555)
  100. const tokens = uni.getStorageSync('token')
  101. const userId = uni.getStorageSync('userId')
  102. const params = {
  103. token: tokens,
  104. data: {
  105. pharmacistUserId: userId,
  106. onlineStatus: 1
  107. }
  108. }
  109. const {data:res} = await updateOnlineStatus(params)
  110. uni.redirectTo({
  111. url:"/pages/login/login"
  112. })
  113. }
  114. </script>
  115. <style lang="scss">
  116. :deep(.uni-button-color){
  117. color: #18c7b0!important;
  118. }
  119. .nav{
  120. display:flex;
  121. justify-content:space-between;
  122. align-items:flex-end;
  123. width: 750rpx;
  124. align-items: center;
  125. height: 75rpx;
  126. background-color: #18C7B0;
  127. padding-top: 43rpx;
  128. .navbar{
  129. width: 750rpx;
  130. display: flex;
  131. align-items: center;
  132. justify-content: space-between;
  133. .scanbara{
  134. display: flex;
  135. width: 91rpx;
  136. height: 32.8rpx;
  137. font-size: 15rpx;
  138. color:#18C7B0;
  139. margin-left: 20.1rpx;
  140. }
  141. .status{
  142. font-size: 18.75rpx;
  143. color:#fff;
  144. margin-right: 110.47rpx;
  145. }
  146. .userinfo{
  147. display: flex;
  148. justify-content: space-between;
  149. align-items: center;
  150. margin-right: 22.19rpx;
  151. .lef{
  152. height: 33.75rpx;
  153. width: 91rpx;
  154. // padding: 14rpx;
  155. margin-right: 17.5rpx;
  156. font-size: 15rpx;
  157. color:#18C7B0;
  158. // margin: 0 20px;
  159. }
  160. .mid{
  161. height: 43.75rpx;
  162. width: 43.75rpx;
  163. margin-right: 5.94rpx;
  164. border-radius: 50%;
  165. }
  166. .rig{
  167. // margin-right: 40px;
  168. display: flex;
  169. flex-direction: column;
  170. align-items: center;
  171. .name{
  172. // margin-bottom: 10px;
  173. // width: 50rpx;
  174. font-size: 17.5rpx;
  175. color: #fff;
  176. text-align: center;
  177. }
  178. .logout{
  179. // width: 50rpx;
  180. background-color: #18C7B0;
  181. font-size: 15rpx;
  182. color: #fff;
  183. border: 1px solid #18C7B0;
  184. display: flex;
  185. align-items: center;
  186. justify-content: center;
  187. }
  188. }
  189. }
  190. }
  191. }
  192. </style>