MrShi
2026-04-21 463b129b1011652af4d4261da4e2797e04198f2f
small-program/pages/itinerary/itinerary.vue
@@ -25,179 +25,196 @@
      <view class="content-wrap">
         <view class="page-padding card-list">
            <view v-for="(item, index) in visibleOrders" :key="item.id" class="order-card">
            <view v-for="(item, index) in dataList" :key="item.id" class="order-card">
               <view class="order-head" :class="item.mode === 'city' ? 'city-head-bg' : 'local-head-bg'">
                  <view v-if="item.mode === 'local'" class="head-local">
                  <view v-if="item.type === 0" class="head-local">
                     <view class="mode-tag local-tag">就地寄存</view>
                     <view class="head-copy single-copy">
                        <text class="head-name text-ellipsis">{{ item.fromName }}</text>
                        <text class="head-user">{{ item.userName }}</text>
                        <text class="head-name text-ellipsis">{{ item.depositShopName||'' }}</text>
                        <text class="head-user">{{ item.takeUser ||'' }}</text>
                     </view>
                  </view>
                  <view v-else class="head-city">
                     <view class="head-copy city-left">
                        <view class="mode-tag city-tag">同城寄送</view>
                        <text class="head-name text-ellipsis">{{ item.fromName }}</text>
                        <text class="head-user">{{ item.userName }}</text>
                        <text class="head-name text-ellipsis">{{ item.depositShopName || '' }}</text>
                        <text class="head-user">{{ item.takeUser||'' }}</text>
                     </view>
                     <view class="city-arrow">
                        <view class="arrow-line"></view>
                        <view class="arrow-head"></view>
                     </view>
                     <view class="head-copy city-right align-right">
                        <text class="status-text" v-if="index === 1">{{ item.status }}</text>
                        <text class="head-name text-ellipsis">{{ item.toName }}</text>
                        <text class="head-user">{{ item.userName }}</text>
                        <text class="status-text">{{ item.statusName||'待发货' }}</text>
                        <text class="head-name text-ellipsis">{{ item.takeShopName||'对对对' }}</text>
                        <text class="head-user">{{ item.takeUser||'' }}</text>
                     </view>
                  </view>
                  <text class="status-text" v-if="index === 0">{{ item.status }}</text>
               </view>
               <view class="goods-area">
                  <view v-for="goods in item.goods" :key="goods.name" class="goods-row">
               <view class="goods-area" v-if="item.detailList">
                  <view v-for="goods in item.detailList " :key="goods.luggageName" class="goods-row">
                     <view class="goods-left">
                        <text class="goods-name">{{ goods.name }}</text>
                        <text class="goods-size">{{ goods.size }}</text>
                        <text class="goods-name">{{ goods.luggageName ||'' }}</text>
                        <text class="goods-size">{{ goods.luggageDetail || '' }}</text>
                     </view>
                     <view class="goods-right">
                        <text class="goods-price">{{ goods.price }}</text>
                        <text class="goods-count">x1</text>
                        <text class="goods-price">{{((goods.subtotal || 0)/100).toFixed(2) }}</text>
                        <text class="goods-count">x{{ goods.num || 1}}</text>
                     </view>
                  </view>
               </view>
               <view class="amount-area">
                  <view class="pay-row">
                     <text class="pay-label">实付款:</text>
                     <text class="pay-value">{{ item.payAmount }}</text>
                     <text class="pay-value">{{((item.estimatedAmount || 0)/100).toFixed(2) }}</text>
                  </view>
                  <view class="insurance-row">
                     <text class="insurance-label">含行李保费:</text>
                     <text class="insurance-value">{{ item.insurance }}</text>
                     <text class="insurance-value">{{((item.declaredFee || 0)/100).toFixed(2) }}</text>
                  </view>
               </view>
               <view class="card-footer">
                  <view class="pickup-wrap" v-if="item.pickupTime">
                  <view class="pickup-wrap" v-if="item.expectedTakeTime">
                     <text class="pickup-label">预计取件时间:</text>
                     <text class="pickup-value">{{ item.pickupTime }}</text>
                     <text class="pickup-value">{{ item.expectedTakeTime ||'' }}</text>
                  </view>
                  <view class="pickup-wrap" v-else></view>
                  <view class="footer-actions">
                     <view class="footer-btn contact-btn">联系门店</view>
                     <view class="footer-btn primary-btn">{{ item.actionText }}</view>
<!--                      <view class="footer-btn contact-btn">联系门店</view>
 -->                  <view class="footer-btn contact-btn" v-if="item.status ===0">取消订单</view>
                     <view class="footer-btn primary-btn" v-if="item.status ===0">立即支付</view>
                     <view class="footer-btn contact-btn" v-if="item.status ===1">联系门店</view>
                     <view class="footer-btn primary-btn" v-if="item.status ===1">申请退款</view>
                  </view>
               </view>
            </view>
            <view v-if="isLoadingMore" class="loading-text">加载中...</view>
            <view v-else-if="!hasMore && visibleOrders.length" class="loading-text">没有更多了</view>
            <view v-else-if="!hasNext && dataList.length" class="loading-text">没有更多了</view>
         </view>
      </view>
      <custom-tabbar></custom-tabbar>
   </view>
