diff --git a/env/.env.development b/env/.env.development index 8285797..a18b03b 100644 --- a/env/.env.development +++ b/env/.env.development @@ -5,6 +5,6 @@ VITE_DELETE_CONSOLE=false #本地环境 VITE_SERVER_BASEURL=https://howhowfresh.com/prod-api -#VITE_SERVER_BASEURL=http://192.168.5.64:8080 +#VITE_SERVER_BASEURL=http://192.168.5.36:8080 #VITE_SERVER_BASEURL=http://192.168.0.148:8888 #VITE_SERVER_BASEURL=http://liuyao.nat100.top/meiguowaimai \ No newline at end of file diff --git a/src/components/navbar/navbar.vue b/src/components/navbar/navbar.vue index 5c19174..585fc6b 100644 --- a/src/components/navbar/navbar.vue +++ b/src/components/navbar/navbar.vue @@ -10,6 +10,12 @@ const props = withDefaults(defineProps<{ }); function handleClickLeft() { + // 页面栈不足时,navigateBack 会失败;兜底回首页 + const pages = getCurrentPages?.() || [] + if (pages.length <= 1) { + uni.switchTab({ url: '/pages/home/index' }) + return + } uni.navigateBack() } diff --git a/src/components/visit-method/index.vue b/src/components/visit-method/index.vue index f1631e5..dcab1ec 100644 --- a/src/components/visit-method/index.vue +++ b/src/components/visit-method/index.vue @@ -4,8 +4,8 @@ const show = ref(false); const pickerValue = ref(0) const emits = defineEmits(['confirm']) -function onOpen(value: number) { - if (value) { +function onOpen(value?: number) { + if (value !== undefined && value !== null) { pickerValue.value = value; } show.value = true; diff --git a/src/locale/en.json b/src/locale/en.json index f29d702..01d1e61 100644 --- a/src/locale/en.json +++ b/src/locale/en.json @@ -34,6 +34,8 @@ "loading": "Loading", "mile": "mile", "minutes": "minutes", + "day": "day", + "days": "days", "no": "No", "obtain": "get", "operation-success": "Operation successful", @@ -439,6 +441,7 @@ "claimCoupon": "Claim coupon", "couponOff": "Off", "validDays": "Valid Days", + "day": "day", "days": "days", "get": "Get", "congratulations": "Congratulations", @@ -493,6 +496,7 @@ "tips3": "membership to enjoy a ", "tips4": "Enjoy delivery service over", "tips5": "Delivery fee", + "start": " and up", "title": "The minimum order amount for this store is", "toast": { "deliveryService": "This merchant does not provide delivery service", diff --git a/src/locale/zh-Hans.json b/src/locale/zh-Hans.json index a2f47fc..6e94c50 100644 --- a/src/locale/zh-Hans.json +++ b/src/locale/zh-Hans.json @@ -34,6 +34,8 @@ "loading": "加载中", "mile": "英里", "minutes": "分钟", + "day": "天", + "days": "天", "no": "否", "obtain": "获取", "operation-success": "操作成功", @@ -439,6 +441,7 @@ "claimCoupon": "领取优惠券", "couponOff": "优惠", "validDays": "有效天数", + "day": "天", "days": "天", "get": "获取", "congratulations": "恭喜!", @@ -493,6 +496,7 @@ "tips3": "会员可享受", "tips4": "最低起送金额", "tips5": "配送费", + "start": "起", "title": "这家店的起送金额是", "toast": { "deliveryService": "该商家未开通配送服务", diff --git a/src/manifest.json b/src/manifest.json index 500cd0a..4dec964 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,8 +2,8 @@ "name" : "CHEFLINK delivery", "appid" : "__UNI__06509BE", "description" : "", - "versionName" : "1.0.21", - "versionCode" : 121, + "versionName" : "1.0.26", + "versionCode" : 126, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/src/pages-store/pages/order/checkout.vue b/src/pages-store/pages/order/checkout.vue index 8ac1bc4..3b19742 100644 --- a/src/pages-store/pages/order/checkout.vue +++ b/src/pages-store/pages/order/checkout.vue @@ -30,8 +30,9 @@ const userStore = useUserStore(); // 送达偏好 const visitMethodRef = ref(); +// value 与 visit-method 组件保持一致:0-亲自送达 1-放门口 const visitMethod = ref({ - value: 2, + value: 1, label: t("components.visit.putItAtTheDoor"), }); function chooseVisitMethod() { @@ -633,15 +634,14 @@ function getAddressList() { let data = addressesList.value[0] - // 回显用户地址中的送达偏好 - // 回显送达偏好 - if(+data.deliveryRemark === 1) { + // 回显送达偏好(deliveryType: 1-亲自送达 2-放门口) + if(+data.deliveryType === 1) { visitMethod.value.label = t('components.visit.leaveItToMePersonally') - visitMethod.value.value = 1 + visitMethod.value.value = 0 } - if(+data.deliveryRemark === 2) { + if(+data.deliveryType === 2) { visitMethod.value.label = t('components.visit.putItAtTheDoor') - visitMethod.value.value = 2 + visitMethod.value.value = 1 } // 如果是批量模式,地址加载完成后重新计算价格 @@ -664,12 +664,14 @@ function chooseAddress() { // 将新选择的地址id存储到selectedAddressId中 selectedAddressId.value = data.data - // 回显送达偏好 + // 回显送达偏好(deliveryType: 1-亲自送达 2-放门口) if(+data.deliveryType === 1) { visitMethod.value.label = t('components.visit.leaveItToMePersonally') + visitMethod.value.value = 0 } if(+data.deliveryType === 2) { visitMethod.value.label = t('components.visit.putItAtTheDoor') + visitMethod.value.value = 1 } // 重新计算价格 @@ -895,9 +897,16 @@ function appMerchantOrderPayOrder() { }) setTimeout(()=> { - uni.navigateBack({ - delta: 2, - }) + // 支付成功后跳转到当前订单详情页 + if (resOrderId.value) { + uni.reLaunch({ + url: `/pages-store/pages/order/index?id=${resOrderId.value}` + }) + } else { + uni.navigateBack({ + delta: 2, + }) + } }, 500) }) } @@ -920,9 +929,17 @@ function appMerchantOrderPayOrderBatch() { }) setTimeout(()=> { - uni.navigateBack({ - delta: 2, - }) + // 批量支付后,优先跳转到第一笔订单详情;若无订单ID则返回 + const firstOrderId = resOrderIds.value && resOrderIds.value.length > 0 ? resOrderIds.value[0] : '' + if (firstOrderId) { + uni.redirectTo({ + url: `/pages-store/pages/order/index?id=${firstOrderId}` + }) + } else { + uni.navigateBack({ + delta: 2, + }) + } }, 500) }).catch(err => { console.error('批量支付失败', err) diff --git a/src/pages-store/pages/order/choose-address.vue b/src/pages-store/pages/order/choose-address.vue index c23551b..c5c9466 100644 --- a/src/pages-store/pages/order/choose-address.vue +++ b/src/pages-store/pages/order/choose-address.vue @@ -4,8 +4,6 @@ import { getCurrentInstance } from 'vue'; import Search from "@/pages/home/components/tabbar-home/components/search.vue"; -import useEventEmit from "@/hooks/useEventEmit"; -import {EventEnum} from "@/constant/enums"; const { t } = useI18n(); import {useAddressStore} from "@/pages/address/store/address"; import {appUserAddressListPost} from "@/service"; @@ -15,6 +13,8 @@ const addressStore = useAddressStore() const addressesList = ref([]) const currentAddressId = ref('') +// 从 checkout 等页面通过 URL 传入的地址 id,用于进入页面时保持正确选中项 +const initialAddressIdFromQuery = ref('') function getAddressList() { appUserAddressListPost({ params: { @@ -25,37 +25,61 @@ function getAddressList() { console.log('获取用户地址列表', res) addressesList.value = res.rows if(res.rows.length > 0) { - currentAddressId.value = res.rows[0].id + // 若有从上一页传入的 id 且该 id 在列表中,则保持选中该地址;否则选中第一个 + const fromQuery = initialAddressIdFromQuery.value + const existsInList = res.rows.some((row: any) => String(row.id) === String(fromQuery)) + if (fromQuery && existsInList) { + currentAddressId.value = fromQuery + } else { + currentAddressId.value = res.rows[0].id + } } }) } function handleClickSearch() { uni.navigateTo({ url: '/pages-user/pages/search-address/index', + events: { + chooseAddress: (data: any) => { + console.log('搜索的地址信息', data) + if (!data) return + + // 先判断是否已有相同地址 + const exist = addressesList.value.find((item: any) => { + return ( + item.formattedAddress === data.formattedAddress && + (item.displayName || '') === (data.displayName || '') + ) + }) + + if (exist) { + // 已存在:直接选择这个地址,走原有 chooseAddress 流程 + chooseAddress(exist) + } else { + // 不存在:走新增地址流程 + addressStore.setAddressLocation({ + displayName: data.displayName, + formattedAddress: data.formattedAddress, + longitude: data.location.lng, + latitude: data.location.lat, + }) + setTimeout(() => { + uni.navigateTo({ + url: '/pages/address/choose-type' + }) + }, 300) + } + } + } }); } -useEventEmit(EventEnum.CHOOSE_ADDRESS, (data) => { - console.log('搜索的地址信息', data) - if(data) { - addressStore.setAddressLocation({ - displayName: data.displayName, - formattedAddress: data.formattedAddress, - longitude: data.location.lng, - latitude: data.location.lat, - }) - setTimeout(()=> { - uni.navigateTo({ - url: '/pages/address/choose-type' - }) - }, 300) - } -}) onShow(()=> { getAddressList() }) onLoad((options: any)=> { if(options.id) { + initialAddressIdFromQuery.value = options.id currentAddressId.value = options.id } }) diff --git a/src/pages-store/pages/order/index.vue b/src/pages-store/pages/order/index.vue index d68082c..e85f321 100644 --- a/src/pages-store/pages/order/index.vue +++ b/src/pages-store/pages/order/index.vue @@ -163,6 +163,8 @@ const payMethodOptions = ref({ payMethod: 1, // 支付方式 1信用卡 2余额 payPassword: '', }) +// 支付密码输入框 ref +const passwordInputRef = ref() useEventEmit(EventEnum.CHOOSE_PAYMENT_METHOD, (data) => { if(data) { if(data.payMethod === 1) { diff --git a/src/pages-store/pages/store/components/coupon-popup.vue b/src/pages-store/pages/store/components/coupon-popup.vue index 49a281c..4e336d3 100644 --- a/src/pages-store/pages/store/components/coupon-popup.vue +++ b/src/pages-store/pages/store/components/coupon-popup.vue @@ -3,12 +3,12 @@ import {useConfigStore} from "@/store"; import {receiveCouponApi} from "@/pages-user/service"; const configStore = useConfigStore() -const {t} = useI18n() +const { t, locale } = useI18n() const emit = defineEmits(['confirm']) const props = defineProps({ couponList: { - type: Array, + type: Array as unknown as PropType, default: () => [] } }) @@ -37,6 +37,57 @@ function confirmCoupon(item: any) { defineExpose({ init }); + +function daySuffix(value: unknown) { + const n = Number(value) + const isEn = String(locale.value || '').toLowerCase().startsWith('en') + if (isEn) { + return n === 1 ? ` ${t('pages-store.store.day')}` : ` ${t('pages-store.store.days')}` + } + return t('pages-store.store.days') +} + +function isEnLocale() { + return String(locale.value || '').toLowerCase().startsWith('en') +} + +function formatMoney(value: unknown) { + const n = Number(value) + if (!Number.isFinite(n)) return '0.00' + return n.toFixed(2) +} + +function couponTitleText(item: any) { + const type = Number(item?.couponType) + const discountValue = Number(item?.discountValue) + + // 标题保持原样:折扣券显示百分比,满减券只显示减免金额(不展示门槛) + if (type === 1) { + const pct = Number.isFinite(discountValue) ? Number(discountValue * 100).toFixed(0) : '0' + return `${pct}% ${t('pages-store.store.couponOff')}` + } + + return `$${formatMoney(discountValue)} ${t('pages-store.store.couponOff')}` +} + +function couponBenefitText(item: any) { + const type = Number(item?.couponType) + const discountValue = Number(item?.discountValue) + const minAmount = Number(item?.minAmount) + + if (type === 2) { + const discountText = `$${formatMoney(discountValue)}` + const hasMin = Number.isFinite(minAmount) && minAmount > 0 + if (hasMin) { + const minText = `$${formatMoney(minAmount)}` + return isEnLocale() ? `Min ${minText} · Off ${discountText}` : `满${minText}减${discountText} 优惠` + } + return isEnLocale() ? `Off ${discountText}` : `立减${discountText}` + } + + const pct = Number.isFinite(discountValue) ? Number(discountValue * 100).toFixed(0) : '0' + return `${pct}%` +}