doum
2026-04-30 f2b6fdd955f8ac6e5b351e0b5e3a9f583ed6da2e
small-program/pages/index/index.vue
@@ -84,6 +84,7 @@
         </view>
         <view class="toast-btn" @click="handleLocation">开启定位</view>
      </view>
      <auth-login :show="showLogin" @close="showLogin = false"></auth-login>
      <custom-tabbar></custom-tabbar>
   </view>
</template>
@@ -98,7 +99,7 @@
         CustomTabbar
      },
      computed: {
         ...mapState(['navHeight', 'statusbarHeight', 'address', 'latitude', 'cityId', 'longitude']),
         ...mapState(['navHeight', 'statusbarHeight', 'address', 'latitude', 'cityId', 'longitude', 'token']),
         currentAddress() {
            return this.address && this.address !== '定位中' ? this.address : '获取定位'
         }
@@ -107,7 +108,10 @@
         return {
            bannerList: [],
            pointList: [],
            ingOrder: null
            ingOrder: null,
            showLogin: false,
            pendingNavigate: null,
            lastLocationAuth: null
         }
      },
      async onLoad() {
@@ -120,8 +124,40 @@
      onShow() {
         this.ingOrder =null
         this.getIngorder()
         this.checkLocationAuth()
      },
      watch: {
         token(newToken) {
            if (newToken && this.pendingNavigate) {
               const fn = this.pendingNavigate
               this.pendingNavigate = null
               this.showLogin = false
               fn()
            }
         }
      },
      methods: {
         async checkLocationAuth() {
            const _this = this
            uni.getSetting({
               success(res) {
                  const authLocation = res.authSetting['scope.userLocation']
                  if (_this.lastLocationAuth !== null && _this.lastLocationAuth !== authLocation) {
                     if (authLocation) {
                        _this.positioning()
                     }
                  }
                  _this.lastLocationAuth = authLocation
               }
            })
         },
         async getIngorder() {
            var that =this
            let res = await that.$u.api.getActiveOrderTip()
            if (res && res.code === 200) {
               this.ingOrder = res.data
            }
         },
         jumpBannerDetail(item) {
            if(!item.content || item.content =='' || item.type==0){
               return
@@ -141,20 +177,23 @@
               url:'/pages/delivery-order-detail/delivery-order-detail?userType=0&id='+id
            })
         },
         async getIngorder(){
            var that =this
            let res = await that.$u.api.getActiveOrderTip()
            if (res && res.code === 200) {
               this.ingOrder = res.data
            }
         },
         jumpOrderList(status){
            if (!this.token) {
               this.pendingNavigate = () => this.jumpOrderList(status)
               this.showLogin = true
               return
            }
            uni.setStorageSync("orderStatus",status)
            uni.switchTab({
               url: '/pages/itinerary/itinerary'
            })
         },
         jumpxiadan() {
            if (!this.token) {
               this.pendingNavigate = () => this.jumpxiadan()
               this.showLogin = true
               return
            }
            if (!this.cityId) return uni.showToast({
               title: '当前城市暂未开通',
               icon: 'none'
@@ -218,12 +257,10 @@
                           console.log(data, '==================选择地址逆解析');
                           let info = data[0];
                           locParam.province = info.province;
                           locParam.city = (info.regeocodeData.addressComponent.city && typeof info.regeocodeData.addressComponent.city === 'string')
                              ? info.regeocodeData.addressComponent.city
                              : info.regeocodeData.addressComponent.province;
                           locParam.adcode = info.regeocodeData.addressComponent.adcode
                           var ta = addr.name || '地址获取失败';
                           locParam.address = ta
                           const resCity = await that.$u.api.getCityByName({ cityName: locParam.city })
                           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)
@@ -233,7 +270,6 @@
                              that.$store.commit('setPosition', locParam)
                              that.$store.commit('clearCityId')
                              that.pointList = []
                              that.getNearbyShopList()
                           }
                        },
                        fail: function(err) {
@@ -259,23 +295,24 @@
               isHighAccuracy: true,
               success: function (addr) {
                  const locParam = { latitude: addr.latitude, longitude: addr.longitude };
                  var myAmapFun = new amapFile.AMapWX({ key: 'f2e6c0bfcac14c27b4f0d6d0d5b9d7d' });
                  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.city = info.city;
                        locParam.adcode = info.regeocodeData.addressComponent.adcode;
                        locParam.area = info.district;
                        locParam.street = info.street;
                        var ta = info.name || '地址获取失败';
                        locParam.address = ta
                        const resCity = await that.$u.api.getCityByName({ cityName: locParam.city })
                        const resCity = await that.$u.api.getCityByName({ code: locParam.adcode })
                        if (resCity.code === 200) {
                           locParam.cityId = resCity.data.id
                        }
                        that.$store.commit('setPosition', locParam)
                        that.getNearbyShopList()
                        that.$isResolve()
                     },
                     fail: (err) => {