feat: 下单校验

This commit is contained in:
2026-03-26 16:01:30 +08:00
parent 1e01028ba8
commit d7d50e1210
2 changed files with 19 additions and 20 deletions

View File

@@ -20,19 +20,20 @@
<!-- 联系方式 --> <!-- 联系方式 -->
<view class="bg-white rounded-12 overflow-hidden"> <view class="bg-white rounded-12 overflow-hidden">
<view <view class="border-box border-bottom font-size-16 font-500 color-000 line-height-24 p-12">联系方式</view>
class="border-box border-bottom font-size-16 font-500 color-000 line-height-24 p-12"
>联系方式</view
>
<view class="flex flex-items-center border-box p-12"> <view class="flex flex-items-center border-box p-12">
<view class="font-size-14 font-500 color-525866 mr-12"> 联系手机 </view> <view class="font-size-14 font-500 color-525866 mr-12"> 联系人姓名 </view>
<view class="right"> <view class="right">
<input <input class="border-box px-4 py-2 font-size-15 color-000 line-height-20"
class="border-box px-4 py-2 font-size-15 color-000 line-height-20" v-model.trim="userFormList[0].visitorName" placeholder="请输入联系人" maxlength="20" />
v-model.trim="userFormList[0].contactPhone" </view>
placeholder="请输入联系手机" </view>
maxlength="11"
/> <view class="flex flex-items-center border-box p-12">
<view class="font-size-14 font-500 color-525866 mr-12"> 手机号码 </view>
<view class="right">
<input class="border-box px-4 py-2 font-size-15 color-000 line-height-20"
v-model.trim="userFormList[0].contactPhone" placeholder="请输入联系手机" maxlength="11" />
</view> </view>
</view> </view>
</view> </view>
@@ -50,7 +51,7 @@ const props = defineProps({
}, },
userFormList: { userFormList: {
type: Array, type: Array,
default: () => [{ contactPhone: "" }], default: () => [{ visitorName: "", contactPhone: "" }],
}, },
reservationDate: { reservationDate: {
type: String, type: String,

View File

@@ -197,7 +197,7 @@ const validateUserForms = () => {
}); });
if (invalidUsers.length) { if (invalidUsers.length) {
uni.showToast({ title: "请填写住客姓名", icon: "none" }); uni.showToast({ title: "请填写姓名", icon: "none" });
return false; return false;
} }
@@ -211,14 +211,12 @@ const handlePayClick = ThrottleUtils.createThrottle(async (goodsData) => {
try { try {
console.log("处理支付点击事件", userFormList.value); console.log("处理支付点击事件", userFormList.value);
// 判断是酒店类型 // 校验用户姓名
if (goodsData.commodityTypeCode === "0") { if (!validateUserForms()) {
// 校验用户姓名 uni.hideLoading();
if (!validateUserForms()) { return;
uni.hideLoading();
return;
}
} }
// 校验手机号 // 校验手机号
if (!PhoneUtils.validatePhone(userFormList.value[0].contactPhone)) { if (!PhoneUtils.validatePhone(userFormList.value[0].contactPhone)) {
uni.hideLoading(); uni.hideLoading();