猫妈狗爸伴宠师小程序前端代码
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.

188 lines
4.0 KiB

2 weeks ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 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. <!-- 客服组件 -->
  30. <CustomerService />
  31. </view>
  32. </template>
  33. <script setup>
  34. import {
  35. computed,
  36. reactive,
  37. ref
  38. } from "vue";
  39. import List from "./components/list.vue";
  40. import {
  41. onShow
  42. } from "@dcloudio/uni-app"
  43. import { getLoginStatus } from "@/utils/useMixin.js"
  44. import {
  45. getIsLogin,
  46. getToken
  47. } from "@/utils/auth";
  48. import {
  49. orderList
  50. } from "@/api/receivingHall/index.js"
  51. import submitBut from "@/components/submitBut/index.vue"
  52. import {
  53. useStore
  54. } from "vuex"
  55. import dayjs from "dayjs";
  56. import { getOrderServiceText, getProductNameText } from '@/utils/serviceTime.js'
  57. const current = ref(0)
  58. const isLogin = ref(false) // 添加登录状态
  59. const list = reactive([{
  60. name: '系统派单',
  61. badge: {
  62. value: 0,
  63. }
  64. },
  65. {
  66. name: '个人订单',
  67. badge: {
  68. value: 0,
  69. }
  70. },
  71. {
  72. name: '流失订单',
  73. badge: {
  74. value: 0,
  75. }
  76. },
  77. ])
  78. const store = useStore();
  79. const userInfo = computed(() => {
  80. return store.getters.userInfo
  81. })
  82. const orderlist = ref([]);
  83. onShow(() => {
  84. checkLoginStatus();
  85. if (isLogin.value) {
  86. getOrderList();
  87. }
  88. })
  89. // 检查登录状态
  90. const checkLoginStatus = () => {
  91. if (getIsLogin() && getToken()) {
  92. isLogin.value = true
  93. } else {
  94. isLogin.value = false
  95. }
  96. }
  97. // 跳转登录页面
  98. const goToLogin = () => {
  99. uni.navigateTo({
  100. url: "/pages/login/index"
  101. })
  102. }
  103. // 检查登录状态,未登录则跳转登录
  104. const checkLoginAndRedirect = () => {
  105. if (!isLogin.value) {
  106. goToLogin()
  107. return false
  108. }
  109. return true
  110. }
  111. // 获取接单大厅列表
  112. const getOrderList = async () => {
  113. if (!isLogin.value) return;
  114. let response = await orderList({
  115. type: current.value,
  116. userIdJson: userInfo.value.userId,
  117. userId:userInfo.value.userId,
  118. });
  119. if (response.code == 200 && response.data) {
  120. orderlist.value = response.data.rows;
  121. list[current.value].badge.value = response.data.total
  122. orderlist.value.forEach(item => {
  123. item.h5OrderVO.petVOList.forEach(pet => {
  124. pet.orderServiceText = getOrderServiceText(pet.id, item.h5OrderVO.orderServiceList)
  125. pet.productNameText = getProductNameText(pet.id, item.h5OrderVO.orderItemList, item.h5OrderVO.orderServiceList)
  126. })
  127. })
  128. }
  129. }
  130. const handleClickEvent = (item) => {
  131. current.value = item.index;
  132. if (checkLoginAndRedirect()) {
  133. getOrderList();
  134. }
  135. }
  136. const updateList = () => {
  137. if (checkLoginAndRedirect()) {
  138. getOrderList();
  139. }
  140. }
  141. </script>
  142. <style scoped lang="scss">
  143. @import "index.scss";
  144. .login-tip-container {
  145. display: flex;
  146. align-items: center;
  147. justify-content: center;
  148. padding: 80rpx 40rpx;
  149. .login-tip-content {
  150. display: flex;
  151. flex-direction: column;
  152. align-items: center;
  153. padding: 60rpx;
  154. border-radius: 20rpx;
  155. .login-image {
  156. margin-bottom: 30rpx;
  157. }
  158. .login-tip {
  159. font-size: 28rpx;
  160. color: #666;
  161. margin-bottom: 30rpx;
  162. }
  163. .login-btn {
  164. width: 240rpx;
  165. }
  166. }
  167. }
  168. </style>