MrShi
2026-04-28 f422860fe7e521f4d252e5d77621d92d7f8dfe61
small-program/pages/index/index.vue
@@ -1,17 +1,17 @@
<template>
   <view class="index-page">
      <view class="top-gradient-bg" :style="{ backgroundImage: 'url(' + backgroundImage + ')' }"></view>
      <image class="top-gradient-bg" src="/static/image/bg_home@2x.png" mode="aspectFill"></image>
      <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>
@@ -30,18 +30,18 @@
            <view class="service-card deposit-card" @click="jumpxiadan">
               <image class="service-image" src="/static/image/home_ic_jicun@2x.png" mode="aspectFit"></image>
            </view>
            <view class="service-card retrieve-card">
            <view class="service-card retrieve-card"  @click="jumpOrderList(3)">
               <image class="service-image" src="/static/image/home_ic_qujian@2x.png" mode="aspectFit"></image>
            </view>
         </view>
         <view class="notice-card">
         <view class="notice-card" v-if="ingOrder && ingOrder.orderId" @click="jumpOrderDetail(ingOrder.orderId)">
            <view class="notice-icon-wrap">
               <image src="/static/icon/home_ic_daizhifu@2x.png" mode="aspectFit"></image>
            </view>
            <view class="notice-copy">
               <text class="notice-title">待支付</text>
               <text class="notice-text">请在 10 分钟内完成支付,超时订单将自动取消</text>
               <text class="notice-title">{{ingOrder.statusDesc || ''}}</text>
               <text class="notice-text">{{ingOrder.tip || ''}}</text>
            </view>
         </view>
@@ -52,20 +52,20 @@
         <view class="recommend-list">
            <template v-if="pointList.length > 0">
               <view v-for="(item, index) in pointList" :key="index" class="point-card" @click="goStoragePage(item)">
               <view v-for="(item, index) in pointList" :key="index" class="point-card" @click="goShopDetails(item)">
                  <view class="point-thumb">
                     <image class="point-thumb-image" :src="item.coverImg" mode="widthFix"></image>
                  </view>
                  <view class="point-main">
                     <view class="point-head">
                        <text class="point-name">{{ item.name }}</text>
                        <text class="point-distance">{{ item.distanceText }}</text>
                        <text class="point-name">{{ item.name ||'' }}</text>
                        <text class="point-distance">{{ item.distanceText  ||''}}</text>
                     </view>
                     <view class="point-address">
                        <image src="/static/icon/home_ic_location3@2x.png" mode="aspectFit"></image>
                        <text>{{ item.address }}</text>
                        <text>{{ item.address ||''}}</text>
                     </view>
                     <text class="point-time">{{ item.shopHours }}</text>
                     <text class="point-time">{{ item.shopHours ||'' }}</text>
                  </view>
               </view>
            </template>
@@ -105,23 +105,46 @@
      },
      data() {
         return {
            backgroundImage: require('@/static/image/bg_home@2x.png'),
            bannerList: [],
            pointList: [],
            page: 1,
            isRequest: true
            ingOrder: null
         }
      },
      async onLoad() {
         await this.$onLaunched
         await this.getBannerList()
         await this.getNearbyShopList()
         if (this.cityId && this.latitude && this.longitude) {
            await this.getNearbyShopList()
         }
      },
      onReachBottom() {
         this.getNearbyShopList()
      onShow() {
         this.ingOrder =null
         this.getIngorder()
      },
      methods: {
         jumpOrderDetail(id){
            uni.navigateTo({
               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){
            uni.setStorageSync("orderStatus",status)
            uni.switchTab({
               url: '/pages/itinerary/itinerary'
            })
         },
         jumpxiadan() {
            if (!this.cityId) return uni.showToast({
               title: '当前城市暂未开通',
               icon: 'none'
            })
            uni.navigateTo({
               url: '/pages/luggage-storage/luggage-storage'
            })
@@ -133,10 +156,9 @@
            }
         },
         async getNearbyShopList() {
            if (!this.isRequest) return;
            const res = await this.$u.api.getNearbyShopList({
               capacity: 10,
               page: this.page,
               capacity: 5,
               page: 1,
               model: {
                  latitude: this.latitude,
                  longitude: this.longitude,
@@ -146,13 +168,13 @@
            })
            if (res.code === 200) {
               this.pointList = res.data.records || []
               this.page++
               if (res.data.total <= this.pointList.length) {
                  this.isRequest = false
               }
            }
         },
         jumpJC() {
            if (!this.cityId) return uni.showToast({
               title: '当前城市暂未开通',
               icon: 'none'
            })
            uni.navigateTo({
               url: '/pages/storage-point/storage-point'
            })
@@ -164,6 +186,53 @@
                  if (res.authSetting['scope.userLocation']) {
                     that.positioning()
                  }
               }
            });
         },
         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.city = (info.regeocodeData.addressComponent.city && typeof info.regeocodeData.addressComponent.city === 'string')
                              ? info.regeocodeData.addressComponent.city
                              : info.regeocodeData.addressComponent.province;
                           var ta = addr.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.pointList = []
                              that.getNearbyShopList()
                           } else {
                              that.$store.commit('setPosition', locParam)
                              that.$store.commit('clearCityId')
                              that.pointList = []
                              that.getNearbyShopList()
                           }
                        },
                        fail: function(err) {
                           console.error('获取位置失败===========', err);
                           that.$store.commit('setPosition', locParam)
                           that.pointList = []
                           that.getNearbyShopList()
                        }
                     });
                  }
               },
               fail: function(err) {
                  console.error('选择位置失败===========', err);
               }
            });
         },
@@ -202,7 +271,16 @@
               }
            });
         },
         goShopDetails(item){
            uni.navigateTo({
               url: '/pages/storage-point-detail/storage-point-detail?id='+item.id
            })
         },
         goStoragePage() {
            if (!this.cityId) return uni.showToast({
               title: '当前城市暂未开通',
               icon: 'none'
            })
            uni.navigateTo({
               url: '/pages/storage-point/storage-point'
            })