doum
2026-04-30 7a0b33a5f2e0ba589bf35a1b8d896700a21f94a4
small-program/App.vue
@@ -1,6 +1,5 @@
<script>
   import { mapState } from 'vuex'
   // var QQMapWX = require('@/utils/qqmap-wx-jssdk.js')
   var amapFile = require('@/utils/amap-wx.130.js')
   export default {
      computed: {
@@ -15,7 +14,6 @@
                  let { code } = loginRes;
                  let res = await that.$u.api.wxLogin({ code })
                  if (res && res.code === 200) {
                     console.log(res, '==================登录成功');
                     // 判断有无openid
                     if (res.data.openid) {
                        await that.$store.commit('setOpenid', res.data.openid)
@@ -27,7 +25,6 @@
                     // 判断有无用户信息
                     if (res.data.member) {
                        await that.$store.commit('setUserInfo', res.data.member)
                        await that.$store.commit('setOpenid', res.data.member.openId)
                     }
                     // 设置定位
                     await that.checkLocationAuth()
@@ -39,7 +36,7 @@
            let res = await that.$u.api.getMemberInfo({})
            if (res.code === 200) {
               await that.$store.commit('setUserInfo', res.data)
               await that.$store.commit('setOpenid', res.data.openId)
               await that.$store.commit('setOpenid', res.data.openid)
            }
            // 设置定位
            await that.checkLocationAuth()
@@ -61,23 +58,24 @@
               isHighAccuracy: true,
               success: function (addr) {
                  const locParam = { latitude: addr.latitude, longitude: addr.longitude };
                  uni.setStorageSync('address', locParam);
                  var address = null
                  var myAmapFun = new amapFile.AMapWX({ key: 'e4d46c87adf151dca20060317592b1b6' });
                  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];
                        console.log(info, '==================获取地址');
                        locParam.province = info.province;
                        locParam.city = info.regeocodeData.addressComponent.city;
                        var ta = info.name || '地址获取失败';
                        locParam.adcode = info.regeocodeData.addressComponent.adcode;
                        var ta = info.desc || '地址获取失败';
                        locParam.address = ta
                        const resCity = await that.$u.api.getCityByName({ cityName: locParam.city })
                        if (resCity.code === 200) {
                        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.$store.commit('setPosition', locParam)
                        } else {
                           that.$store.commit('setPosition', locParam)
                           that.$store.commit('clearCityId')
                        }
                        that.$isResolve()
                     },
                     fail: function(err) {
@@ -86,35 +84,6 @@
                        that.$isResolve()
                     }
                  });
                  // const qqmapsdk = new QQMapWX({
                  //    key: 'WE3BZ-HN6WS-ONDOH-62QCV-MNL6F-5NFNE'
                  // });
                  // qqmapsdk.reverseGeocoder({
                  //    locParam,
                  //    success: async function(res) {
                  //       console.log(res, '==================获取地址');
                  //       let info = res.result;
                  //       locParam.province = info.address_component.province;
                  //       locParam.city = info.address_component.city;
                  //       locParam.area = info.address_component.district;
                  //       locParam.street = info.address_component.street;
                  //       var ta = info.address  || '地址获取失败' ;
                  //       if(info.formatted_addresses  && info.formatted_addresses.recommend){
                  //          ta =info.formatted_addresses.recommend
                  //       }
                  //       locParam.address =ta
                  //       const resCity = await that.$u.api.getCityByName({ cityName: locParam.city })
                  //       if (resCity.code === 200) {
                  //          locParam.cityId = resCity.data.id
                  //       }
                  //       that.$store.commit('setPosition',locParam)
                  //       that.$isResolve()
                  //    },
                  //    fail: (err) => {
                  //       that.$isResolve()
                  //    }
                  // });
               }
            });
         },