|
|
@@ -4,7 +4,7 @@ import { handleWeChatPayment } from "../../../../utils/util";
|
|
|
import {
|
|
|
getTickleContext,
|
|
|
} from "../../../../core/behavior/tickle.behavior";
|
|
|
-import { getOrderDetailMethod, orderPayMethod } from "../../request";
|
|
|
+import { getOrderDetailMethod, orderPayMethod, applyAfterSaleMethod } from "../../request";
|
|
|
// module/order/pages/select-goods/other-detail.ts
|
|
|
Page({
|
|
|
behaviors: [PageContainerBehavior, DictionariesBehavior],
|
|
|
@@ -37,6 +37,29 @@ Page({
|
|
|
showDetail: false,
|
|
|
isPaymentLoading: false,
|
|
|
orderStatus: "", // 订单状态:pending, paid, closed, completed
|
|
|
+ // 售后半屏弹窗(组件 after-sale-type-popup)
|
|
|
+ afterSalePopupVisible: false,
|
|
|
+ refundReasonPopupVisible: false,
|
|
|
+ refundConfirmPopupVisible: false,
|
|
|
+ refundProofPopupVisible: false,
|
|
|
+ refundSubmitSuccessPopupVisible: false,
|
|
|
+ selectedAfterSaleType: "",
|
|
|
+ selectedRefundReason: "",
|
|
|
+ refundStatus: "",
|
|
|
+ refundMaxAmount: 0,
|
|
|
+ refundAmount: 0,
|
|
|
+ refundDesc: "",
|
|
|
+ refundProofImages: [] as string[],
|
|
|
+ afterSaleSiteOption: {
|
|
|
+ name: "",
|
|
|
+ price: 0,
|
|
|
+ meta1: "",
|
|
|
+ meta2: "",
|
|
|
+ image: "",
|
|
|
+ patientConditioningProgramId: "",
|
|
|
+ patientConditioningRecordId: "",
|
|
|
+ sellType: "",
|
|
|
+ },
|
|
|
},
|
|
|
onLoad(options: any) {
|
|
|
const remark = (this.data.orderDetail as any)?.remark || '';
|
|
|
@@ -77,6 +100,25 @@ Page({
|
|
|
break;
|
|
|
}
|
|
|
},
|
|
|
+ // 查看物流详情
|
|
|
+ goLogistics(e: any) {
|
|
|
+ const { id } = e.currentTarget.dataset.goods;
|
|
|
+ const { liaison, phone, provinceName, cityName, areaName, detailAddress } = this.data.orderDetail;
|
|
|
+ let address = `${provinceName}${cityName ? `${cityName}` : ""
|
|
|
+ }${areaName ? `${areaName}` : ""}${detailAddress ? `${detailAddress}` : ""
|
|
|
+ }`;
|
|
|
+ const goods = JSON.stringify({ ...e.currentTarget.dataset.goods, liaison, phone, address });
|
|
|
+ if (id) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/module/order/pages/logistics-detail/logistics-detail?id=${id}&goods=${goods}`,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: "无参数id",
|
|
|
+ icon: "none",
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
// 订单详情
|
|
|
async load(id: string) {
|
|
|
wx.showLoading({ title: "加载中" });
|
|
|
@@ -119,11 +161,11 @@ Page({
|
|
|
if (!items || !Array.isArray(items)) {
|
|
|
return [];
|
|
|
}
|
|
|
- return items.map((item: any) => {
|
|
|
+ return items.map((item: any, index: number) => {
|
|
|
// 0是一口价 1按穴位/经络次数计费
|
|
|
const pricingType = item?.conditioningProgramDetail?.pricingType;
|
|
|
return {
|
|
|
- id: item.id || '',
|
|
|
+ id: item.id || '', //患者调理方案id
|
|
|
patientConditioningRecordId: item?.patientConditioningRecordId || '',//调理记录id
|
|
|
name: item.conditioningProgramName || '',
|
|
|
description: (() => {
|
|
|
@@ -139,15 +181,21 @@ Page({
|
|
|
receiptType: item?.receiptType || '', //收货类型 0-快递 1-线下取货
|
|
|
expressType: item?.expressType || '', //快递类型 0-邮政速递 1-顺丰速运 2-京东快递 3-中通快递 4-圆通速递 5-申通快递 6-韵达快递 7-极兔速递
|
|
|
expressNo: item?.expressNo || '', //快递单号
|
|
|
- expressTypeName: this.getExpressTypeName(item?.expressType), //快递公司名称
|
|
|
- expressTypeIcon: this.getExpressTypeIcon(item?.expressType), //快递公司图标
|
|
|
+ expressTypeName: item?.expressType, //快递公司名称
|
|
|
+ // expressTypeIcon: this.getExpressTypeIcon(item?.expressType), //快递公司图标
|
|
|
//end实体商品所用到的字段
|
|
|
progress: item?.progress || '', //进度 0-进行中 1-已完成 2-未开始 3-已取消 这个字段用于线下服务商品以及线上权益商品的进度状态
|
|
|
image: item.conditioningProgramPhoto || '',
|
|
|
price: item?.unitPrice || 0,
|
|
|
+ totalPrice: item?.totalPrice || 0,
|
|
|
quantity: item?.totalMeasure || 0,
|
|
|
- statusClass: this.getStatusClass(item?.sellType, item?.progress, item?.receiptStatus),
|
|
|
- statusText: this.getGoodsStatusText(item?.sellType, item?.progress, item?.receiptStatus),
|
|
|
+ statusClass: this.getStatusClass(item?.sellType, item?.progress, item?.receiptStatus, item.expressStatus),
|
|
|
+ statusText: this.getGoodsStatusText(item?.sellType, item?.progress, item?.receiptStatus, item.expressStatus),
|
|
|
+ isCanEvaluate: item?.isCanEvaluate, //是否可以评价 false-否 true-是
|
|
|
+ evaluateTime: item?.evaluateTime, //有评价时间就是已评价,是空就是未评价
|
|
|
+ isShowAftersaleButton: item?.isShowAftersaleButton || false,
|
|
|
+ aftersaleProgressStr: item?.aftersaleProgressStr || '',
|
|
|
+ aftersaleProgress: item?.aftersaleProgress,
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
@@ -178,7 +226,7 @@ Page({
|
|
|
}
|
|
|
} catch (error: any) {
|
|
|
wx.showToast({
|
|
|
- title: error.errMsg,
|
|
|
+ title: error.errMsg || "获取订单详情失败",
|
|
|
icon: "none",
|
|
|
});
|
|
|
}
|
|
|
@@ -205,7 +253,7 @@ Page({
|
|
|
const payResult = await orderPayMethod(this.data.id, (this.data.orderDetail as any)?.remark);
|
|
|
if (payResult && payResult.data) {
|
|
|
const paymentParams = payResult.data;
|
|
|
- handleWeChatPayment(paymentParams, (res: any) => {
|
|
|
+ handleWeChatPayment(paymentParams, (_res: any) => {
|
|
|
// 支付成功,跳转到成功页面
|
|
|
wx.redirectTo({
|
|
|
url: "/module/article/pages/success-page/success-page?title=订单支付成功",
|
|
|
@@ -213,13 +261,9 @@ Page({
|
|
|
}, (error: any) => {
|
|
|
this.setData({ isPaymentLoading: false });
|
|
|
if (error?.errMsg === 'requestPayment:fail cancel') {
|
|
|
- // 支付取消跳到支付订单页面
|
|
|
+ // 支付取消跳到支付订单页面
|
|
|
wx.navigateBack({ delta: 1 });
|
|
|
}
|
|
|
- // wx.showToast({
|
|
|
- // title: error.errMsg,
|
|
|
- // icon: "none",
|
|
|
- // });
|
|
|
});
|
|
|
} else {
|
|
|
wx.showToast({
|
|
|
@@ -253,6 +297,158 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ preventTap() {
|
|
|
+ // 仅用于 catchtap 阻止冒泡,避免触发父级 goAppointment
|
|
|
+ },
|
|
|
+ onApplyAfterSale(e: any) {
|
|
|
+ const { goods } = e.currentTarget.dataset;
|
|
|
+ this.setData({
|
|
|
+ afterSaleSiteOption: {
|
|
|
+ image: goods.image || '',
|
|
|
+ name: goods.name,
|
|
|
+ price: goods.price,
|
|
|
+ totalPrice: goods.totalPrice,
|
|
|
+ meta1: goods.description || '',
|
|
|
+ meta2: `x${goods.quantity}`,
|
|
|
+ patientConditioningProgramId: goods.id || '',
|
|
|
+ patientConditioningRecordId: goods.patientConditioningRecordId || '',
|
|
|
+ sellType: goods.sellType || '',
|
|
|
+ },
|
|
|
+ refundMaxAmount: goods.totalPrice || 0,
|
|
|
+ refundAmount: goods.totalPrice || 0,
|
|
|
+ selectedAfterSaleType: "",
|
|
|
+ selectedRefundReason: "",
|
|
|
+ refundDesc: "",
|
|
|
+ refundProofImages: [],
|
|
|
+ afterSalePopupVisible: true,
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 点击退款状态,跳转到售后详情页
|
|
|
+ onAftersaleProgress(e: any) {
|
|
|
+ const { goods } = e.currentTarget.dataset;
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/module/order/pages/refund-processing/refund-processing?id=${goods.id}&recordId=${goods.patientConditioningRecordId || ''}`,
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ onAfterSalePopupClose() {
|
|
|
+ this.setData({ afterSalePopupVisible: false });
|
|
|
+ },
|
|
|
+
|
|
|
+ onAfterSaleNext(e: WechatMiniprogram.CustomEvent<{ selectedKey: string }>) {
|
|
|
+ const key = e.detail?.selectedKey;
|
|
|
+ if (!key) {
|
|
|
+ wx.showToast({ title: "请选择售后类型", icon: "none" });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ selectedAfterSaleType: key,
|
|
|
+ afterSalePopupVisible: false,
|
|
|
+ refundReasonPopupVisible: true,
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ onRefundReasonPopupClose() {
|
|
|
+ this.setData({ refundReasonPopupVisible: false });
|
|
|
+ },
|
|
|
+
|
|
|
+ onRefundReasonNext(e: WechatMiniprogram.CustomEvent<{ reason: string }>) {
|
|
|
+ const reason = e.detail?.reason;
|
|
|
+ if (!reason) {
|
|
|
+ wx.showToast({ title: "请选择退款原因", icon: "none" });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ selectedRefundReason: reason,
|
|
|
+ refundReasonPopupVisible: false,
|
|
|
+ refundConfirmPopupVisible: true,
|
|
|
+ refundAmount: this.data.refundMaxAmount,
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ onRefundConfirmClose() {
|
|
|
+ this.setData({ refundConfirmPopupVisible: false });
|
|
|
+ },
|
|
|
+
|
|
|
+ onChangeRefundStatus(e: WechatMiniprogram.CustomEvent<{ status: string }>) {
|
|
|
+ this.setData({ refundStatus: e.detail?.status || "" });
|
|
|
+ },
|
|
|
+
|
|
|
+ onOpenRefundReasonAgain() {
|
|
|
+ this.setData({ refundReasonPopupVisible: true });
|
|
|
+ },
|
|
|
+
|
|
|
+ onRefundAmountConfirm(e: WechatMiniprogram.CustomEvent<{ amount: number }>) {
|
|
|
+ const amount = Number(e.detail?.amount || 0);
|
|
|
+ this.setData({ refundAmount: amount });
|
|
|
+ },
|
|
|
+
|
|
|
+ onOpenRefundProofEditor() {
|
|
|
+ this.setData({ refundProofPopupVisible: true });
|
|
|
+ },
|
|
|
+
|
|
|
+ onRefundProofPopupClose() {
|
|
|
+ this.setData({ refundProofPopupVisible: false });
|
|
|
+ },
|
|
|
+
|
|
|
+ onRefundProofConfirm(e: WechatMiniprogram.CustomEvent<{ desc: string; images: string[] }>) {
|
|
|
+ this.setData({
|
|
|
+ refundDesc: e.detail?.desc || "",
|
|
|
+ refundProofImages: e.detail?.images || [],
|
|
|
+ refundProofPopupVisible: false,
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ async onSubmitRefundApply() {
|
|
|
+ if (!this.data.selectedRefundReason) {
|
|
|
+ wx.showToast({ title: "请选择退款原因", icon: "none" });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.data.refundProofImages.length && !this.data.refundDesc.trim()) {
|
|
|
+ wx.showToast({ title: "请上传凭证或填写描述", icon: "none" });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ wx.showLoading({ title: "提交中" });
|
|
|
+ const { afterSaleSiteOption, selectedAfterSaleType, refundStatus, selectedRefundReason, refundAmount, refundProofImages, refundDesc } = this.data;
|
|
|
+ const params = {
|
|
|
+ patientConditioningRecordId: (afterSaleSiteOption as any).patientConditioningRecordId,
|
|
|
+ patientConditioningProgramId: (afterSaleSiteOption as any).patientConditioningProgramId,
|
|
|
+ type: selectedAfterSaleType,
|
|
|
+ ...((afterSaleSiteOption as any).sellType === '1' ? { receiptStatus: refundStatus } : {}),
|
|
|
+ reason: selectedRefundReason,
|
|
|
+ applyAmount: refundAmount,
|
|
|
+ voucherImgs: refundProofImages,
|
|
|
+ remark: refundDesc,
|
|
|
+ };
|
|
|
+ console.log(params, "参数111")
|
|
|
+ try {
|
|
|
+ await applyAfterSaleMethod(params);
|
|
|
+ this.setData({ refundConfirmPopupVisible: false });
|
|
|
+ wx.navigateTo({
|
|
|
+ url: "/module/order/pages/refund-success/refund-success",
|
|
|
+ });
|
|
|
+ } catch (error: any) {
|
|
|
+ wx.showToast({ title: error.errMsg || "提交失败", icon: "none" });
|
|
|
+ }
|
|
|
+ wx.hideLoading();
|
|
|
+ },
|
|
|
+ onReview(e: WechatMiniprogram.TouchEvent) {
|
|
|
+ console.log(e.currentTarget.dataset);
|
|
|
+ const { evaluateTime } = e.currentTarget.dataset.goods;
|
|
|
+ if (evaluateTime) {
|
|
|
+ // 单商品评价详情
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/module/order/pages/goods-evaluateDetail/goods-evaluateDetail?goodsInfo=${encodeURIComponent(JSON.stringify(e.currentTarget.dataset.goods))}`,
|
|
|
+ });
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 去单商品评价页面
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/module/order/pages/goods-evaluate/goods-evaluate?goodsInfo=${encodeURIComponent(JSON.stringify(e.currentTarget.dataset.goods))}`,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
// 复制订单号
|
|
|
copyOrderNo(e: any) {
|
|
|
const orderNo = e.currentTarget.dataset.orderno;
|
|
|
@@ -275,9 +471,9 @@ Page({
|
|
|
// sellType: 商品类型 1-实体商品 2-线下服务 3-线上权益
|
|
|
// progress: 进度状态(用于线下服务和线上权益):0-进行中 1-已完成 2-未开始
|
|
|
// receiptStatus: 收货状态(用于实体商品):0-待发货 1-已发货 2-已收货
|
|
|
- getStatusClass(sellType?: string | number, progress?: string | number, receiptStatus?: string | number): string {
|
|
|
+ getStatusClass(sellType?: string | number, progress?: string | number, receiptStatus?: string | number, expressStatus?: string): string {
|
|
|
const type = String(sellType || '');
|
|
|
- // 实体商品 (sellType === 1) 使用 receiptStatus(三种状态)
|
|
|
+ // 实体商品 (sellType === 1) 使用 receiptStatus(三种状态)实体商品增加运输中
|
|
|
if (type === "1") {
|
|
|
const status = String(receiptStatus || '');
|
|
|
if (status === "0") {
|
|
|
@@ -286,6 +482,8 @@ Page({
|
|
|
return "status-received"; // 已发货
|
|
|
} else if (status === "2") {
|
|
|
return "status-completed"; // 已收货
|
|
|
+ } else {
|
|
|
+ return "status-received"
|
|
|
}
|
|
|
}
|
|
|
// 线下服务 (sellType === 2) 和线上权益 (sellType === 3) 使用 progress(三种状态)
|
|
|
@@ -303,17 +501,21 @@ Page({
|
|
|
},
|
|
|
|
|
|
// 获取商品状态文本
|
|
|
- getGoodsStatusText(sellType?: string | number, progress?: string | number, receiptStatus?: string | number): string {
|
|
|
+ getGoodsStatusText(sellType?: string | number, progress?: string | number, receiptStatus?: string | number, expressStatus?: string): string {
|
|
|
const type = String(sellType || '');
|
|
|
- // 实体商品 (sellType === 1) 使用 receiptStatus(三种状态)
|
|
|
+ // 实体商品 (sellType === 1) 使用 receiptStatus(三种状态)新增expressStatus运输状态
|
|
|
if (type === "1") {
|
|
|
const status = String(receiptStatus || '');
|
|
|
- if (status === "0") {
|
|
|
- return "待发货";
|
|
|
- } else if (status === "1") {
|
|
|
- return "已发货";
|
|
|
- } else if (status === "2") {
|
|
|
- return "已收货";
|
|
|
+ if (expressStatus) {
|
|
|
+ return expressStatus
|
|
|
+ } else {
|
|
|
+ if (status === "0") {
|
|
|
+ return "待发货";
|
|
|
+ } else if (status === "1") {
|
|
|
+ return "已发货";
|
|
|
+ } else if (status === "2") {
|
|
|
+ return "已收货";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// 线下服务 (sellType === 2) 和线上权益 (sellType === 3) 使用 progress(三种状态)
|
|
|
@@ -329,37 +531,6 @@ Page({
|
|
|
}
|
|
|
return "";
|
|
|
},
|
|
|
-
|
|
|
- // 获取快递公司名称
|
|
|
- getExpressTypeName(expressType?: string | number): string {
|
|
|
- const expressTypeMap: Record<string, string> = {
|
|
|
- "0": "邮政速递",
|
|
|
- "1": "顺丰速运",
|
|
|
- "2": "京东快递",
|
|
|
- "3": "中通快递",
|
|
|
- "4": "圆通速递",
|
|
|
- "5": "申通快递",
|
|
|
- "6": "韵达快递",
|
|
|
- "7": "极兔速递",
|
|
|
- };
|
|
|
- return expressTypeMap[String(expressType || '')] || "";
|
|
|
- },
|
|
|
-
|
|
|
- // 获取快递公司图标
|
|
|
- getExpressTypeIcon(expressType?: string | number): string {
|
|
|
- const expressIconMap: Record<string, string> = {
|
|
|
- "0": "icon-youzhengkuaidi", // 邮政速递
|
|
|
- "1": "icon-shunfengkuaidi", // 顺丰速运
|
|
|
- "2": "icon-jingdong", // 京东快递
|
|
|
- "3": "icon-zhongtong", // 中通快递
|
|
|
- "4": "icon-yuantongkuaidi", // 圆通速递
|
|
|
- "5": "icon-shentong", // 申通快递
|
|
|
- "6": "icon-yunda", // 韵达快递
|
|
|
- "7": "icon-jitukuaidi", // 极兔速递
|
|
|
- };
|
|
|
- return expressIconMap[String(expressType || '')] || "";
|
|
|
- },
|
|
|
-
|
|
|
// 获取订单状态文本
|
|
|
getStatusText(status: string | number): string {
|
|
|
const statusTextMap: Record<string, string> = {
|