fix(uniapp): 外卖订单默认地址
This commit is contained in:
1 parent
6d3c640c98
commit
81ccaa6e01
1 file changed
+16
@@ -76,6 +76,7 @@ import {
|
|||||||
couponCount
|
couponCount
|
||||||
} from '@/api/coupon'
|
} from '@/api/coupon'
|
||||||
import { getDeliveryFee } from '@/api/goods'
|
import { getDeliveryFee } from '@/api/goods'
|
||||||
|
import { addressAll } from '@/api/address'
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
import * as jweixin from 'weixin-js-sdk'
|
import * as jweixin from 'weixin-js-sdk'
|
||||||
// #endif
|
// #endif
|
||||||
@@ -215,6 +216,7 @@ onShow(() => {
|
|||||||
|
|
||||||
if(orderType.value == 'takeout'){
|
if(orderType.value == 'takeout'){
|
||||||
active.value = true
|
active.value = true
|
||||||
|
fillDefaultAddress()
|
||||||
}else{
|
}else{
|
||||||
active.value = false
|
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() => {
|
const getSubscribeMss = async() => {
|
||||||
let data = []
|
let data = []
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|||||||
Reference in new issue
Block a user