陶杰
2024-12-23 d39644872fa6f9499fc2c1651bced631a9e96b19
pages/user/address/address.vue
@@ -2,7 +2,8 @@
   <!-- 收货地址列表 -->
   <view class="p15 container-address">
      <view class="search-container m-t-12 flex">
         <view class="flex1 input" @click="selectWxAddress('input')">
         <!-- <view class="flex1 input" @click="selectWxAddress('input')"> -->
         <view class="flex1 input" @click="selectGaodeAddress('input')">
            <u-input placeholder="小区名/店铺名/写字楼/街道名等" disabled v-model="search_flow">
               <template slot="suffix">
                  <uni-icons color="#20613D" type="search" size="24"></uni-icons>
@@ -122,7 +123,9 @@
                  <view class="m-l-a m-r-0 flex " :class="[!dto['province']?'desc-gray':'']">
                     <uni-data-picker :area="true" @change="(e)=>{PickArea(submitForm,e)}" placeholder=""
                        :localdata="regionDataPlus">
                        {{ submitForm['province'] || '请选择' }}{{ submitForm['city'] && ('/' + submitForm['city']) || '' }}{{
                        {{ submitForm['province'] || '请选择' }}{{ submitForm['city'] && ('/' + submitForm['city'])
                           || ''
                        }}{{
                  submitForm['region'] && ('/' + submitForm['region']) || ''
                }}
                     </uni-data-picker>
@@ -174,6 +177,8 @@
   // const chooseLocation = requirePlugin('chooseLocation');   
   // #endif
import amapFile from '@/map/amap-wx.130.js';
   import {
      mapState
   } from 'vuex'
@@ -184,6 +189,24 @@
         uni.stopPullDownRefresh()
      },
      async onLoad(options) {
      // debugger;
      // 引入高德地图的组件
      const myAmapFun = new amapFile.AMapWX({ key: '75d7da3feb329cd5ae997975b953abb6' });
      myAmapFun.getRegeo({
         success: (data) => {
            console.log('当前位置:', data[0]);
            console.log(data)
            // this.setData({
            //    longitude: data[0].longitude,
            //    latitude: data[0].latitude,
            //    locationName: data[0].name,
            // });
         },
         fail(err) {
            console.error(err);
         },
      });
         // this.list = [{}, {}]
         this.source = options.source || ''
         this.listApi = '/api/address/list'
@@ -196,33 +219,7 @@
      },
      onShow() {
         // const location = chooseLocation.getLocation(); // 如果点击确认选点按钮,则返回选点结果对象,否则返回null
         // // console.log('onshow location', location, this.tmp_picker_lock_index, this.formcodes["LOC_ONE"])
         // // address: "江苏省苏州市吴中区太湖东路280号"
         // // city: "苏州市"
         // // district: "吴中区"
         // // latitude: 31.262438
         // // longitude: 120.633985
         // // name: "太湖东路280号小区"
         // // province: "江苏省"
         // if (location && location.address) {
         //    this.submitForm.address = location.address
         //    this.submitForm.latitude = location.latitude
         //    this.submitForm.longitude = location.longitude
         //    if (!this.submitForm.province && location.province) {
         //       this.submitForm.province = location.province
         //       if (!this.submitForm.city && location.city) {
         //          this.submitForm.city = location.city
         //       }
         //       if (!this.submitForm.region && location.district) {
         //          this.submitForm.region = location.district
         //       }
         //       if (!this.submitForm.region && location.city) {
         //          this.submitForm.region = location.city
         //       }
         //    }
         //    this.$forceUpdate()
         // }
      },
      computed: {
         ...mapState({
@@ -258,6 +255,11 @@
         };
      },
      methods: {
      selectGaodeAddress(){
         uni.navigateTo({
            url: '/pages/user/address/gaode-address'
         })
      },
         selectWxAddress(source) {
            let that = this
@@ -266,6 +268,7 @@
               wx.chooseLocation({
                  success: location => {
                     console.log('success loc', location,source)
                  console.log(location)
                     // address: "江苏省苏州市吴中区太湖东路288号"
                     // errMsg: "chooseLocation:ok"
                     // latitude: 31.26249