From 81ccaa6e011a1e5c00e4e167f883aa0664fbdb0a Mon Sep 17 00:00:00 2001 From: Kroytz Date: Fri, 24 Jul 2026 13:25:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(uniapp):=20=E5=A4=96=E5=8D=96=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=BB=98=E8=AE=A4=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/components/pages/pay/pay.vue | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/yshop-drink-uniapp-vue3/pages/components/pages/pay/pay.vue b/yshop-drink-uniapp-vue3/pages/components/pages/pay/pay.vue index ad825ad..983c8ef 100644 --- a/yshop-drink-uniapp-vue3/pages/components/pages/pay/pay.vue +++ b/yshop-drink-uniapp-vue3/pages/components/pages/pay/pay.vue @@ -76,6 +76,7 @@ import { couponCount } from '@/api/coupon' import { getDeliveryFee } from '@/api/goods' +import { addressAll } from '@/api/address' // #ifdef H5 import * as jweixin from 'weixin-js-sdk' // #endif @@ -215,6 +216,7 @@ onShow(() => { if(orderType.value == 'takeout'){ active.value = true + fillDefaultAddress() }else{ active.value = false } @@ -236,6 +238,20 @@ onLoad((option) => { } }) +// 外卖且未选手动地址时,自动填入默认地址(无默认则取列表第一项) +const fillDefaultAddress = async () => { + if (orderType.value !== 'takeout') return + if (address.value?.id) return + if (!isLogin.value) return + const list = await addressAll() + if (!list || !list.length) return + main.SET_ADDRESSES(list) + const preferred = list.find(item => Number(item.isDefault) === 1) || list[0] + if (preferred) { + main.SET_ADDRESS(preferred) + } +} + const getSubscribeMss = async() => { let data = [] if (data) {