猫妈狗爸伴宠师小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
4.0 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <view>
  3. <up-sticky bgColor="#fff">
  4. <view class="container-tabs">
  5. <up-tabs :list="list" lineWidth="68rpx" :activeStyle="{
  6. color: '#FFFFFF',
  7. fontWeight: 'bold',
  8. transform: 'scale(1.05)'
  9. }" :inactiveStyle="{
  10. color: '#FFFFFF',
  11. transform: 'scale(1)'
  12. }" :itemStyle="{height:'88rpx',width : '33%'}" lineColor="#FFFFFF" @click="handleClickEvent"></up-tabs>
  13. </view>
  14. </up-sticky>
  15. <view class="container">
  16. <!-- 未登录提示 -->
  17. <view v-if="!isLogin" class="login-tip-container">
  18. <view class="login-tip-content">
  19. <up-image class="login-image" width="120rpx" height="120rpx"
  20. src="https://image.hhlm1688.com/img/work/log/headImage.png" shape="circle"></up-image>
  21. <view class="login-tip">请先登录查看接单数据</view>
  22. <up-button @click="goToLogin" type="primary" text="立即登录"
  23. shape="circle" color="#FFBF60" class="login-btn"></up-button>
  24. </view>
  25. </view>
  26. <!-- 已登录状态 -->
  27. <List v-else :orderList="orderlist" :current="current" @update="updateList"></List>
  28. </view>
  29. </view>
  30. </template>
  31. <script setup>
  32. import {
  33. computed,
  34. reactive,
  35. ref
  36. } from "vue";
  37. import List from "./components/list.vue";
  38. import {
  39. onShow
  40. } from "@dcloudio/uni-app"
  41. import { getLoginStatus } from "@/utils/useMixin.js"
  42. import {
  43. getIsLogin,
  44. getToken
  45. } from "@/utils/auth";
  46. import {
  47. orderList
  48. } from "@/api/receivingHall/index.js"
  49. import submitBut from "@/components/submitBut/index.vue"
  50. import {
  51. useStore
  52. } from "vuex"
  53. import dayjs from "dayjs";
  54. import { getOrderServiceText, getProductNameText } from '@/utils/serviceTime.js'
  55. const current = ref(0)
  56. const isLogin = ref(false) // 添加登录状态
  57. const list = reactive([{
  58. name: '系统派单',
  59. badge: {
  60. value: 0,
  61. }
  62. },
  63. {
  64. name: '个人订单',
  65. badge: {
  66. value: 0,
  67. }
  68. },
  69. {
  70. name: '流失订单',
  71. badge: {
  72. value: 0,
  73. }
  74. },
  75. ])
  76. const store = useStore();
  77. const userInfo = computed(() => {
  78. return store.getters.userInfo
  79. })
  80. const orderlist = ref([]);
  81. onShow(() => {
  82. checkLoginStatus();
  83. if (isLogin.value) {
  84. getOrderList();
  85. }
  86. })
  87. // 检查登录状态
  88. const checkLoginStatus = () => {
  89. if (getIsLogin() && getToken()) {
  90. isLogin.value = true
  91. } else {
  92. isLogin.value = false
  93. }
  94. }
  95. // 跳转登录页面
  96. const goToLogin = () => {
  97. uni.navigateTo({
  98. url: "/pages/login/index"
  99. })
  100. }
  101. // 检查登录状态,未登录则跳转登录
  102. const checkLoginAndRedirect = () => {
  103. if (!isLogin.value) {
  104. goToLogin()
  105. return false
  106. }
  107. return true
  108. }
  109. // 获取接单大厅列表
  110. const getOrderList = async () => {
  111. if (!isLogin.value) return;
  112. let response = await orderList({
  113. type: current.value,
  114. userIdJson: userInfo.value.userId,
  115. userId:userInfo.value.userId,
  116. });
  117. if (response.code == 200 && response.data) {
  118. orderlist.value = response.data.rows;
  119. list[current.value].badge.value = response.data.total
  120. orderlist.value.forEach(item => {
  121. item.h5OrderVO.petVOList.forEach(pet => {
  122. pet.orderServiceText = getOrderServiceText(pet.id, item.h5OrderVO.orderServiceList)
  123. pet.productNameText = getProductNameText(pet.id, item.h5OrderVO.orderItemList, item.h5OrderVO.orderServiceList)
  124. })
  125. })
  126. }
  127. }
  128. const handleClickEvent = (item) => {
  129. current.value = item.index;
  130. if (checkLoginAndRedirect()) {
  131. getOrderList();
  132. }
  133. }
  134. const updateList = () => {
  135. if (checkLoginAndRedirect()) {
  136. getOrderList();
  137. }
  138. }
  139. </script>
  140. <style scoped lang="scss">
  141. @import "index.scss";
  142. .login-tip-container {
  143. display: flex;
  144. align-items: center;
  145. justify-content: center;
  146. padding: 80rpx 40rpx;
  147. .login-tip-content {
  148. display: flex;
  149. flex-direction: column;
  150. align-items: center;
  151. padding: 60rpx;
  152. border-radius: 20rpx;
  153. .login-image {
  154. margin-bottom: 30rpx;
  155. }
  156. .login-tip {
  157. font-size: 28rpx;
  158. color: #666;
  159. margin-bottom: 30rpx;
  160. }
  161. .login-btn {
  162. width: 240rpx;
  163. }
  164. }
  165. }
  166. </style>