nav-bar.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view class="nav">
  3. <view class="navbar">
  4. <view class="status">{{userInfo.status === 1?"接单中":"暂停接单"}}</view>
  5. <view class="userinfo">
  6. <button type="primary" class="lef" @click="hangdleChange">{{userInfo.status === 1?"暂停接单":"开始接单"}}</button>
  7. <image class="mid" aspectFill :src="userInfo.faceurl?userInfo.faceurl:'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/cat-1.png'" />
  8. <view class="rig">
  9. <text class="name">{{props.userInfo.name?props.userInfo.name:"张三三"}}</text>
  10. <button size="mini" type="primary" @click="handleLogout" class="logout">退出</button>
  11. </view>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. name: 'NavBar'
  19. }
  20. </script>
  21. <script setup>
  22. import { onMounted,ref } from 'vue'
  23. const props = defineProps({
  24. userInfo: {
  25. default: function() {
  26. return {}
  27. },
  28. type: Object
  29. }
  30. })
  31. const emit = defineEmits(['updateUser'])
  32. const userInfo = ref({})
  33. onMounted(() => {
  34. userInfo.value = props.userInfo
  35. // console.log("props.userInfo.name", props.userInfo.name)
  36. })
  37. const hangdleChange =()=>{
  38. console.log("hangdleChange", 555)
  39. if(userInfo.value.status ===1){
  40. userInfo.value.status = 0
  41. } else {
  42. userInfo.value.status = 1
  43. }
  44. emit('updateUser', userInfo)
  45. }
  46. const handleLogout = ()=>{
  47. console.log("handleLogout", 555)
  48. uni.redirectTo({
  49. url:"/pages/login/login"
  50. })
  51. // emit('updateUser', userInfo)
  52. }
  53. </script>
  54. <style lang="scss">
  55. .nav{
  56. display:flex;
  57. justify-content:flex-end;
  58. align-items:flex-end;
  59. width: 1200px;
  60. background-color: #cfcfcf;
  61. padding-bottom: 20rpx;
  62. // position: fixed;
  63. .navbar{
  64. width: 440rpx;
  65. display: flex;
  66. align-items: center;
  67. justify-content: space-between;
  68. .status{
  69. font-size: 20rpx;
  70. }
  71. .userinfo{
  72. display: flex;
  73. justify-content: space-between;
  74. align-items: center;
  75. .lef{
  76. height: 60rpx;
  77. width: 60rpx;
  78. padding: 14rpx;
  79. margin-right: 30rpx;
  80. font-size: 15rpx;
  81. line-height: 15rpx;
  82. }
  83. .mid{
  84. height: 50rpx;
  85. width: 50rpx;
  86. margin-right: 30rpx;
  87. }
  88. .rig{
  89. margin-right: 10rpx;
  90. display: flex;
  91. flex-direction: column;
  92. align-items: center;
  93. .name{
  94. margin-bottom: 10rpx;
  95. width: 50rpx;
  96. text-align: center;
  97. }
  98. .logout{
  99. width: 50rpx;
  100. }
  101. }
  102. }
  103. }
  104. }
  105. </style>