nav-bar.vue 5.3 KB

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