陶杰
2025-01-13 efa9bfe98ba906e4c9b8f49c89f5da162a46bb0f
pages/user/address/address.vue
@@ -77,6 +77,9 @@
            <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>
      </view>
@@ -401,7 +404,40 @@
            });
         },
         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 = ''
@@ -436,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() {
@@ -529,6 +569,7 @@
                     this.$store.commit('setDefaultAddress', {
                        ...item
                     })
                  }
               }, err => {
@@ -543,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) {