</template>
<script>
   import { mapState } from 'vuex'
   import CustomTabbar from '@/components/custom-tabbar/custom-tabbar.vue'
   const baseOrders = [
      {
         id: 1,
         mode: 'local',
         status: '待核验',
         statusKey: 'verify',
         fromName: '中铁快运南站旗舰店',
         userName: '蔡子瑄',
         goods: [
            { name: '大件行李箱', size: '24-28寸', price: '¥35' },
            { name: '中件行李箱', size: '24-28寸', price: '¥35' },
            { name: '小件行李箱', size: '24-28寸', price: '¥35' }
         ],
         payAmount: '¥125.00',
         insurance: '¥20',
         pickupTime: '2026-04-12 10:10',
         actionText: '申请退款'
      },
      {
         id: 2,
         mode: 'city',
         status: '待核验',
         statusKey: 'verify',
         fromName: '中铁快运南站旗舰店',
         toName: '丽枫酒店34...',
         userName: '蔡子瑄',
         goods: [
            { name: '大件行李箱', size: '24-28寸', price: '¥35' },
            { name: '中件行李箱', size: '24-28寸', price: '¥35' }
         ],
         payAmount: '¥90.00',
         insurance: '¥20',
         pickupTime: '',
         actionText: '申请退款'
      }
   ]
   export default {
      components: {
         CustomTabbar
      },
      onReachBottom() {
         this.loadMore()
      },
      computed: {
         ...mapState(['navHeight', 'statusbarHeight']),
         filteredOrders() {
            if (this.activeTab === 'all') {
               return this.orders
            }
            return this.orders.filter(item => item.statusKey === this.activeTab)
         },
         visibleOrders() {
            return this.filteredOrders.slice(0, this.pageSize)
         },
         hasMore() {
            return this.pageSize < this.filteredOrders.length
         }
         ...mapState(['navHeight', 'statusbarHeight'])
      },
      data() {
         return {
            activeTab: 'all',
            pageSize: 4,
            activeTab: -1,
            pageSize: 10,
            currentPage: 1,
            total:0,
            hasNext:true,
            userType: 0,
            isLoadingMore: false,
            filterTabs: [
               { label: '全部', value: 'all' },
               { label: '待支付', value: 'pending' },
               { label: '待核验', value: 'verify' },
               { label: '待配送', value: 'delivery' },
               { label: '待收货', value: 'receive' },
               { label: '待核验', value: 'verify' },
               { label: '待配送', value: 'delivery' },
               { label: '待收货', value: 'receive' }
               { label: '全部'  ,value: -1},
               { label: '待支付',value: 0 },
               { label: '待核验', value: 1},
               { label: '待配送', value: 2 },
               { label: '待收货', value: 3},
               { label: '已完成', value: 4},
               { label: '已退款', value: 5}
            ],
            orders: [
               ...baseOrders,
               ...baseOrders.map((item, index) => ({ ...item, id: item.id + (index + 1) * 10 })),
               ...baseOrders.map((item, index) => ({ ...item, id: item.id + (index + 1) * 20 }))
            ]
            dataList: []
         }
      },
      watch: {
         activeTab() {
            this.pageSize = 4
           this.getFirstPageData()
         }
      },
      methods: {
         loadMore() {
            if (!this.hasMore || this.isLoadingMore) {
               return
      onLoad(options) {
         console.log(options )
         this.activeTab = -1
         if (options.status) {
            this.activeTab =  Number(options.status)
         }
         this.getFirstPageData()
         var that =this
         uni.$on('updateOrder',function(data){
            console.log('监听到事件来自 update ,携带参数 msg 为:' ,data);
            if(data.delete == 1){
               //删除订单,强制刷新数据
               that.getFirstPageData()
            }else if(data.info!=null && data.info.orderId!=null){
                 console.log('监听到事件来自 update 01:' ,data);
               that.dataList.forEach((item,index)=>{
                  if(item.id==data.info.orderId){
                      console.log('监听到事件来自 update 02:' ,data);
                     item.status = data.info.orderStatus
                  }
               })
            }
            this.isLoadingMore = true
            setTimeout(() => {
               this.pageSize += 2
               this.isLoadingMore = false
            }, 300)
          })
      },
      onShow() {
         // this.showDone=false
         // this.showCancel=false
         // this.showDelete=false
         // this.showQrcode=false
         // this.showPay=false
         // this.showPhone=false
         this.loading=false,
         this.currentOrder=null
      },
      onReachBottom(){
         this.getDataList();
      },
      methods: {
         getFirstPageData(){
            this.currentPage = 0
            this.hasNext=true
            this.total=0
            this.dataList=[]
            this.getDataList()
         },
         async getDataList(){
               if(this.loading || !this.hasNext){
                  return
               }
               this.loading=true
               this.currentPage =   this.currentPage+1
               if(this.currentPage == 1){
                  this.hasNext =true
                  this.dataList=[]
               }
               var that =this
               let res ={};
               res = await that.$u.api.myOrderPage({
                     capacity:10,
                     model: {
                        combinedStatus: this.activeTab == -1?'':this.activeTab
                     },
                     page:this.currentPage
                  });
               console.log(res)
               if (res.code === 200 ) {
                  if ( res.data && res.data.page ===this.currentPage) {
                     res.data.records = res.data.records||[]
                      that.dataList.push(...res.data.records)
                      that.total=res.data.total
                      if( this.currentPage >= res.data.pageCount||0){
                         that.hasNext=false
                      }else{
                         that.hasNext=true
                      }
                  }
               }
               this.loading=false
         },
         jumpOrderDetail(id){
            uni.navigateTo({
               url:'/pages/details-entry/details-entry?userType='+this.userType+'&id='+id
            })
         }
      }
   }