nav-bar.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. },
  42. type: Object
  43. }
  44. })
  45. const {proxy} = getCurrentInstance()
  46. const emit = defineEmits(['updateUser'])
  47. console.log("props.userInfo.workStatus", props.userInfo.workStatus)
  48. onMounted(() => {
  49. // userInfo.value = props.userInfo
  50. // console.log("props.userInfo.name", props.userInfo.name)
  51. })
  52. const dialogToggle = ()=>{
  53. proxy.$refs.alertDialog.open()
  54. }
  55. const dialogConfirm = ()=>{
  56. handleChange()
  57. }
  58. const dialogClose = ()=>{
  59. console.log('guanbi')
  60. }
  61. const handleChange =async()=>{
  62. console.log("props.userInfo.workStatus》》》", props.userInfo.workStatus)
  63. const token = uni.getStorageSync('token')
  64. const userId = uni.getStorageSync('userId')
  65. if(props.userInfo.workStatus){
  66. const params = {
  67. token: uni.getStorageSync('token'),
  68. data: {
  69. pharmacistUserId: userId,
  70. workStatus: props.userInfo.workStatus ==='1'?'0':'1'
  71. }
  72. }
  73. console.log('params.data.workStatus', params)
  74. const {data:res} = await updateWorkStatus(params)
  75. if (res.code === 200) {
  76. uni.setStorageSync('workStatus', params.data.workStatus);
  77. emit('updateUser', params.data.workStatus)
  78. }
  79. emit('updateUser', props.userInfo.workStatus)
  80. }
  81. }
  82. const handleScanbara = ()=>{
  83. uni.scanCode({
  84. scanType: ['barCode'],
  85. success: function (res) {
  86. console.log('条码类型:' + res.scanType);
  87. console.log('条码内容:' + res.result);
  88. if(res.result) {
  89. uni.navigateTo({
  90. url:`/pages/review/review?preNo=${res.result}&depolyStatus=2`
  91. })
  92. }
  93. }
  94. });
  95. }
  96. const handleLogout = async()=>{
  97. console.log("handleLogout", 555)
  98. const tokens = uni.getStorageSync('token')
  99. const userId = uni.getStorageSync('userId')
  100. const params = {
  101. token: tokens,
  102. data: {
  103. pharmacistUserId: userId,
  104. onlineStatus: 1
  105. }
  106. }
  107. const {data:res} = await updateOnlineStatus(params)
  108. uni.redirectTo({
  109. url:"/pages/login/login"
  110. })
  111. }
  112. </script>
  113. <style lang="scss">
  114. :deep(.uni-button-color){
  115. color: #18c7b0!important;
  116. }
  117. .nav{
  118. display:flex;
  119. justify-content:space-between;
  120. align-items:flex-end;
  121. width: 750rpx;
  122. align-items: center;
  123. height: 75rpx;
  124. background-color: #18C7B0;
  125. padding-top: 43rpx;
  126. .navbar{
  127. width: 750rpx;
  128. display: flex;
  129. align-items: center;
  130. justify-content: space-between;
  131. .scanbara{
  132. display: flex;
  133. width: 91rpx;
  134. height: 32.8rpx;
  135. font-size: 15rpx;
  136. color:#18C7B0;
  137. margin-left: 20.1rpx;
  138. }
  139. .status{
  140. font-size: 18.75rpx;
  141. color:#fff;
  142. margin-right: 110.47rpx;
  143. }
  144. .userinfo{
  145. display: flex;
  146. justify-content: space-between;
  147. align-items: center;
  148. margin-right: 22.19rpx;
  149. .lef{
  150. height: 33.75rpx;
  151. width: 91rpx;
  152. // padding: 14rpx;
  153. margin-right: 17.5rpx;
  154. font-size: 15rpx;
  155. color:#18C7B0;
  156. // margin: 0 20px;
  157. }
  158. .mid{
  159. height: 43.75rpx;
  160. width: 43.75rpx;
  161. margin-right: 5.94rpx;
  162. border-radius: 50%;
  163. }
  164. .rig{
  165. // margin-right: 40px;
  166. display: flex;
  167. flex-direction: column;
  168. align-items: center;
  169. .name{
  170. // margin-bottom: 10px;
  171. // width: 50rpx;
  172. font-size: 17.5rpx;
  173. color: #fff;
  174. text-align: center;
  175. }
  176. .logout{
  177. // width: 50rpx;
  178. background-color: #18C7B0;
  179. font-size: 15rpx;
  180. color: #fff;
  181. border: 1px solid #18C7B0;
  182. display: flex;
  183. align-items: center;
  184. justify-content: center;
  185. }
  186. }
  187. }
  188. }
  189. }
  190. </style>