From eed2eea123a0ffea7889d1c5e33984076a1f8f21 Mon Sep 17 00:00:00 2001 From: duanshuwen Date: Tue, 28 Oct 2025 20:34:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A2=E5=8D=95=E6=94=AF=E4=BB=98|?= =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/RefundPopup/index.vue | 28 ++- src/manifest.json | 6 +- .../components/ConactSection/index.vue | 2 +- .../components/UserSection/index.vue | 4 +- src/pages-booking/index.vue | 111 ++++++++++- src/pages/goods/index.vue | 174 +++--------------- src/pages/goods/styles/index.scss | 49 ++--- src/static/scss/border.scss | 4 + 8 files changed, 175 insertions(+), 203 deletions(-) diff --git a/src/components/RefundPopup/index.vue b/src/components/RefundPopup/index.vue index ebea121..3e589ff 100644 --- a/src/components/RefundPopup/index.vue +++ b/src/components/RefundPopup/index.vue @@ -28,11 +28,16 @@ {{ zniconsMap["zn-refund"] }} - 退订规则 + + {{ refundTitle }} + - - - ·不予退款:12小时以内取消或未入住,不予退款。 + + {{ item }} @@ -64,9 +69,22 @@ const emit = defineEmits(["update:modelValue"]); const popupRef = ref(null); // 获取退款模板 +const refundTitle = computed(() => { + if (props.orderData.commodityPurchaseInstruction) { + return ( + props.orderData.commodityPurchaseInstruction.refundTitle || "退订规则" + ); + } + + return "退订规则"; +}); + const commodityPurchaseInstruction = computed(() => { if (props.orderData.commodityPurchaseInstruction) { - return props.orderData.commodityPurchaseInstruction; + // 以换行符为分隔符,将字符串转换为数组 + return props.orderData.commodityPurchaseInstruction.refundContent.split( + "\n" + ); } return {}; diff --git a/src/manifest.json b/src/manifest.json index 424edf2..4a7d719 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -62,7 +62,11 @@ "mp-weixin": { "appid": "wx5e79df5996572539", "setting": { - "urlCheck": false + "urlCheck": false, + "minified": true + }, + "optimization": { + "subPackages": true }, "usingComponents": true, "requiredPrivateInfos": ["getLocation"], diff --git a/src/pages-booking/components/ConactSection/index.vue b/src/pages-booking/components/ConactSection/index.vue index ed73936..37a8056 100644 --- a/src/pages-booking/components/ConactSection/index.vue +++ b/src/pages-booking/components/ConactSection/index.vue @@ -27,7 +27,7 @@ diff --git a/src/pages-booking/components/UserSection/index.vue b/src/pages-booking/components/UserSection/index.vue index 56a7fe6..8bbab9a 100644 --- a/src/pages-booking/components/UserSection/index.vue +++ b/src/pages-booking/components/UserSection/index.vue @@ -19,7 +19,7 @@ @@ -31,7 +31,7 @@ diff --git a/src/pages-booking/index.vue b/src/pages-booking/index.vue index 70a1b00..acc8c25 100644 --- a/src/pages-booking/index.vue +++ b/src/pages-booking/index.vue @@ -102,10 +102,10 @@ import UserSection from "./components/UserSection/index.vue"; import RefundPopup from "@/components/RefundPopup/index.vue"; import DetailPopup from "@/components/DetailPopup/index.vue"; import FooterSection from "./components/FooterSection/index.vue"; -import { goodsDetail } from "@/request/api/GoodsApi"; +import { goodsDetail, orderPay } from "@/request/api/GoodsApi"; import { useSelectedDateStore } from "@/store"; import { GOODS_TYPE } from "@/constant/type"; -import { PhoneUtils } from "@/utils"; +import { ThrottleUtils, PhoneUtils } from "@/utils"; const refundVisible = ref(false); const detailVisible = ref(false); @@ -190,18 +190,113 @@ const navigateToDetail = ({ commodityId }) => { }); }; +// 验证用户姓名 +const validateUserForms = () => { + const invalidUsers = userFormList.value.filter((user) => { + return user.visitorName.trim() === ""; + }); + + if (invalidUsers.length) { + uni.showToast({ title: "请填写住客姓名", icon: "none" }); + return false; + } + + return true; +}; + // 处理支付点击事件 -const handlePayClick = (orderData) => { +const handlePayClick = ThrottleUtils.createThrottle(async (goodsData) => { console.log("处理支付点击事件", userFormList.value); + // 判断是酒店类型 + if (goodsData.commodityTypeCode === "0") { + // 校验用户姓名 + if (!validateUserForms()) { + return; + } + } // 校验手机号 if (!PhoneUtils.validatePhone(userFormList.value[0].contactPhone)) { - uni.showToast({ - title: "请输入正确的手机号", - icon: "none", - }); + uni.showToast({ title: "请输入正确的手机号", icon: "none" }); return; } -}; + + // 购买的商品id + const commodityId = goodsData.commodityId; + // 消费者信息 + const consumerInfoEntityList = userFormList.value; + // 购买数量 + const purchaseAmount = consumerInfoEntityList.length; + // 支付方式 0-微信 1-支付宝 2-云闪付 + const payWay = "0"; + // 支付渠道 0-app 1-小程序 2-h5 + const paySource = "1"; + + const params = { + commodityId, + purchaseAmount, + payWay, + paySource, + consumerInfoEntityList, + }; + + //酒店类型添加入住时间、离店时间 + if (goodsData.commodityTypeCode === "0" && selectedDate.value) { + const { startDate, endDate } = selectedDate.value; + // 入住时间 + params.checkInData = startDate; + // 离店时间 + params.checkOutData = endDate; + } + + const res = await orderPay(params); + console.log("确认订单---2:", res); + + // 检查接口返回数据 + if (!res || !res.data) { + uni.showToast({ title: "订单创建失败,请重试", icon: "none" }); + return; + } + + const { data } = res; + const { nonceStr, packageVal, paySign, signType, timeStamp } = data; + + // 验证支付参数是否完整 + if (!nonceStr || !packageVal || !paySign || !signType || !timeStamp) { + // console.error("支付参数不完整:", { + // nonceStr: !!nonceStr, + // packageVal: !!packageVal, + // paySign: !!paySign, + // signType: !!signType, + // timeStamp: !!timeStamp, + // }); + uni.showToast({ title: "支付参数错误,请重试", icon: "none" }); + return; + } + + // 调用微信支付 + uni.requestPayment({ + provider: "wxpay", + timeStamp: String(timeStamp), // 确保为字符串类型 + nonceStr: String(nonceStr), + package: String(packageVal), // 确保为字符串类型 + signType: String(signType), + paySign: String(paySign), + success: () => { + uni.showToast({ + title: "支付成功", + icon: "success", + success: () => { + uni.navigateTo({ + url: "/pages-order/order/list", + }); + }, + }); + }, + fail: () => { + uni.showToast({ title: "支付失败,请重试", icon: "none" }); + }, + }); +}, 1000);