This commit is contained in:
2026-04-08 16:11:18 +08:00
parent 078e0bc8ab
commit 124beb0666
4 changed files with 126 additions and 27 deletions

View File

@ -96,7 +96,7 @@
</view> -->
</view>
<view class="payBtn" @click.stop="writeOff">
核销
预约
</view>
</view>
</view>
@ -147,6 +147,12 @@ export default {
components: {
InfoCell,
},
props: {
orderId: {
type: [String, Number],
default: null
}
},
data() {
return {
imgPrefix,
@ -156,7 +162,7 @@ export default {
ORDER_TYPE_RESERVATION,
ORDER_TYPE_SITE,
orderType: ORDER_TYPE_RESERVATION,
selectedPetType: PET_TYPE_CAT, // 默认选中“猫”
selectedPetType: PET_TYPE_CAT, // 默认选中"猫"
petInfo: {}, // 兼容下游,取 selectedPets[0]
selectedPets: [], // 多选宠物列表
parkState: "",
@ -168,11 +174,24 @@ export default {
address: null,
catHtmlData: "",
dogHtmlData: "",
tip: ''
tip: '',
localOrderId: null, // 本地存储的 orderId
};
},
mounted() {
this.initData();
// 如果有传入的 orderId保存到本地
if (this.orderId) {
this.localOrderId = this.orderId;
}
},
watch: {
// 监听 orderId 变化
orderId(newVal) {
if (newVal) {
this.localOrderId = newVal;
}
}
},
computed: {
// 展示价格discount_price 数组相加的总和
@ -186,26 +205,87 @@ export default {
}
},
methods: {
// 用于接收从父页面传递的数据
onShowFun(orderId) {
if (orderId) {
this.localOrderId = orderId;
}
},
// 核销按钮点击处理
async writeOff () {
const data = {
goods_order_id:1, //抖音商品订单id整数
order_date:'2026-03-01', //预约日期2026-03-01格式
period_id:1, //预约时间段id整数
address_id:1, //地址id整数
recipient_name:'用户姓名', //用户姓名
phone:123, //用户手机
park_desc:123, //停车描述
note:'哈哈' // 备注
// 校验必填项
if (Object.keys(this.reservationTime).length === 0) {
uni.showToast({
title: "请选择预约时间",
icon: "none",
});
return;
}
if (!this.address) {
uni.showToast({
title: "请选择服务地址",
icon: "none",
});
return;
}
if (!this.parkState) {
uni.showToast({
title: "请选择停车状况",
icon: "none",
});
return;
}
if (!this.localOrderId) {
uni.showToast({
title: "订单ID缺失",
icon: "none",
});
return;
}
const data = {
goods_order_id: Number(this.localOrderId), //抖音商品订单id整数
order_date: this.reservationTime.date, //预约日期('2026-03-01'格式)
period_id: Number(this.reservationTime.id), //预约时间段id整数
address_id: Number(this.address.id), //地址id整数
recipient_name: this.address.name || '用户姓名', //用户姓名
phone: this.address.phone || '', //用户手机
park_desc: this.otherParkState || this.parkState || '', //停车描述
note: '' // 备注
};
uni.showLoading({
title: "处理中",
mask: true,
});
getdouyReview(data).then((res) => {
uni.hideLoading();
if (res.code == 0) {
uni.showToast({
title: "预约成功",
icon: "none",
});
}
});
// 预约成功后清空数据并跳转
setTimeout(() => {
uni.reLaunch({
url: "/pages/client/index/index?activePageId=homePage",
});
}, 1500);
} else {
uni.showToast({
title: res.msg || "预约失败",
icon: "none",
});
}
}).catch((err) => {
uni.hideLoading();
console.error("预约失败:", err);
uni.showToast({
title: "预约失败,请重试",
icon: "none",
});
});
},
getPetShortName(pet) {