From efa9bfe98ba906e4c9b8f49c89f5da162a46bb0f Mon Sep 17 00:00:00 2001 From: 陶杰 <1378534974@qq.com> Date: 星期一, 13 一月 2025 10:21:24 +0800 Subject: [PATCH] 1.微信一键登录:新增“同意用户协议”之后才可登录 --- pages/user/address/address.vue | 92 +++++++++++++++++++++++++++++++++++++--------- 1 files changed, 74 insertions(+), 18 deletions(-) diff --git a/pages/user/address/address.vue b/pages/user/address/address.vue index 6be831d..772cdfe 100644 --- a/pages/user/address/address.vue +++ b/pages/user/address/address.vue @@ -19,7 +19,7 @@ </view> <view class="flex" @click="changeCurrentAddress"> <view> - <image style="width: 30rpx;height: 30rpx;" class="m-t-2" + <image style="width: 30rpx;height: 30rpx;margin-top: 6rpx;margin-right: 10rpx;" class="m-t-2" src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/a2/a248385d4fe748ca81ee058ea5bf8c47icon-address.jpg"> </image> </view> @@ -28,7 +28,7 @@ </view> </view> <view class="m-t-12 "> - <view class="desc-gray">我的收获地址</view> + <view class="desc-gray">我的收货地址</view> </view> <no-data v-if="!list||list.length==0" style="width: 100%;"></no-data> @@ -76,6 +76,9 @@ </view> <view class="desc del t-green m-l-10" v-if="source==='select'" @click="selectAddress(item)"> 选择此地址 + </view> + <view class="desc del t-green m-l-10" v-if="source==='home'" @click="selectAddress(item)"> + 按此地址定位 </view> </view> @@ -262,7 +265,7 @@ //表单选择了地址 wx.chooseLocation({ success: location => { - console.log('success loc', location) + console.log('success loc', location,source) // address: "江苏省苏州市吴中区太湖东路288号" // errMsg: "chooseLocation:ok" // latitude: 31.26249 @@ -270,13 +273,15 @@ // name: "苏州市吴中区人民政府" if (source === 'form') { // (location.address || '') + - that.submitForm.address = (location.name || '') + that.submitForm.address = (location.name || location.address || '') that.submitForm.latitude = location.latitude || 0 that.submitForm.longitude = location.longitude || 0 } else if (source === 'input') { // (location.address || '') + // that.search_flow = (location.name || '') - that.$store.commit('setAddressDesc', (location.name || '')) + that.$store.commit('setAddressDesc', (location.name || location.address || '')) + that.$forceUpdate() + that.backpage() } // if (!that.submitForm.province && location.provinceName) { @@ -369,7 +374,7 @@ // }; const { code,data - } = that.$http.request('get', '/api/pub/customer/home/address/parse', { + } = await that.$http.request('get', '/api/pub/customer/home/address/parse', { data: {}, params: { // https://apis.map.qq.com/ws/geocoder/v1/?location=39.984154,116.307490&key=[你的key]&get_poi=1 @@ -378,24 +383,61 @@ }) console.log('定位成功:', data); if(data){ - var address = data.address || '' + var address = data.result&&data.result.address || '' that.$store.commit('setAddressDesc', (address || '')) + that.$forceUpdate() + + that.backpage() + } }, fail: (err) => { - this.error = err; + that.error = err; console.error('定位失败:', err); }, complete() { - this.$message.hideLoading() + that.$message.hideLoading() } }); }, PickArea(item, e) { - console.log('PickArea', item, e) + if (e.detail.value) { + this.submitForm.province = '' + this.submitForm.city = '' + this.submitForm.region = '' + if (e.detail.value.length == 2) { + if (!!e.detail.value[0]) + this.submitForm.province = e.detail.value[0].text + if (!!e.detail.value[0]) + this.submitForm.city = e.detail.value[0].text + if (!!e.detail.value[1]) + this.submitForm.region = e.detail.value[1].text + } else if (e.detail.value.length <= 3) { + if (!!e.detail.value[0]) + this.submitForm.province = e.detail.value[0].text + if (!!e.detail.value[1]) + this.submitForm.city = e.detail.value[1].text + if (!!e.detail.value[2]) + this.submitForm.region = e.detail.value[2].text + } else { + //说明有重复的 + var plusnum = e.detail.value.length - 3 + if (!!e.detail.value[plusnum + 0]) + this.submitForm.province = e.detail.value[plusnum + 0].text + if (!!e.detail.value[plusnum + 1]) + this.submitForm.city = e.detail.value[plusnum + 1].text + if (!!e.detail.value[plusnum + 2]) + this.submitForm.region = e.detail.value[plusnum + 2].text + } + + this.$forceUpdate() + console.log('submit forn', this.submitForm) + } + }, + PickArea2(item, e) { if (e.detail.value) { this.submitForm.province = '' this.submitForm.city = '' @@ -430,21 +472,25 @@ } }, async init_area() { - if (this.regionDataPlus && this.regionDataPlus.length > 0) { + // debugger; + // if (this.regionDataPlus && this.regionDataPlus.length > 0) { - } else { - var a = this.$storage.getItem('cache_area') + // } else { + // var a = this.$storage.getItem('cache_area') + var a =false if (a) { this.regionDataPlus = JSON.parse(a) || [] } else { + // await this.$http.request('get', '/api/pub/china/area/json/refresh') const res = await this.$http.request('get', '/api/pub/china/area/json') // console.log('area', JSON.parse(res.data)) this.regionDataPlus = res.data && JSON.parse(res.data.replaceAll('code', 'value').replaceAll( 'name', 'text')) || [] + this.$storage.setItem('cache_area', JSON.stringify(this.regionDataPlus)) } - } + // } }, chooseLocation() { @@ -523,6 +569,7 @@ this.$store.commit('setDefaultAddress', { ...item }) + } }, err => { @@ -537,11 +584,20 @@ }) }, async selectAddress(item) { - await this.$message.confirm('确定选择此地址作为收货地址吗') //携带,然后返回 - this.$store.commit('setDefaultAddress', { - ...item - }) + + if(this.source==='home'){ + this.$store.commit('setAddressDesc', '') + this.$store.commit('setDefaultAddress', { + ...item + }) + }else{ + await this.$message.confirm('确定选择此地址作为收货地址吗') + this.$store.commit('setDefaultAddress', { + ...item + }) + + } this.backpage() }, async deleteAddress(item) { -- Gitblit v1.9.3