From e57fd125f7651e4f81918262b258d770ff83ec85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=90=A6?= Date: Mon, 26 Jan 2026 15:55:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E9=97=AE=E8=AF=8A=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E4=B8=8D=E8=83=BD=E9=80=89=E6=8B=A9=E5=88=B0=E5=BA=97?= =?UTF-8?q?=EF=BC=8C=E8=81=8A=E5=A4=A9UI=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- subPackages/chat/chat.vue | 626 ++++++------------ subPackages/chat/components/MessageBubble.vue | 375 +++++++++++ subPackages/my/my-drug/drug-info.vue | 87 ++- subPackages/my/record-pay.vue | 92 ++- subPackages/product/product.vue | 10 + subPackages/product/symptoms.vue | 10 + 6 files changed, 741 insertions(+), 459 deletions(-) create mode 100644 subPackages/chat/components/MessageBubble.vue diff --git a/subPackages/chat/chat.vue b/subPackages/chat/chat.vue index 9b21564..f73956e 100644 --- a/subPackages/chat/chat.vue +++ b/subPackages/chat/chat.vue @@ -1,21 +1,20 @@ + + \ No newline at end of file diff --git a/subPackages/my/my-drug/drug-info.vue b/subPackages/my/my-drug/drug-info.vue index 2b0f531..dc7dcb7 100644 --- a/subPackages/my/my-drug/drug-info.vue +++ b/subPackages/my/my-drug/drug-info.vue @@ -200,11 +200,17 @@ export default { order_no: "", // 订单编号 p_id: "", // 处方id orderType: 0, // 处方id + originalList: [{ + text: '快递到家' + }, { + text: '到店自取' + }], list: [{ text: '快递到家' }, { text: '到店自取' }], + is_online: 0, // 是否在线复诊 0-否 非0-是 toshowed: false, tips: { text: '配送方式', @@ -315,32 +321,65 @@ export default { this.toshowed = true }, chooseway(index) { - this.delivery_method = index - + // 如果选择到店自取(index == 1),检查 is_online + if (index == 1 && this.is_online != 0) { + // 阻止选择并提示 + this.$refs.uToast.show({ + title: '在线复诊订单不支持到店自取,请选择收货地址', + type: 'default', + icon: false + }) + return + } + + // 先调用接口更新,成功后再更新页面状态 if (index == 1) { - this.isshowed = true - this.isshow = false - this.toUpdata() + // 到店自取:先调用接口,成功后再更新页面 + this.toUpdata(index) } else { + // 快递到家:跳转到地址选择页面 this.isshowed = false this.isshow = true this.toChoose() } }, // 更新配送方式 - toUpdata() { + toUpdata(deliveryMethodIndex) { if (!this.order_id) return + + // 如果传入了参数,使用传入的值,否则使用当前的 delivery_method + const targetDeliveryMethod = deliveryMethodIndex !== undefined ? deliveryMethodIndex : this.delivery_method + getDelivery({ method: "post", data: { address_id: uni.getStorageSync('address_id'), - delivery_method: this.delivery_method, + delivery_method: targetDeliveryMethod, order_id: this.order_id, store_id: uni.getStorageSync('store_id') || '11001' } }).then((res) => { - if (res.data.errcode == 0) { + if (res.data.errcode === 0) { + // 接口成功后再更新页面状态 + if (deliveryMethodIndex !== undefined) { + this.delivery_method = deliveryMethodIndex + if (deliveryMethodIndex == 1) { + this.isshowed = true + this.isshow = false + } else { + this.isshowed = false + this.isshow = true + } + } + // 刷新订单信息 this.getInfo() + } else { + // 错误处理:拒绝更新并显示错误信息,不更新页面状态 + this.$refs.uToast.show({ + title: res.data.msg || '更新失败', + type: 'default', + icon: false + }) } }) }, @@ -377,12 +416,34 @@ export default { uni.setStorageSync('userWay_order_id', res.data.data.ProductOrder.id) uni.setStorageSync('delivery_method', res.data.data.ProductOrder.delivery_method) - if (res.data.data.ProductOrder.delivery_method == 1) { - this.isshowed = true - this.isshow = false + // 检查 is_online 字段,动态控制 list 数组 + if (res.data.data.ProductOrder && res.data.data.ProductOrder.is_online !== undefined) { + this.is_online = res.data.data.ProductOrder.is_online + } else if (res.data.data.is_online !== undefined) { + this.is_online = res.data.data.is_online + } + + // 如果 is_online !== 0,则不显示到店自取选项 + if (this.is_online != 0) { + this.list = [{ + text: '快递到家' + }] } else { - this.isshowed = false - this.isshow = true + // 如果 is_online === 0,显示所有选项 + this.list = [...this.originalList] + } + + // 根据返回的订单数据更新页面状态(配送方式) + if (res.data.data.ProductOrder && res.data.data.ProductOrder.delivery_method !== undefined) { + const deliveryMethod = res.data.data.ProductOrder.delivery_method + this.delivery_method = deliveryMethod + if (deliveryMethod == 1) { + this.isshowed = true + this.isshow = false + } else { + this.isshowed = false + this.isshow = true + } } // 查询处方状态 diff --git a/subPackages/my/record-pay.vue b/subPackages/my/record-pay.vue index 335be6e..c34f9a0 100644 --- a/subPackages/my/record-pay.vue +++ b/subPackages/my/record-pay.vue @@ -202,11 +202,17 @@ order_id: "", // 订单id order_no: "", // 订单编号 p_id: "", // 处方id + originalList: [{ + text: '快递到家' + }, { + text: '到店自取' + }], list: [{ text: '快递到家' }, { text: '到店自取' }], + is_online: 0, // 是否在线复诊 0-否 非0-是 toshowed: false, tips: { text: '配送方式', @@ -264,14 +270,23 @@ this.toshowed = true }, chooseway(index) { - this.wayText = this.list[index].text - this.delivery_method = index - + // 如果选择到店自取(index == 1),检查 is_online + if (index == 1 && this.is_online != 0) { + // 阻止选择并提示 + this.$refs.uToast.show({ + title: '在线复诊订单不支持到店自取,请选择收货地址', + type: 'default', + icon: false + }) + return + } + + // 先调用接口更新,成功后再更新页面状态 if (index == 1) { - this.isshowed = true - this.isshow = false - this.toUpdata() + // 到店自取:先调用接口,成功后再更新页面 + this.toUpdata(index) } else { + // 快递到家:跳转到地址选择页面 this.isshowed = false this.isshow = true this.toChoose() @@ -279,19 +294,45 @@ // console.log(`点击了第${index + 1}项,内容为:${this.list[index].text}`) }, // 更新配送方式 - toUpdata() { + toUpdata(deliveryMethodIndex) { + // 如果传入了参数,使用传入的值,否则使用当前的 delivery_method + const targetDeliveryMethod = deliveryMethodIndex !== undefined ? deliveryMethodIndex : this.delivery_method + + if (this.order_id == '') { + return ; + } getDelivery({ method: "post", data: { address_id: uni.getStorageSync('address_id'), - delivery_method: this.delivery_method, + delivery_method: targetDeliveryMethod, order_id: this.order_id, store_id: uni.getStorageSync('store_id') || '11001' } }).then((res) => { - if (res.data.errcode == 0) { + if (res.data.errcode === 0) { + // 接口成功后再更新页面状态 + if (deliveryMethodIndex !== undefined) { + this.wayText = this.list[deliveryMethodIndex].text + this.delivery_method = deliveryMethodIndex + if (deliveryMethodIndex == 1) { + this.isshowed = true + this.isshow = false + } else { + this.isshowed = false + this.isshow = true + } + } + // 刷新订单信息 this.getInfo() // console.log(res, '确定代煎'); + } else { + // 错误处理:拒绝更新并显示错误信息,不更新页面状态 + this.$refs.uToast.show({ + title: res.data.msg || '更新失败', + type: 'default', + icon: false + }) } }) }, @@ -333,6 +374,39 @@ uni.setStorageSync('userWay_order_id', res.data.data.ProductOrder.id) // this.order_no = res.data.data.ProductOrder.order_no // console.log(this.west.content); + + // 检查 is_online 字段,动态控制 list 数组 + if (res.data.data.ProductOrder && res.data.data.ProductOrder.is_online !== undefined) { + this.is_online = res.data.data.ProductOrder.is_online + } else if (res.data.data.is_online !== undefined) { + this.is_online = res.data.data.is_online + } + + // 如果 is_online !== 0,则不显示到店自取选项 + if (this.is_online != 0) { + this.list = [{ + text: '快递到家' + }] + } else { + // 如果 is_online === 0,显示所有选项 + this.list = [...this.originalList] + } + + // 根据返回的订单数据更新页面状态(配送方式) + if (res.data.data.ProductOrder && res.data.data.ProductOrder.delivery_method !== undefined) { + const deliveryMethod = res.data.data.ProductOrder.delivery_method + this.delivery_method = deliveryMethod + if (this.list[deliveryMethod]) { + this.wayText = this.list[deliveryMethod].text + } + if (deliveryMethod == 1) { + this.isshowed = true + this.isshow = false + } else { + this.isshowed = false + this.isshow = true + } + } } }) }, diff --git a/subPackages/product/product.vue b/subPackages/product/product.vue index 2e2e451..fcae8a8 100644 --- a/subPackages/product/product.vue +++ b/subPackages/product/product.vue @@ -413,6 +413,16 @@ export default { }, quantityChange(value) {}, confirmAddToCart() { + // 检查是否为处方药:is_otc === 0 && type == 2 + if (this.currentProduct.drug && this.currentProduct.drug.is_otc === 0 && this.currentProduct.drug.type == 2) { + uni.showToast({ + title: '处方药不能加入购物车,请通过提交预定购买', + icon: 'none', + duration: 2000 + }); + return; + } + saveCartApi({ store_id: uni.getStorageSync('store_id') || '11001', drug_id: this.currentProduct.drug.id, diff --git a/subPackages/product/symptoms.vue b/subPackages/product/symptoms.vue index 19abd9b..8d36659 100644 --- a/subPackages/product/symptoms.vue +++ b/subPackages/product/symptoms.vue @@ -484,6 +484,16 @@ export default { }) }, addToCart() { + // 检查是否为处方药:is_otc === 0 && type == 2 + if (this.productDetail.is_otc === 0 && this.productDetail.type == 2) { + uni.showToast({ + title: '处方药不能加入购物车,请通过提交预定购买', + icon: 'none', + duration: 2000 + }); + return; + } + saveCartApi({ store_id: uni.getStorageSync('store_id') || '11001', drug_id: this.productDetail.id,