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

130 lines
3.0 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. orderlist.value.forEach(item => {
  77. item.h5OrderVO.petVOList.forEach(pet => {
  78. pet.orderServiceText = getOrderServiceText(pet.id, item.h5OrderVO.orderServiceList)
  79. pet.productNameText = getProductNameText(pet.id, item.h5OrderVO.orderItemList, item.h5OrderVO.orderServiceList)
  80. })
  81. })
  82. }
  83. }
  84. function getOrderServiceText(petId, orderServiceList){
  85. let YYYY = undefined
  86. return orderServiceList
  87. .filter(service => service.petId == petId)//过滤
  88. .map(service => dayjs(service.serviceDate))//转成时间
  89. .sort((a, b) => a.valueOf() - b.valueOf())//排序
  90. .map((service, i) => {
  91. if(YYYY && YYYY.format('YYYY-MM') == service.format('YYYY-MM')){
  92. return service.format('DD')
  93. }
  94. if(YYYY && YYYY.format('YYYY') == service.format('YYYY')){
  95. return service.format('MM-DD')
  96. }
  97. YYYY = service
  98. return service.format('YYYY-MM-DD')
  99. })
  100. }
  101. function getProductNameText(petId, productList, orderServiceList){
  102. let orderService = orderServiceList.filter(service => service.petId == petId)
  103. return productList
  104. .filter(product => orderService.filter(service => service.id == product.orderServiceId).length > 0)
  105. .map(product => product.productName)
  106. }
  107. const clickEvent = (item) => {
  108. current.value = item.index;
  109. getOrderList();
  110. }
  111. const updateList = () => {
  112. getOrderList();
  113. }
  114. </script>
  115. <style scoped lang="scss">
  116. @import "index.scss";
  117. </style>