From 29dfab5b6dd5dc5bcfa96b0ffbf4091c3c69b5ab Mon Sep 17 00:00:00 2001 From: "mayubo@gmail.com" Date: Fri, 18 Jul 2025 09:53:16 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E6=94=B6=E8=B4=A7=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8?= =?UTF-8?q?And=E5=9C=B0=E5=8C=BA=E9=80=89=E6=8B=A9=E5=99=A8=E7=BB=84?= =?UTF-8?q?=E4=BB=B6bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/shop.js | 5 + components/areaPopup/areaPopup.vue | 3 + packages/shop/addAddress/index.vue | 161 ++++++++++++++++-- packages/shop/address/index.vue | 61 +++++-- pages/shopcity/shopcity.vue | 1 + .../.sourcemap/mp-weixin/common/main.js.map | 2 +- .../.sourcemap/mp-weixin/common/vendor.js.map | 2 +- .../mp-weixin/kitchen/index/index.js.map | 2 +- .../mp-weixin/pages/index/index.js.map | 2 +- .../mp-weixin/reservation/index/index.js.map | 2 +- .../uview-ui/components/u-icon/u-icon.js.map | 2 +- .../u-loading-icon/u-loading-icon.js.map | 2 +- .../components/u-overlay/u-overlay.js.map | 2 +- .../components/u-popup/u-popup.js.map | 2 +- .../u-safe-bottom/u-safe-bottom.js.map | 2 +- .../u-status-bar/u-status-bar.js.map | 2 +- .../u-transition/u-transition.js.map | 2 +- .../dev/mp-weixin/project.private.config.json | 23 ++- 18 files changed, 226 insertions(+), 52 deletions(-) diff --git a/api/shop.js b/api/shop.js index 192cd1ce..f63fe88e 100644 --- a/api/shop.js +++ b/api/shop.js @@ -6,5 +6,10 @@ export const apiArr = { getCarCount:"/api/v2/wechat/commodity/cart/all_count",//购物车数量 addCar:"/api/v2/wechat/commodity/cart/add",//添加购物车 deleteCar:"/api/v2/wechat/commodity/cart/delete",//删除购物车 + addressList: '/api/v2/wechat/commodity/receiving_address', // 收货地址列表 + addAddress: '/api/v2/wechat/commodity/receiving_address/add', // 收货地址添加 + addressDel: '/api/v2/wechat/commodity/receiving_address/delete', // 收货地址删除 + settingDefaultAddress: '/api/v2/wechat/commodity/receiving_address/default', // 收货地址设置默认 + updateAddress: '/api/v2/wechat/commodity/receiving_address/update', // 收货地址修改 updateCar:"/api/v2/wechat/commodity/cart/update", } \ No newline at end of file diff --git a/components/areaPopup/areaPopup.vue b/components/areaPopup/areaPopup.vue index c487f639..b953b820 100644 --- a/components/areaPopup/areaPopup.vue +++ b/components/areaPopup/areaPopup.vue @@ -78,6 +78,9 @@ export default { console.log('新市区跟旧市区不一直') this.xsq = newDist; this.getDistList(newDist, x); + } else { + console.log('新市区跟旧市区一直'); + this.confirmDist = this.defaultDist[x] } return } diff --git a/packages/shop/addAddress/index.vue b/packages/shop/addAddress/index.vue index e0a090ac..5a9db032 100644 --- a/packages/shop/addAddress/index.vue +++ b/packages/shop/addAddress/index.vue @@ -3,14 +3,14 @@
*收货人
- +
*手机号
- +
@@ -24,24 +24,23 @@
地址
- 请选择地址 + 请选择地址 + {{ orientation.region }} {{orientation.district}}
-
+
-
当前定位:和平里社区综合 服务站
-
使用
+
当前定位:{{orientation.district}}
+
使用
-
河北衡水市桃城区
+
{{orientation.region}}
-
门牌号
- +
@@ -69,24 +68,24 @@
*详细地址
- +
-
+
设置默认地址
提醒:下单时会优先选择
- - + +
-
确定
+
确定
@@ -95,6 +94,7 @@ import { apiArr } from '../../../api/area'; +import { apiArr as apiArr2 } from '../../../api/shop'; import { picUrl, menuButtonInfo, @@ -122,6 +122,16 @@ export default { sf: true, xsq: {}, value2: '', + + isShow: false, + id: '', + type: '', + orientation: uni.getStorageSync('location'), + name: '', + phone: '', + houseNumber: '', + isDefault: 2, + showOrientation: true, } }, methods: { @@ -130,6 +140,7 @@ export default { }, chooseAddress() { console.log(123); + this.isShow = true; NavgateTo("/pages/shopcity/shopcity") }, /////////////////////////////////// 省市区方法/////////////////////////////////////////// @@ -143,8 +154,9 @@ export default { }, // 获取市区信息 - async getCityList(sq, x) { + async getCityList(sq, x,) { console.log('11swq', sq); + console.log('获取x', x); if (!this.sf) { console.log('省份没变,查市跟区', this.cityList) let newDist = this.cityList[sq]; @@ -153,6 +165,9 @@ export default { console.log('新市区跟旧市区不一直') this.xsq = newDist; this.getDistList(newDist, x); + } else { + console.log('新市区跟旧市区一直'); + this.confirmDist = this.defaultDist[x] } return } @@ -166,11 +181,101 @@ export default { }, // 获取 县/区 信息 async getDistList(xsq, x) { + console.log('页面传递的x',x); const res = await request(apiArr.getArea, 'POST', { parent_ad_code: xsq ? xsq.ad_code : this.confirmCity.ad_code }, { silent: false }); this.distList = res.rows; this.defaultDist = res.rows; this.confirmDist = res.rows[0] // 区的第一条信息 }, + + async headerSubmitClick() { + console.log('省' ,this.confirmProv1); + console.log('xsq' ,this.xsq); + console.log('confirmCity' ,this.confirmCity); + console.log('confirmDist' ,this.confirmDist); + const { confirmProv1, xsq, confirmCity, confirmDist } = this; + if(!this.name) { + uni.showToast({ + title: '请输入收货人名称', + icon: 'none' + }) + return + } + if(!this.phone) { + uni.showToast({ + title: '请输入收货人手机号', + icon: 'none' + }) + return + } + if(this.tab == 0 && this.showOrientation) { + uni.showToast({ + title: '请输入收货地址', + icon: 'none' + }) + return + } + if(!this.houseNumber) { + uni.showToast({ + title: '请输入门牌号', + icon: 'none' + }) + return + } + if(this.type === 'edit') { + const res = await request(apiArr2.updateAddress, "POST", { + id: this.id, + name: this.name, + phone: this.phone, + address: this.tab === 0 ? this.orientation.region + this.orientation.district : `${confirmProv1.short_name}${xsq.short_name ? xsq.short_name : confirmCity.short_name}${confirmDist.short_name}`, + house_number: this.houseNumber, + is_default: this.isDefault + }, { nested: true}) + console.log('编辑成功', res); + if(res.code === 1) { + uni.showToast({ + title: '地址更新成功', + icon: 'success', + mask: true + }) + setTimeout(() => { + uni.navigateBack({ + delta: 1 + }) + }, 1000) + } + } else { + const res = await request(apiArr2.addAddress, 'POST', { + name: this.name, + phone: this.phone, + address: this.tab === 0 ? this.orientation.region + this.orientation.district : `${confirmProv1.short_name}${xsq.short_name ? xsq.short_name : confirmCity.short_name}${confirmDist.short_name}`, + house_number: this.houseNumber, + is_default: this.isDefault + }, { nested: true}) + if(res.code === 1) { + uni.showToast({ + title: '地址添加成功', + icon: 'success', + mask: true + }) + setTimeout(() => { + uni.navigateBack({ + delta: 1 + }) + }, 1000) + } + } + + }, + + headerConfirmClick() { + this.showOrientation = false; + this.isShow = true; + this.orientation = uni.getStorageSync('location'); + }, + headerSettingDefaultAddressClick() { + this.isDefault = this.isDefault == 2 ? 1 : 2; + }, async init() { uni.showLoading({ title: '加载中', @@ -205,11 +310,35 @@ export default { /////////////////////////////////// 省市区方法/////////////////////////////////////////// }, onLoad(options) { + console.log('12231', options); + if(options.item) { + const item = JSON.parse(options.item); + console.log('1231', item); + this.name = item.name; + this.phone = item.phone; + this.orientation = { + region: item.address, + district: '' + } + this.showOrientation = false; + this.id = item.id; + this.type = 'edit'; + this.isShow = false; + this.isDefault = item.is_default; + this.houseNumber = item.house_number; + } const meun = menuButtonInfo(); this.top = meun.top; this.localHeight = meun.height; this.init() }, + onShow() { + if(!this.isShow ) return; + if(this.orientation.district !== uni.getStorageSync('location').district) { + this.orientation = uni.getStorageSync('location'); + this.showOrientation = false; + } + }, onReachBottom() { }, diff --git a/packages/shop/address/index.vue b/packages/shop/address/index.vue index d16430cf..48abeba4 100644 --- a/packages/shop/address/index.vue +++ b/packages/shop/address/index.vue @@ -3,29 +3,27 @@
-
+
- 高世霞 15901518415
默认
-
-
- 河北 衡水 桃城区 上海公馆 赞寓17层 + {{item.name}} {{item.phone}}
默认
+
{{item.address}}{{ item.house_number }}