From 15edbb0f760ada6b3b4140e94798ef104d95f9b0 Mon Sep 17 00:00:00 2001 From: huliyong <2783385703@qq.com> Date: Sun, 10 Aug 2025 20:42:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=AE=A2=E5=8D=95):=20=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=86=8D=E6=9D=A5=E4=B8=80=E5=8D=95=E5=8A=9F=E8=83=BD=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BC=B4=E5=AE=A0=E5=B8=88=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增再来一单功能,支持从历史订单重新下单并保留原订单数据。重构伴宠师选择组件为独立组件,优化多选交互体验。添加10元再来一单费用计算逻辑,完善订单修改流程。 主要变更: 1. 新增CompanionItem组件统一伴宠师展示样式 2. 实现订单数据保留和定位信息处理 3. 添加再来一单费用计算和显示 4. 优化伴宠师多选交互和默认选中逻辑 5. 完善订单状态判断和服务记录查看条件 --- .trae/rules/project_rules.md | 1 + api/order/order.js | 14 +- components/CompanionItem/CompanionItem.vue | 176 +++++ pages.json | 2 +- pages/newOrder/confirmOrder.vue | 22 +- pages/newOrder/serviceNew2.vue | 96 ++- pages_order/companionPetList/companionPetList.vue | 174 +---- .../components/order/CompanionSelectPopup.vue | 285 ++++++- pages_order/order/companionSelect.vue | 834 ++++++++++----------- pages_order/order/orderDetail.vue | 6 +- pages_order/order/orderList.vue | 11 +- pages_order/order/orderModify.vue | 2 + store/index.js | 2 + 13 files changed, 1017 insertions(+), 608 deletions(-) create mode 100644 .trae/rules/project_rules.md create mode 100644 components/CompanionItem/CompanionItem.vue diff --git a/.trae/rules/project_rules.md b/.trae/rules/project_rules.md new file mode 100644 index 0000000..b0d505c --- /dev/null +++ b/.trae/rules/project_rules.md @@ -0,0 +1 @@ +当前项目是uniapp开发微信小程序,请你写出来的代码要符合微信小程序的规范,并且需要后期能够方便的进行维护扩展,方便uniapp转其他平台的开发 \ No newline at end of file diff --git a/api/order/order.js b/api/order/order.js index 3d39683..e1d3cf3 100644 --- a/api/order/order.js +++ b/api/order/order.js @@ -180,7 +180,7 @@ export const orderPay = (data) => { }) } -// 再次支付订单 +// 更新订单基本信息 export const updateBaseOrder = (params) => { return request({ url: '/applet/mall/order/updateBaseOrder', @@ -190,4 +190,16 @@ export const updateBaseOrder = (params) => { method: "POST", params }) +} + +// 查询服务过的伴宠师 +export const getTecByUser = (params) => { + return request({ + headers: { + "isToken": true + }, + url: "/applet/mall/order/getTecByUser", + method: 'get', + params + }) } \ No newline at end of file diff --git a/components/CompanionItem/CompanionItem.vue b/components/CompanionItem/CompanionItem.vue new file mode 100644 index 0000000..4adc5c9 --- /dev/null +++ b/components/CompanionItem/CompanionItem.vue @@ -0,0 +1,176 @@ + + + + + \ No newline at end of file diff --git a/pages.json b/pages.json index 58be278..fab88a9 100644 --- a/pages.json +++ b/pages.json @@ -415,7 +415,7 @@ "style": { "navigationBarTitleText": "服务过的伴宠师", "navigationBarBackgroundColor": "#FFBF60", - "enablePullDownRefresh": false, + "enablePullDownRefresh": true, "navigationBarTextStyle": "white" } }, diff --git a/pages/newOrder/confirmOrder.vue b/pages/newOrder/confirmOrder.vue index 2e12308..da3855e 100644 --- a/pages/newOrder/confirmOrder.vue +++ b/pages/newOrder/confirmOrder.vue @@ -181,6 +181,10 @@ -¥{{ parseFloat(memberDiscount).toFixed(2) }} + + 再来一单费用 + +¥{{ parseFloat($globalData.newOrderData.moreOrderPrice).toFixed(2) }} + 应付费用 ¥{{ parseFloat(finalPrice).toFixed(2) }} @@ -837,6 +841,11 @@ order.orderId = this.$globalData.newOrderData.orderId } + // 再来一单费用 + if(this.$globalData.newOrderData.moreOrderPrice){ + order.moreOrderPrice = this.$globalData.newOrderData.moreOrderPrice + } + console.log(order) return order }, @@ -902,14 +911,16 @@ needPreFamiliarize: [] } uni.reLaunch({ - url: '/pages_order/order/payOrderSuccessful' - // url: '/pages/details/successful' + url: '/pages_order/order/orderList' }); }, fail: (err) => { this.loading = false console.log('支付失败', err) this.$modal.showToast('支付失败') + uni.reLaunch({ + url: '/pages_order/order/' + }); }, complete: () => { this.loading = false @@ -938,9 +949,12 @@ const originalPriceBeforeMemberDiscount = this.originalTotalPrice / this.$store.state.memberRate this.memberDiscount = (originalPriceBeforeMemberDiscount - this.originalTotalPrice).toFixed(2) + // 获取再来一单费用 + const moreOrderPrice = this.$globalData.newOrderData.moreOrderPrice || 0 + // 计算最终支付价格 - // finalPrice: 最终支付价格 = 已应用会员折扣的价格 - 优惠券优惠 - this.finalPrice = (this.originalTotalPrice - this.discount).toFixed(2) + // finalPrice: 最终支付价格 = 已应用会员折扣的价格 + 再来一单费用 - 优惠券优惠 + this.finalPrice = (this.originalTotalPrice + moreOrderPrice - this.discount).toFixed(2) }, getCouponAmountOrDiscount(item) { if (item.stockType == "PDISCOUNT") { diff --git a/pages/newOrder/serviceNew2.vue b/pages/newOrder/serviceNew2.vue index a734542..962e736 100644 --- a/pages/newOrder/serviceNew2.vue +++ b/pages/newOrder/serviceNew2.vue @@ -457,6 +457,53 @@ export default { return d * this.distancePrice }, + getCustomServicesByOrder(pet, date){ + // 获取所有当前可用的定制服务 + const currentCustomServices = JSON.parse(this.customServicesStr || '[]') + const customServices = [] + + // 遍历所有当前定制服务 + currentCustomServices.forEach(service => { + let quantity = 0 // 默认数量为0 + + // 如果存在原订单数据,查找对应的数量 + if(this.$globalData.newOrderData.originalOrderData) { + const originalOrderData = this.$globalData.newOrderData.originalOrderData + + if(originalOrderData.orderItemList && originalOrderData.orderItemList.length > 0) { + // 查找原订单中对应的定制服务项目 + const originalItem = originalOrderData.orderItemList.find(item => { + // 定制服务的categoryId为78,且不是主产品,且skuId匹配 + if(item.productCategoryId === 78 && item.isMainProduct !== 1 && item.skuId === service.skuId) { + // 查找对应的服务记录,匹配宠物和日期 + const matchingService = originalOrderData.orderServiceList.find(serviceRecord => { + return serviceRecord.id === item.orderServiceId && + serviceRecord.petId === pet.id && + serviceRecord.serviceDate === date + }) + return !!matchingService + } + return false + }) + + if(originalItem) { + quantity = originalItem.quantity + } + } + } + + // 添加定制服务到结果中 + customServices.push({ + skuId: service.skuId, + name: service.name, + price: service.price, + quantity: quantity, + isMainProduct: false + }) + }) + + return customServices + }, initNewOrderData() { const needPreFamiliarize = this.$globalData.newOrderData.needPreFamiliarize.length > 0 const pets = [] @@ -470,6 +517,9 @@ export default { // 单个宠物服务日期列表 const serviceDateList = pet.selectedDate.map(item => item.date) serviceDateList.forEach(date => { + // 获取原订单中该宠物在该日期的定制服务 + const originalCustomServices = this.getCustomServicesByOrder(pet, date) + pets.push({ petId: pet.id, serviceDate: date, @@ -480,7 +530,7 @@ export default { photo: pet.photo, feedCount: 1, selectedTimeSlots: [], - customServices: [], + customServices: originalCustomServices, //额外费用 additionalCost: 0 }) @@ -550,6 +600,27 @@ export default { this.feedCount = selectedPet ? selectedPet.feedCount : 1 // 还原当前选择日期是否已选择定制服务 this.customServices = selectedPet.customServices.length > 0 ? selectedPet.customServices : JSON.parse(this.customServicesStr) + + /* + if (selectedPet && selectedPet.customServices.length > 0) { + // 如果当前宠物已有定制服务(可能来自原订单),直接使用 + this.customServices = selectedPet.customServices + } else { + // 否则使用默认的定制服务列表 + this.customServices = JSON.parse(this.customServicesStr) + // 如果存在原订单数据,尝试获取该宠物在该日期的定制服务 + if (this.$globalData.newOrderData.originalOrderData) { + const currentPet = this.currentPets.find(pet => pet.id === this.currentPetId) + if (currentPet) { + const originalCustomServices = this.getCustomServicesByOrder(currentPet, this.currentMonthDay.fullDate) + if (originalCustomServices.length > 0) { + this.customServices = originalCustomServices + } + } + } + } + */ + this.getCurrentDayPrice(this.currentMonthDay.fullDate) }, @@ -825,12 +896,16 @@ export default { this.customServiceItemCount = customServiceItemCount this.customServicesTotalCost = customServicesTotalCost + // 再来一单费用 + const moreOrderPrice = this.$globalData.newOrderData.moreOrderPrice || 0; + this.totalPrice = Number(this.needPreFamiliarizeCost) + Number(this.baseServiceTotalCost) + Number(this.additionalTotalCost) + Number(this.multServicesTotalCost) + Number(this.companionLevelPrice()) - + Number(this.customServicesTotalCost); // 更新总价 + + Number(this.customServicesTotalCost) + + Number(moreOrderPrice); // 更新总价 this.getCurrentDayPrice(this.currentMonthDay.fullDate) }, @@ -850,6 +925,7 @@ export default { }, goNext() { + console.log('this.$globalData.newOrderData', this.$globalData.newOrderData) this.calculateTotalPrice(); // 计算总价 this.showPriceDetails = false; this.$globalData.newOrderData.currentPetsByDay = this.newOrderData.pets @@ -861,6 +937,7 @@ export default { goBack() { this.showPriceDetails = false + let len = getCurrentPages().length; this.loading = false if (len >= 2) { @@ -1023,6 +1100,21 @@ export default { item: customServiceItem }) } + + // 再来一单费用 + const moreOrderPrice = this.$globalData.newOrderData.moreOrderPrice || 0; + if (moreOrderPrice > 0) { + priceDetails.push({ + name: '再来一单', + item: [{ + itemName: '再来一单费用', + price: moreOrderPrice, + quantity: 1, + unit: '次' + }] + }) + } + this.priceDetails = priceDetails this.calculateTotalPrice() }, diff --git a/pages_order/companionPetList/companionPetList.vue b/pages_order/companionPetList/companionPetList.vue index 40607d7..30b46c1 100644 --- a/pages_order/companionPetList/companionPetList.vue +++ b/pages_order/companionPetList/companionPetList.vue @@ -106,64 +106,13 @@ - - - - - - - - - - - - - - - - {{ item.userName || '匿名' }} - - - sex - - - - - 点赞数{{ item.appletUsersTeacher.thumbsUp || 0 }} - - - - - - - 距离{{ item.distanceText }}km - - - {{ '<' }}1km - - - - - 简介:{{ item.appletUsersTeacher.userBrief || '暂无' }} - - - - - - - - 养宠{{ item.experience || 0 }}年 | 评价{{ item.commentNum || 0 }}条 | 服务小结{{ item.serviceSummaryNum || 0 }}份 - - - - + + - + 系统下单 - + 指定伴宠师 @@ -48,42 +48,247 @@ diff --git a/pages_order/order/companionSelect.vue b/pages_order/order/companionSelect.vue index 809b2c1..6785223 100644 --- a/pages_order/order/companionSelect.vue +++ b/pages_order/order/companionSelect.vue @@ -1,434 +1,416 @@ \ No newline at end of file diff --git a/pages_order/order/orderDetail.vue b/pages_order/order/orderDetail.vue index 42ab434..01f5623 100644 --- a/pages_order/order/orderDetail.vue +++ b/pages_order/order/orderDetail.vue @@ -34,13 +34,13 @@ 修改订单 - + 去评价 - + 再来一单 - + 查看服务记录 diff --git a/pages_order/order/orderList.vue b/pages_order/order/orderList.vue index 42e8efa..59a2ecc 100644 --- a/pages_order/order/orderList.vue +++ b/pages_order/order/orderList.vue @@ -78,10 +78,10 @@ @click="goToReview(order)"> 去评价 - + 再来一单 - + 查看服务记录 @@ -206,10 +206,10 @@ } }, onPullDownRefresh() { - this.refreshing() + this.refresh() }, onShow() { - this.refreshing() + this.refresh() }, onReachBottom() { this.loadMore() @@ -435,7 +435,8 @@ // 处理再来一单 handleReorder(order) { this.currentOrder = order; - this.$refs.companionSelectPopup.open(); + // 传递订单中的技师ID和订单ID,用于默认选中和获取订单详情 + this.$refs.companionSelectPopup.open(order.teacherId, order.orderId); }, // 修改订单 diff --git a/pages_order/order/orderModify.vue b/pages_order/order/orderModify.vue index ce77c44..1fb0b1e 100644 --- a/pages_order/order/orderModify.vue +++ b/pages_order/order/orderModify.vue @@ -246,6 +246,8 @@ export default { let order = this.originalOrderData + this.$globalData.newOrderData.originalOrderData = order + // 验证地址是否存在 if(order.addressId) { try { diff --git a/store/index.js b/store/index.js index 6296584..a1680dc 100644 --- a/store/index.js +++ b/store/index.js @@ -5,6 +5,7 @@ import getters from './getters' import { getConfigList } from '@/api/system/configList' import { getPersonalInfo } from "@/api/system/personal.js" +import { setOpenIdKey } from '@/utils/auth' Vue.use(Vuex) @@ -73,6 +74,7 @@ const store = new Vuex.Store({ }, setUserInfo(state, userInfo){ state.userInfo = userInfo; + setOpenIdKey(userInfo.openId) }, setNewUserCoupon(state, coupon){ state.NewUserCoupon = coupon