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

253 lines
6.4 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <view>
  3. <view class="header-buts flex flex-center">
  4. <view class="flex buts-box">
  5. <view class="buts" :class="{'buts-active':activeIndex===1}" @click="clickTab(1)">总订单</view>
  6. <view class="buts" :class="{'buts-active':activeIndex===2}" @click="clickTab(2)">日订单</view>
  7. </view>
  8. </view>
  9. <up-sticky bgColor="#fff" v-if="activeIndex == 1">
  10. <view class="container-tabs">
  11. <up-tabs @click="classIfyClickTab" :list="tabList1" lineWidth="68rpx" :activeStyle="{
  12. color: '#FFFFFF',
  13. fontWeight: 'bold',
  14. transform: 'scale(1.05)'
  15. }" :inactiveStyle="{
  16. color: '#FFFFFF',
  17. transform: 'scale(1)'
  18. }" :itemStyle="{height:'88rpx',width : '33%'}"
  19. lineColor="#FFFFFF"></up-tabs>
  20. </view>
  21. </up-sticky>
  22. <up-sticky bgColor="#fff" v-else>
  23. <view class="container-tabs">
  24. <up-tabs :list="tabList2" lineWidth="68rpx" :activeStyle="{
  25. color: '#FFFFFF',
  26. fontWeight: 'bold',
  27. transform: 'scale(1.05)'
  28. }" :inactiveStyle="{
  29. color: '#FFFFFF',
  30. transform: 'scale(1)'
  31. }" :itemStyle="{height:'88rpx',padding:'0 52rpx', width : '400rpx'}"
  32. @click="classIfyClickTab"
  33. lineColor="#FFFFFF"></up-tabs>
  34. </view>
  35. </up-sticky>
  36. <view class="container">
  37. <!-- 加载中状态 -->
  38. <view v-if="loading" class="loading-container">
  39. <up-loading-icon size="36" mode="circle" color="#FFAA48"></up-loading-icon>
  40. <text class="loading-text">加载中...</text>
  41. </view>
  42. <!-- 总订单内容 -->
  43. <systemOrder :list="list" :current="current" v-else-if="activeIndex == 1" />
  44. <!-- 日订单内容 -->
  45. <view v-else>
  46. <view v-if="dateOrderList && dateOrderList.length > 0">
  47. <timelineService
  48. v-for="(item,index) in dateOrderList"
  49. :key="index"
  50. :date="item.serviceDate"
  51. :orderCount="item.num"
  52. :status="current === 0"
  53. :list="item.orderList"
  54. :current="current"
  55. />
  56. </view>
  57. <view v-else class="empty-state">
  58. <image src="/static/images/ydd/empty.png" mode="aspectFit" class="empty-image"></image>
  59. <text class="empty-text">暂无订单数据</text>
  60. </view>
  61. </view>
  62. <!-- <orderListByData :list="list" v-else /> -->
  63. </view>
  64. </view>
  65. </template>
  66. <script setup>
  67. import {
  68. computed,
  69. reactive,
  70. ref
  71. } from "vue";
  72. import systemOrder from "./components/systemOrder.vue";
  73. import orderListByData from "./components/orderListByData.vue";
  74. import timelineService from "./components/timelineService.vue";
  75. import {
  76. onShow,
  77. onLoad,
  78. } from "@dcloudio/uni-app"
  79. import {
  80. getLoginStatus
  81. } from "@/utils/useMixin.js"
  82. // import personOrder from "./components/personOrder.vue";
  83. // import lossOrder from "./components/lossOrder.vue";
  84. import {
  85. myList
  86. } from "@/api/receivingHall/index.js"
  87. import {
  88. getOrderDateList
  89. } from "@/api/order/order.js"
  90. import {
  91. useStore
  92. } from "vuex"
  93. import { getOrderServiceText, getProductNameText } from '@/utils/serviceTime.js'
  94. onShow(() => {
  95. if (!getLoginStatus()) return;
  96. getList();
  97. })
  98. const current = ref(0)
  99. const activeIndex = ref(1)
  100. const list = ref([])
  101. const dateOrderList = ref([])
  102. const loading = ref(false) // 添加loading状态
  103. const store = useStore();
  104. const userInfo = computed(() => {
  105. return store.getters.userInfo;
  106. })
  107. const tabList1 = reactive([{
  108. name: '待服务',
  109. badge: {
  110. value: 0,
  111. }
  112. },
  113. {
  114. name: '进行中',
  115. badge: {
  116. value: 0,
  117. }
  118. },
  119. {
  120. name: '已完成',
  121. badge: {
  122. value: 0,
  123. }
  124. },
  125. ])
  126. const tabList2 = reactive([{
  127. name: '待上门',
  128. badge: {
  129. value: 0,
  130. }
  131. },
  132. {
  133. name: '已完成',
  134. badge: {
  135. value: 0,
  136. }
  137. },
  138. ])
  139. function getList() {
  140. loading.value = true; // 开始加载
  141. let index = current.value;
  142. if (activeIndex.value == 1) {
  143. myList({
  144. orderStatus: index,
  145. userId: userInfo.value.userId
  146. })
  147. .then(res => {
  148. if (res.code == 200) {
  149. list.value = res.data.rows
  150. tabList1[index].badge.value = res.data.total
  151. list.value.forEach(item => {
  152. item.h5OrderVO.petVOList.forEach(pet => {
  153. pet.orderServiceText = getOrderServiceText(pet.id, item.h5OrderVO.orderServiceList)
  154. pet.productNameText = getProductNameText(pet.id, item.h5OrderVO.orderItemList, item.h5OrderVO.orderServiceList)
  155. })
  156. })
  157. }
  158. })
  159. .finally(() => {
  160. if(activeIndex.value == 1){
  161. loading.value = false; // 结束加载
  162. }
  163. })
  164. }else{
  165. dateOrderList.value = []
  166. getOrderDateList({
  167. status: index,
  168. userId: userInfo.value.userId
  169. })
  170. .then(res => {
  171. if (res.code == 200) {
  172. dateOrderList.value = res.data
  173. // 更新标签数量显示
  174. let totalOrders = 0;
  175. dateOrderList.value.forEach(item => {
  176. totalOrders += item.num || 0;
  177. });
  178. tabList2[index].badge.value = totalOrders;
  179. }
  180. })
  181. .finally(() => {
  182. if(activeIndex.value == 2){
  183. loading.value = false; // 结束加载
  184. }
  185. })
  186. }
  187. }
  188. function clickTab(index) {
  189. current.value = 0;
  190. activeIndex.value = index;
  191. getList();
  192. }
  193. const classIfyClickTab = (item) => {
  194. current.value = item.index;
  195. getList();
  196. }
  197. </script>
  198. <style scoped lang="scss">
  199. @import "index.scss";
  200. .loading-container {
  201. display: flex;
  202. flex-direction: column;
  203. align-items: center;
  204. justify-content: center;
  205. padding: 40rpx;
  206. .loading-text {
  207. margin-top: 20rpx;
  208. color: #999;
  209. font-size: 28rpx;
  210. }
  211. }
  212. .empty-state {
  213. display: flex;
  214. flex-direction: column;
  215. align-items: center;
  216. justify-content: center;
  217. padding: 80rpx 40rpx;
  218. .empty-image {
  219. width: 200rpx;
  220. height: 200rpx;
  221. margin-bottom: 20rpx;
  222. }
  223. .empty-text {
  224. color: #999;
  225. font-size: 28rpx;
  226. }
  227. }
  228. </style>