MrShi
3 小时以前 fbc074229fd4736f1ae2793c9daebf04726188b2
small-program/pages/index/index.vue
@@ -272,48 +272,51 @@
            });
         },
         chooseLocation() {
            var that = this;
            uni.chooseLocation({
               type: 'gcj02',
               success: async function(addr) {
                  console.log(addr, '==================uniapp选择位置成功');
                  if (addr.errMsg === 'chooseLocation:ok' && addr.latitude) {
                     const locParam = { latitude: addr.latitude, longitude: addr.longitude };
                     var myAmapFun = new amapFile.AMapWX({ key: that.$gaodeMapKey });
                     myAmapFun.getRegeo({
                        location: addr.longitude + ',' + addr.latitude,
                        success: async function(data) {
                           console.log(data, '==================选择地址逆解析');
                           let info = data[0];
                           locParam.province = info.province;
                           locParam.adcode = info.regeocodeData.addressComponent.adcode
                           var ta = addr.name || '地址获取失败';
                           locParam.address = ta
                           const resCity = await that.$u.api.getCityByName({ code: locParam.adcode })
                           if (resCity.code === 200 && resCity.data) {
                              locParam.cityId = resCity.data.id
                              that.$store.commit('setPosition', locParam)
                              that.pointList = []
                              that.getNearbyShopList()
                           } else {
                              that.$store.commit('setPosition', locParam)
                              that.$store.commit('clearCityId')
                              that.pointList = []
                           }
                        },
                        fail: function(err) {
                           console.error('获取位置失败===========', err);
                           that.$store.commit('setPosition', locParam)
                           that.pointList = []
                           that.getNearbyShopList()
                        }
                     });
                  }
               },
               fail: function(err) {
                  console.error('选择位置失败===========', err);
               }
            });
            uni.navigateTo({
               url: '/shop/pages/storage-point/storage-point'
            })
            // var that = this;
            // uni.chooseLocation({
            //    type: 'gcj02',
            //    success: async function(addr) {
            //       console.log(addr, '==================uniapp选择位置成功');
            //       if (addr.errMsg === 'chooseLocation:ok' && addr.latitude) {
            //          const locParam = { latitude: addr.latitude, longitude: addr.longitude };
            //          var myAmapFun = new amapFile.AMapWX({ key: that.$gaodeMapKey });
            //          myAmapFun.getRegeo({
            //             location: addr.longitude + ',' + addr.latitude,
            //             success: async function(data) {
            //                console.log(data, '==================选择地址逆解析');
            //                let info = data[0];
            //                locParam.province = info.province;
            //                locParam.adcode = info.regeocodeData.addressComponent.adcode
            //                var ta = addr.name || '地址获取失败';
            //                locParam.address = ta
            //                const resCity = await that.$u.api.getCityByName({ code: locParam.adcode })
            //                if (resCity.code === 200 && resCity.data) {
            //                   locParam.cityId = resCity.data.id
            //                   that.$store.commit('setPosition', locParam)
            //                   that.pointList = []
            //                   that.getNearbyShopList()
            //                } else {
            //                   that.$store.commit('setPosition', locParam)
            //                   that.$store.commit('clearCityId')
            //                   that.pointList = []
            //                }
            //             },
            //             fail: function(err) {
            //                console.error('获取位置失败===========', err);
            //                that.$store.commit('setPosition', locParam)
            //                that.pointList = []
            //                that.getNearbyShopList()
            //             }
            //          });
            //       }
            //    },
            //    fail: function(err) {
            //       console.error('选择位置失败===========', err);
            //    }
            // });
         },
         // 定位
         positioning() {
@@ -334,6 +337,7 @@
                        locParam.adcode = info.regeocodeData.addressComponent.adcode;
                        locParam.area = info.district;
                        locParam.street = info.street;
                        locParam.cityName = info.regeocodeData.addressComponent.city;
                        var ta = info.name || '地址获取失败';
                        locParam.address = ta
                        const resCity = await that.$u.api.getCityByName({ code: locParam.adcode })