Browse Source

refactor(订单管理): 优化订单列表显示逻辑和样式

- 在 `orderTakingManage/index.vue` 中引入 `dayjs` 并添加 `getOrderServiceText` 和 `getProductNameText` 方法,用于格式化服务日期和产品名称
- 在 `orderTakingManage/components/list.vue` 中重构订单列表的显示逻辑,直接使用 `pet` 对象的属性进行渲染,提升代码可读性和维护性
- 在 `utils/getUrl.js` 中更新开发环境的 API 地址
- 修复 `Modal/index.vue` 文件末尾的样式标签格式问题
master
前端-胡立永 1 month ago
parent
commit
068d248bef
4 changed files with 47 additions and 11 deletions
  1. +1
    -1
      components/Modal/index.vue
  2. +8
    -8
      pages/orderTakingManage/components/list.vue
  3. +35
    -0
      pages/orderTakingManage/index.vue
  4. +3
    -2
      utils/getUrl.js

+ 1
- 1
components/Modal/index.vue View File

@ -75,4 +75,4 @@ defineExpose({
background: #FFF4E6;
color: #FFC269;
}
</style>
</style>

+ 8
- 8
pages/orderTakingManage/components/list.vue View File

@ -11,25 +11,25 @@
</view>
</view>
<view class="container-list">
<view class="flex-between flex mb28">
<up-image style="flex-shrink:0" class="mr20" width="70px" height="70px" src=""
<view class="flex mb28" v-for="(pet, index) in item.h5OrderVO.petVOList">
<up-image style="flex-shrink:0" class="mr20" width="70px" height="70px" :src="pet.photo"
shape="circle"></up-image>
<view>
<!-- <view class="font28 col3">服务天数: 2天 I {{itemService.serviceDate}}</view> -->
<view class="font28 col3">服务天数: {{ item.h5OrderVO.orderServiceList.length }} I
<view class="font28 col3">服务天数: {{ pet.orderServiceText.length }} I {{ pet.orderServiceText.join(',') }}</view>
<!-- <view class="font28 col3">服务天数: {{ item.h5OrderVO.orderServiceList.length }} I
<text v-for="itemService in item.h5OrderVO.orderServiceList" :key="itemService.id">
{{ itemService.serviceDate }}
</text>
</view>
</view> -->
<!-- <view style="margin: 18rpx 0">期望上门时间{{itemService.expectServiceTime}}</view> -->
<view>中华田园犬(小型犬) |
<view>{{ pet.breed }} | {{ pet.productNameText.join(',') }}
<text v-for="itemPet in item.h5OrderVO.orderItemList" :key="itemPet.id">
<!-- <text v-for="itemPet in item.h5OrderVO.orderItemList" :key="itemPet.id">
{{ itemPet.productName }}
</text>
</text> -->
</view>


+ 35
- 0
pages/orderTakingManage/index.vue View File

@ -37,6 +37,7 @@
import {
useStore
} from "vuex"
import dayjs from "dayjs";
const current = ref(0)
const list = reactive([{
@ -78,8 +79,42 @@
if (response.code == 200 && response.data) {
orderlist.value = response.data.rows;
orderlist.value.forEach(item => {
item.h5OrderVO.petVOList.forEach(pet => {
pet.orderServiceText = getOrderServiceText(pet.id, item.h5OrderVO.orderServiceList)
pet.productNameText = getProductNameText(pet.id, item.h5OrderVO.orderItemList, item.h5OrderVO.orderServiceList)
})
})
}
}
function getOrderServiceText(petId, orderServiceList){
let YYYY = undefined
return orderServiceList
.filter(service => service.petId == petId)//
.map(service => dayjs(service.serviceDate))//
.sort((a, b) => a.valueOf() - b.valueOf())//
.map((service, i) => {
if(YYYY && YYYY.format('YYYY-MM') == service.format('YYYY-MM')){
return service.format('DD')
}
if(YYYY && YYYY.format('YYYY') == service.format('YYYY')){
return service.format('MM-DD')
}
YYYY = service
return service.format('YYYY-MM-DD')
})
}
function getProductNameText(petId, productList, orderServiceList){
let orderService = orderServiceList.filter(service => service.petId == petId)
return productList
.filter(product => orderService.filter(service => service.id == product.orderServiceId).length > 0)
.map(product => product.productName)
}
const clickEvent = (item) => {
current.value = item.index;


+ 3
- 2
utils/getUrl.js View File

@ -1,9 +1,10 @@
let current = "release";
const accountInfo = wx.getAccountInfoSync();
// current = accountInfo.miniProgram.envVersion;
current = accountInfo.miniProgram.envVersion;
const api = {
develop: "http://youyi-test.natapp1.cc/prod-api", // 开发
develop:"http://h5.xzaiyp.top/prod-api",
// develop: "http://youyi-test.natapp1.cc/prod-api", // 开发
trial: "https://pet-admin.hhlm1688.com/prod-api", //测试
release: "https://pet-admin.hhlm1688.com/api/prod-api", // 线上
}


Loading…
Cancel
Save