diff --git a/packages/shop/address/index.vue b/packages/shop/address/index.vue index 6fd9c1e3..b40c5267 100644 --- a/packages/shop/address/index.vue +++ b/packages/shop/address/index.vue @@ -3,7 +3,7 @@ - + {{item.name}} {{item.phone}} 默认 @@ -102,6 +102,14 @@ export default { } }); }, + + // 选择地址 + selectAddress(item) { + // 存储选中的地址信息 + uni.setStorageSync('selectedAddress', item); + // 返回上一页 + uni.navigateBack(); + }, async init() { const res = await request(apiArr.addAddressList, 'POST', {}); diff --git a/packages/shop/goodsSubmit/index.vue b/packages/shop/goodsSubmit/index.vue index c39d459e..3bfa0859 100644 --- a/packages/shop/goodsSubmit/index.vue +++ b/packages/shop/goodsSubmit/index.vue @@ -192,7 +192,16 @@ export default { this.carList = JSON.parse(options.shopCarList) }, onShow() { - this.getUserAddress() + // 检查是否有选中的地址 + const selectedAddress = uni.getStorageSync('selectedAddress'); + if (selectedAddress && Object.keys(selectedAddress).length > 0) { + this.defAddress = selectedAddress; + // 清除选中状态,避免重复应用 + uni.removeStorageSync('selectedAddress'); + } else { + // 如果没有选中的地址,则获取默认地址 + this.getUserAddress(); + } this.getGoodsList() }, onUnload() {