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

277 lines
7.2 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.date"
  51. :status="current == 0"
  52. :list="item.list"
  53. :current="current"
  54. />
  55. </view>
  56. <view v-else class="empty-state">
  57. <image src="/static/images/ydd/empty.png" mode="aspectFit" class="empty-image"></image>
  58. <text class="empty-text">暂无订单数据</text>
  59. </view>
  60. </view>
  61. <!-- <orderListByData :list="list" v-else /> -->
  62. </view>
  63. </view>
  64. </template>
  65. <script setup>
  66. import {
  67. computed,
  68. reactive,
  69. ref
  70. } from "vue";
  71. import systemOrder from "./components/systemOrder.vue";
  72. import orderListByData from "./components/orderListByData.vue";
  73. import timelineService from "./components/timelineService.vue";
  74. import {
  75. onShow,
  76. onLoad,
  77. } from "@dcloudio/uni-app"
  78. import {
  79. getLoginStatus
  80. } from "@/utils/useMixin.js"
  81. // import personOrder from "./components/personOrder.vue";
  82. // import lossOrder from "./components/lossOrder.vue";
  83. import {
  84. myList
  85. } from "@/api/receivingHall/index.js"
  86. import {
  87. getOrderDateList,
  88. } from "@/api/order/order.js"
  89. import {
  90. appletOrderDateFrequencyList,
  91. } from "@/api/order/frequency.js"
  92. import {
  93. useStore
  94. } from "vuex"
  95. import { getOrderServiceText, getProductNameText } from '@/utils/serviceTime.js'
  96. onShow(() => {
  97. if (!getLoginStatus()) return;
  98. getList();
  99. })
  100. const current = ref(0)
  101. const activeIndex = ref(1)
  102. const list = ref([])
  103. const dateOrderList = ref([])
  104. const loading = ref(false) // 添加loading状态
  105. const store = useStore();
  106. const userInfo = computed(() => {
  107. return store.getters.userInfo;
  108. })
  109. const tabList1 = reactive([{
  110. name: '待服务',
  111. badge: {
  112. value: 0,
  113. }
  114. },
  115. {
  116. name: '进行中',
  117. badge: {
  118. value: 0,
  119. }
  120. },
  121. {
  122. name: '已完成',
  123. badge: {
  124. value: 0,
  125. }
  126. },
  127. ])
  128. const tabList2 = reactive([{
  129. name: '待上门',
  130. badge: {
  131. value: 0,
  132. }
  133. },
  134. {
  135. name: '已完成',
  136. badge: {
  137. value: 0,
  138. }
  139. },
  140. ])
  141. function getList() {
  142. loading.value = true; // 开始加载
  143. let index = current.value;
  144. if (activeIndex.value == 1) {
  145. myList({
  146. orderStatus: index,
  147. userId: userInfo.value.userId
  148. })
  149. .then(res => {
  150. if (res.code == 200) {
  151. list.value = res.data.rows
  152. tabList1[index].badge.value = res.data.total
  153. list.value.forEach(item => {
  154. item.h5OrderVO.petVOList.forEach(pet => {
  155. pet.orderServiceText = getOrderServiceText(pet.id, item.h5OrderVO.orderServiceList)
  156. pet.productNameText = getProductNameText(pet.id, item.h5OrderVO.orderItemList, item.h5OrderVO.orderServiceList)
  157. })
  158. })
  159. }
  160. })
  161. .finally(() => {
  162. if(activeIndex.value == 1){
  163. loading.value = false; // 结束加载
  164. }
  165. })
  166. }else{
  167. dateOrderList.value = []
  168. appletOrderDateFrequencyList({
  169. status: index == 0 ? '0,1' : '2',
  170. masterId: userInfo.value.userId
  171. })
  172. .then(res => {
  173. if (res.code == 200) {
  174. dateOrderList.value = res.data
  175. // 更新标签数量显示
  176. let totalOrders = 0;
  177. dateOrderList.value.forEach(item => {
  178. totalOrders += item.list.length || 0;
  179. });
  180. tabList2[index].badge.value = totalOrders;
  181. }
  182. })
  183. .finally(() => {
  184. if(activeIndex.value == 2){
  185. loading.value = false; // 结束加载
  186. }
  187. })
  188. // getOrderDateList({
  189. // status: index,
  190. // userId: userInfo.value.userId
  191. // })
  192. // .then(res => {
  193. // if (res.code == 200) {
  194. // dateOrderList.value = res.data
  195. // // 更新标签数量显示
  196. // let totalOrders = 0;
  197. // dateOrderList.value.forEach(item => {
  198. // totalOrders += item.num || 0;
  199. // });
  200. // tabList2[index].badge.value = totalOrders;
  201. // }
  202. // })
  203. // .finally(() => {
  204. // if(activeIndex.value == 2){
  205. // loading.value = false; // 结束加载
  206. // }
  207. // })
  208. }
  209. }
  210. function clickTab(index) {
  211. current.value = 0;
  212. activeIndex.value = index;
  213. getList();
  214. }
  215. const classIfyClickTab = (item) => {
  216. current.value = item.index;
  217. getList();
  218. }
  219. </script>
  220. <style scoped lang="scss">
  221. @import "index.scss";
  222. .loading-container {
  223. display: flex;
  224. flex-direction: column;
  225. align-items: center;
  226. justify-content: center;
  227. padding: 40rpx;
  228. .loading-text {
  229. margin-top: 20rpx;
  230. color: #999;
  231. font-size: 28rpx;
  232. }
  233. }
  234. .empty-state {
  235. display: flex;
  236. flex-direction: column;
  237. align-items: center;
  238. justify-content: center;
  239. padding: 80rpx 40rpx;
  240. .empty-image {
  241. width: 200rpx;
  242. height: 200rpx;
  243. margin-bottom: 20rpx;
  244. }
  245. .empty-text {
  246. color: #999;
  247. font-size: 28rpx;
  248. }
  249. }
  250. </style>