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

132 lines
3.1 KiB

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. <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',padding:'0 52rpx'}" lineColor="#FFFFFF" @click="clickEvent"></up-tabs>
  13. </view>
  14. </up-sticky>
  15. <view class="container">
  16. <List :orderList="orderlist" :current="current" @update="updateList"></List>
  17. </view>
  18. </view>
  19. </template>
  20. <script setup>
  21. import {
  22. computed,
  23. reactive,
  24. ref
  25. } from "vue";
  26. import List from "./components/list.vue";
  27. import {
  28. onShow
  29. } from "@dcloudio/uni-app"
  30. import { getLoginStatus } from "@/utils/useMixin.js"
  31. import {
  32. orderList
  33. } from "@/api/receivingHall/index.js"
  34. import submitBut from "@/components/submitBut/index.vue"
  35. import {
  36. useStore
  37. } from "vuex"
  38. import dayjs from "dayjs";
  39. const current = ref(0)
  40. const list = reactive([{
  41. name: '系统派单',
  42. badge: {
  43. value: 0,
  44. }
  45. },
  46. {
  47. name: '个人订单',
  48. badge: {
  49. value: 0,
  50. }
  51. },
  52. {
  53. name: '流失订单',
  54. badge: {
  55. value: 0,
  56. }
  57. },
  58. ])
  59. const store = useStore();
  60. const userInfo = computed(() => {
  61. return store.getters.userInfo
  62. })
  63. const orderlist = ref([]);
  64. onShow(() => {
  65. if (!getLoginStatus()) return;
  66. getOrderList();
  67. })
  68. // 获取接单大厅列表
  69. const getOrderList = async () => {
  70. let response = await orderList({
  71. type: current.value,
  72. userIdJson: userInfo.value.userId
  73. });
  74. if (response.code == 200 && response.data) {
  75. orderlist.value = response.data.rows;
  76. list[current.value].badge.value = response.data.total
  77. orderlist.value.forEach(item => {
  78. item.h5OrderVO.petVOList.forEach(pet => {
  79. pet.orderServiceText = getOrderServiceText(pet.id, item.h5OrderVO.orderServiceList)
  80. pet.productNameText = getProductNameText(pet.id, item.h5OrderVO.orderItemList, item.h5OrderVO.orderServiceList)
  81. })
  82. })
  83. }
  84. }
  85. function getOrderServiceText(petId, orderServiceList){
  86. let YYYY = undefined
  87. return orderServiceList
  88. .filter(service => service.petId == petId)//过滤
  89. .map(service => dayjs(service.serviceDate))//转成时间
  90. .sort((a, b) => a.valueOf() - b.valueOf())//排序
  91. .map((service, i) => {
  92. // if(YYYY && YYYY.format('YYYY-MM') == service.format('YYYY-MM')){
  93. // return service.format('DD')
  94. // }
  95. // if(YYYY && YYYY.format('YYYY') == service.format('YYYY')){
  96. // return service.format('MM-DD')
  97. // }
  98. // YYYY = service
  99. return service.format('MM-DD')
  100. })
  101. }
  102. function getProductNameText(petId, productList, orderServiceList){
  103. let orderService = orderServiceList.filter(service => service.petId == petId)
  104. return productList
  105. .filter(product => orderService.filter(service => service.id == product.orderServiceId).length > 0)
  106. .map(product => product.productName)
  107. }
  108. const clickEvent = (item) => {
  109. current.value = item.index;
  110. getOrderList();
  111. }
  112. const updateList = () => {
  113. getOrderList();
  114. }
  115. </script>
  116. <style scoped lang="scss">
  117. @import "index.scss";
  118. </style>