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

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