rk
2026-04-22 2e3ab7fbbb336cf11ed37b8b0a7871976d597564
small-program/pages/index/index.vue
@@ -4,14 +4,14 @@
      <view class="top-hero">
         <view :style="{ height: statusbarHeight + 'px' }"></view>
         <view class="hero-bar" :style="{ height: navHeight + 'px' }">
            <view class="location-chip" @tap="handleLocation">
            <view class="location-chip" @click="chooseLocation">
               <image src="/static/icon/home1_ic_location@2x.png" mode="aspectFit"></image>
               <text>{{ currentAddress }}</text>
               <u-icon name="arrow-right" size="14" color="#ffffff"></u-icon>
            </view>
         </view>
         <view class="search-box" @tap="goStoragePage">
         <view class="search-box" @click="goStoragePage">
            <image src="/static/icon/home_ic_search@2x.png" mode="aspectFit"></image>
            <text class="search-text">搜索寄存点名称或地址</text>
         </view>
@@ -115,13 +115,21 @@
      async onLoad() {
         await this.$onLaunched
         await this.getBannerList()
         await this.getNearbyShopList()
         if (this.cityId && this.latitude && this.longitude) {
            await this.getNearbyShopList()
         }
      },
      onReachBottom() {
         this.getNearbyShopList()
         if (this.cityId && this.latitude && this.longitude) {
            this.getNearbyShopList()
         }
      },
      methods: {
         jumpxiadan() {
            if (!this.cityId) return uni.showToast({
               title: '当前城市暂未开通',
               icon: 'none'
            })
            uni.navigateTo({
               url: '/pages/luggage-storage/luggage-storage'
            })
@@ -153,6 +161,10 @@
            }
         },
         jumpJC() {
            if (!this.cityId) return uni.showToast({
               title: '当前城市暂未开通',
               icon: 'none'
            })
            uni.navigateTo({
               url: '/pages/storage-point/storage-point'
            })
@@ -164,6 +176,59 @@
                  if (res.authSetting['scope.userLocation']) {
                     that.positioning()
                  }
               }
            });
         },
         chooseLocation() {
            var that = this;
            uni.chooseLocation({
               type: 'gcj02',
               success: async function(addr) {
                  if (addr.errMsg === 'chooseLocation:ok' && addr.latitude) {
                     const locParam = { latitude: addr.latitude, longitude: addr.longitude };
                     // uni.setStorageSync('address', locParam);
                     var myAmapFun = new amapFile.AMapWX({ key: 'e4d46c87adf151dca20060317592b1b6' });
                     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.regeocodeData.addressComponent.city && typeof info.regeocodeData.addressComponent.city === 'string')
                              ? info.regeocodeData.addressComponent.city
                              : info.regeocodeData.addressComponent.province;
                           var ta = info.name || '地址获取失败';
                           locParam.address = ta
                           const resCity = await that.$u.api.getCityByName({ cityName: locParam.city })
                           if (resCity.code === 200 && resCity.data) {
                              locParam.cityId = resCity.data.id
                              that.$store.commit('setPosition', locParam)
                              that.page = 1
                              that.pointList = []
                              that.isRequest = true
                              that.getNearbyShopList()
                           } else {
                              that.$store.commit('setPosition', locParam)
                              that.$store.commit('clearCityId')
                              that.page = 1
                              that.pointList = []
                              that.isRequest = true
                           }
                        },
                        fail: function(err) {
                           console.error('获取位置失败===========', err);
                           that.$store.commit('setPosition', locParam)
                           that.page = 1
                           that.pointList = []
                           that.isRequest = true
                           // that.getNearbyShopList()
                        }
                     });
                  }
               },
               fail: function(err) {
                  console.error('选择位置失败===========', err);
               }
            });
         },
@@ -203,6 +268,10 @@
            });
         },
         goStoragePage() {
            if (!this.cityId) return uni.showToast({
               title: '当前城市暂未开通',
               icon: 'none'
            })
            uni.navigateTo({
               url: '/pages/storage-point/storage-point'
            })