diff --git a/src/locale/en.json b/src/locale/en.json index b3d9679..f29d702 100644 --- a/src/locale/en.json +++ b/src/locale/en.json @@ -629,7 +629,8 @@ "enter-verification-code": "Please enter the verification code" }, "set-payment-password-successfully": "Setting the payment password successfully", - "two-passwords-inconsistent": "The password is inconsistent when entered twice" + "two-passwords-inconsistent": "The password is inconsistent when entered twice", + "password-length-limit": "Password must be 8-16 characters long" }, "recharge": { "amount": "Recharge amount", diff --git a/src/locale/zh-Hans.json b/src/locale/zh-Hans.json index ce58485..a2f47fc 100644 --- a/src/locale/zh-Hans.json +++ b/src/locale/zh-Hans.json @@ -629,7 +629,8 @@ "enter-verification-code": "请输入验证码" }, "set-payment-password-successfully": "设置支付密码成功", - "two-passwords-inconsistent": "两次输入的密码不一致" + "two-passwords-inconsistent": "两次输入的密码不一致", + "password-length-limit": "密码长度必须为8-16位" }, "recharge": { "amount": "充值金额", diff --git a/src/manifest.json b/src/manifest.json index bf3b0fd..500cd0a 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,8 +2,8 @@ "name" : "CHEFLINK delivery", "appid" : "__UNI__06509BE", "description" : "", - "versionName" : "1.0.13", - "versionCode" : 113, + "versionName" : "1.0.21", + "versionCode" : 121, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/src/pages-store/pages/dishes/index.vue b/src/pages-store/pages/dishes/index.vue index 20ccf60..6edb327 100644 --- a/src/pages-store/pages/dishes/index.vue +++ b/src/pages-store/pages/dishes/index.vue @@ -29,7 +29,7 @@ onLoad(()=> { }) function handleClickDish(item: any) { - navigateTo(`/pages-store/pages/store/dishes?id=${item.id}&storeId=${item.merchantId}`) + navigateTo(`/pages-store/pages/store/index?id=${item.merchantId}`) } function navigateTo(url: string) { diff --git a/src/pages-store/pages/order/checkout.vue b/src/pages-store/pages/order/checkout.vue index 5b1bc74..8ac1bc4 100644 --- a/src/pages-store/pages/order/checkout.vue +++ b/src/pages-store/pages/order/checkout.vue @@ -58,7 +58,8 @@ function confirmPhone(data: { phone: string; areaCode: string }) { } // 配送时间 1 即刻配送 2 预约配送 -const deliveryTimeType = ref(1); +// 当前业务仅支持预约配送,默认值设置为 2 +const deliveryTimeType = ref(2); // 配送时间配置 const deliveryMinutes = ref(0); // 预计送达时间(分钟) // 自取时间配置 @@ -92,21 +93,22 @@ const showDeliveryTime = computed(() => { } return ""; }); -// 切换配送时间点击事件 +// 切换配送时间点击事件(目前仅支持预约配送) function toggleDeliveryTimeType(type: number) { - if (type === 2) { - if (userSelectedDeliveryTimeDate.value) { - deliveryTimeType.value = type; - } - // 跳转到时间选择页面 - console.log(storeDetail.value.merch); - - uni.navigateTo({ - url: "/pages/address/reservation-time?storeBusinessHours=" + storeDetail.value.businessHours, - }); - } else { - deliveryTimeType.value = type; - } + // 统一设置为预约配送 + deliveryTimeType.value = 2; + + // 跳转到时间选择页面 + const businessHours = (storeDetail.value as any)?.businessHours; + const url = businessHours + ? `/pages/address/reservation-time?storeBusinessHours=${encodeURIComponent( + businessHours + )}` + : "/pages/address/reservation-time"; + + uni.navigateTo({ + url, + }); } const diyTime = ref({}) @@ -118,9 +120,13 @@ useEventEmit(EventEnum.CHOOSE_APPOINTMENT_TIME, (data) => { // 配送还是自取 if(deliveryMethod.value === 0) { - userSelectedDeliveryTimeDate.value = dayjs(data.date).format('MM-DD') + ' ' + data.timeSlot; + userSelectedDeliveryTimeDate.value = + dayjs(data.date).format('MM-DD') + + (data.timeSlot ? ' ' + data.timeSlot : ''); } else { - userSelectedSelfPickupTimeDate.value = dayjs(data.date).format('MM-DD') + ' ' + data.timeSlot; + userSelectedSelfPickupTimeDate.value = + dayjs(data.date).format('MM-DD') + + (data.timeSlot ? ' ' + data.timeSlot : ''); } } }) @@ -161,8 +167,8 @@ function handleClickSegmented(index: number) { if(index !== deliveryMethod.value) { deliveryMethod.value = index - // 重置配送类型 - deliveryTimeType.value = 1 + // 重置配送类型为预约配送 + deliveryTimeType.value = 2 appMerchantOrderCalculatePriceCart() } } @@ -170,33 +176,70 @@ function handleClickSegmented(index: number) { // 折叠面板 const collapseValue = ref([""]); -// 当前选中的小费 -const selectedTipIndex = ref(5); +// 单个订单的小费 +const selectedTipIndex = ref(0); const diyTipValue = ref('') +// 批量订单:每个店铺的小费索引映射 merchantId -> tipIndex +const merchantTipIndexMap = ref>({}) +// 批量订单:每个店铺的自定义小费值映射 merchantId -> diyTipValue +const merchantDiyTipValueMap = ref>({}) + const tipOptions = ref([ { - label: "5%", + label: "$3", + value: 3, + }, + { + label: "$5", value: 5, }, { - label: "10%", + label: "$10", value: 10, }, - { - label: "15%", - value: 15, - }, ]); + +// 单个订单的小费选择 function selectedTipChange(item: any) { if(item.value === selectedTipIndex.value) return diyTipValue.value = '' selectedTipIndex.value = item.value appMerchantOrderCalculatePriceCart() } + +// 批量订单:选择某个店铺的小费 +function selectedTipChangeForMerchant(merchantId: string, item: any) { + if(item.value === merchantTipIndexMap.value[merchantId]) return + merchantDiyTipValueMap.value[merchantId] = '' + merchantTipIndexMap.value[merchantId] = item.value + appMerchantOrderCalculatePriceCart() +} + +// 单个订单的自定义小费确认(金额,单位:美元) function handleConfirmTip() { - if(diyTipValue.value) { - appMerchantOrderCalculatePriceCart() + // 如果未填写其他小费金额,失去焦点时默认填充为 0 + const val = String(diyTipValue.value || '').trim() + if (!val) { + diyTipValue.value = '0' } + // 使用自定义小费时,选中"其他"这一项 + if (selectedTipIndex.value !== 0) { + selectedTipIndex.value = 0 + } + appMerchantOrderCalculatePriceCart() +} + +// 批量订单:确认某个店铺的自定义小费(金额,单位:美元) +function handleConfirmTipForMerchant(merchantId: string) { + const val = String(merchantDiyTipValueMap.value[merchantId] || '').trim() + if (!val) { + merchantDiyTipValueMap.value[merchantId] = '0' + } + // 使用自定义小费时,选中"其他"这一项 + if (merchantTipIndexMap.value[merchantId] !== 0) { + merchantTipIndexMap.value[merchantId] = 0 + } + appMerchantOrderCalculatePriceCart() } // 是否选择了配送周卡 @@ -486,13 +529,44 @@ function appMerchantOrderCalculatePriceCart() { // 批量模式使用批量计算价格接口 if(orderType.value == 'batch') { + // 构建 merchantCouponMap: { merchantId: couponId } + const couponMap: Record = {} + Object.keys(merchantCouponMap.value).forEach(merchantId => { + if(merchantCouponMap.value[merchantId]?.id) { + couponMap[merchantId] = merchantCouponMap.value[merchantId].id + } + }) + + // 构建 merchantTipMap: { merchantId: tipAmount } (小费金额,单位:美元) + const tipMap: Record = {} + cartDataList.value.forEach((merchant: any) => { + const merchantId = String(merchant.id) + if(deliveryMethod.value === 1) { + // 自取订单不需要小费 + tipMap[merchantId] = 0 + } else { + // 配送订单需要小费 + const diyTip = merchantDiyTipValueMap.value[merchantId] + const tipIndex = merchantTipIndexMap.value[merchantId] || 0 + if(diyTip) { + // 自定义小费金额(美元) + tipMap[merchantId] = Number(diyTip) || 0 + } else if(tipIndex > 0) { + // 选择固定金额选项 + tipMap[merchantId] = tipIndex + } else { + tipMap[merchantId] = 0 + } + } + }) + appMerchantOrderCalculatePriceCartBatchPost({ body: { addressId: targetAddressId, cartIds: cartIds, receiveMethod: deliveryMethod.value === 0 ? 1 : 2, - couponId: couponInfo.value ? couponInfo.value.id : '', - tipDiscount: deliveryMethod.value === 1 ? 0 : (diyTipValue.value ? Number(diyTipValue.value) / 100 : (selectedTipIndex.value || 0) / 100), // 小费比例,自取订单不需要小费 + merchantCouponMap: couponMap, + merchantTipMap: tipMap, // 小费金额(美元) phone: formData.value.phone, areaCode: contact.value.areaCode, } @@ -502,13 +576,24 @@ function appMerchantOrderCalculatePriceCart() { }) } else { // 普通模式使用单店铺计算价格接口 + // 计算小费金额(美元) + let tipAmount = 0 + if(deliveryMethod.value === 0) { + // 配送订单需要小费 + if(diyTipValue.value) { + tipAmount = Number(diyTipValue.value) || 0 + } else if(selectedTipIndex.value > 0) { + tipAmount = selectedTipIndex.value + } + } + appMerchantOrderCalculatePriceCartPost({ body: { addressId: targetAddressId, cartIds: cartIds, receiveMethod: deliveryMethod.value === 0 ? 1 : 2, couponId: couponInfo.value ? couponInfo.value.id : '', - tipDiscount: deliveryMethod.value === 1 ? 0 : (diyTipValue.value ? Number(diyTipValue.value) / 100 : (selectedTipIndex.value || 0) / 100), // 小费比例,自取订单不需要小费 + tipDiscount: tipAmount, // 小费金额(美元),自取订单不需要小费 // weeklyDeliveryFee: isWeeklyDelivery.value ? 1 : 2, // 是否支付周配送费(1-是 2-否) phone: formData.value.phone, areaCode: contact.value.areaCode, @@ -633,23 +718,63 @@ function handleGoSettle() { }) return } + + // 仅支持预约配送:必须先选择预约时间 + if (deliveryTimeType.value === 2 && (!diyTime.value.startTime || !diyTime.value.endTime)) { + uni.showToast({ + title: t('pages-store.checkout.chooseTime'), + icon: 'none' + }) + return + } // 批量下单 if(orderType.value == 'batch') { if(resOrderIds.value.length === 0) { + // 构建 merchantCouponMap: { merchantId: couponId } + const couponMap: Record = {} + Object.keys(merchantCouponMap.value).forEach(merchantId => { + if(merchantCouponMap.value[merchantId]?.id) { + couponMap[merchantId] = merchantCouponMap.value[merchantId].id + } + }) + + // 构建 merchantTipMap: { merchantId: tipAmount } (小费金额,单位:美元) + const tipMap: Record = {} + cartDataList.value.forEach((merchant: any) => { + const merchantId = String(merchant.id) + if(deliveryMethod.value === 1) { + // 自取订单不需要小费 + tipMap[merchantId] = 0 + } else { + // 配送订单需要小费 + const diyTip = merchantDiyTipValueMap.value[merchantId] + const tipIndex = merchantTipIndexMap.value[merchantId] || 0 + if(diyTip) { + // 自定义小费金额(美元) + tipMap[merchantId] = Number(diyTip) || 0 + } else if(tipIndex > 0) { + // 选择固定金额选项 + tipMap[merchantId] = tipIndex + } else { + tipMap[merchantId] = 0 + } + } + }) + let data = { addressId: targetAddressId, phone: formData.value.phone, areaCode: contact.value.areaCode, cartIds: batchCartIds.value, - couponId: couponInfo.value ? couponInfo.value.id : '', + merchantCouponMap: couponMap, + merchantTipMap: tipMap, deliveryMethod: visitMethod.value.label, // 派送方式(如放门口或者交到顾客手中) deliveryType: deliveryTimeType.value, // 1-立即交付 2-预约交付 orderRemark: formData.value.orderRemark, receiveMethod: deliveryMethod.value === 0 ? 1 : 2, // 收货方式(1-派送 2-自取) startScheduledTime: '', // endScheduledTime: '', // - tipDiscount: deliveryMethod.value === 1 ? 0 : (diyTipValue.value ? Number(diyTipValue.value) / 100 : (selectedTipIndex.value || 0) / 100), // 小费比例,自取订单不需要小费 needTableware: needTableware.value ? 1 : 2, // 餐具 1是 2否 } @@ -686,6 +811,17 @@ function handleGoSettle() { } else { // 普通下单 if(!resOrderId.value) { + // 计算小费金额(美元) + let tipAmount = 0 + if(deliveryMethod.value === 0) { + // 配送订单需要小费 + if(diyTipValue.value) { + tipAmount = Number(diyTipValue.value) || 0 + } else if(selectedTipIndex.value > 0) { + tipAmount = selectedTipIndex.value + } + } + let data = { addressId: targetAddressId, phone: formData.value.phone, @@ -698,7 +834,7 @@ function handleGoSettle() { receiveMethod: deliveryMethod.value === 0 ? 1 : 2, // 收货方式(1-派送 2-自取) startScheduledTime: '', // endScheduledTime: '', // - tipDiscount: deliveryMethod.value === 1 ? 0 : (diyTipValue.value ? Number(diyTipValue.value) / 100 : (selectedTipIndex.value || 0) / 100), // 小费比例,自取订单不需要小费 + tipDiscount: tipAmount, // 小费金额(美元),自取订单不需要小费 // weeklyDeliveryFee: isWeeklyDelivery.value ? 1 : 2, // 是否支付周配送费(1-是 2-否) needTableware: needTableware.value ? 1 : 2, // 餐具 1是 2否 } @@ -899,16 +1035,31 @@ export interface CreateOrderCartBo { [property: string]: any; } +// 单个订单的优惠券信息 const couponInfo = ref(null) -function navigateToCoupon() { +// 批量订单:每个店铺的优惠券映射 merchantId -> couponInfo +const merchantCouponMap = ref>({}) +// 批量订单:每个店铺的小费映射 merchantId -> tipAmount (小费金额,单位:美元) +const merchantTipMap = ref>({}) +// 批量订单:每个店铺的小费比例映射 merchantId -> tipPercent (小费比例,0-100) +const merchantTipPercentMap = ref>({}) + +function navigateToCoupon(merchantId?: string) { + const targetMerchantId = merchantId || storeId.value uni.navigateTo({ - url: '/pages-user/pages/coupon/list?id=' + storeId.value, + url: '/pages-user/pages/coupon/list?id=' + targetMerchantId, events: { // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据 selectedCoupon: function(data) { console.log(data) if(data) { - couponInfo.value = data + if(orderType.value === 'batch' && merchantId) { + // 批量模式:存储到对应店铺的优惠券映射 + merchantCouponMap.value[merchantId] = data + } else { + // 单个订单模式 + couponInfo.value = data + } // 重新计算价格 appMerchantOrderCalculatePriceCart() } @@ -916,8 +1067,14 @@ function navigateToCoupon() { }, }) } -function handleClose() { - couponInfo.value = null +function handleClose(merchantId?: string) { + if(orderType.value === 'batch' && merchantId) { + // 批量模式:清除对应店铺的优惠券 + delete merchantCouponMap.value[merchantId] + } else { + // 单个订单模式 + couponInfo.value = null + } // 重新计算价格 appMerchantOrderCalculatePriceCart() } @@ -1111,25 +1268,13 @@ function handleClose() { - -