doum
2025-09-15 82735e4d46ac7b9969facef2acc8f8e793b68f71
small-program/pages/demand-hall/demand-hall.vue
@@ -18,18 +18,18 @@
         <!-- 发单方 -->
         <view class="index-labs" v-if="typeViewId === 0" :style="{ top: statusbarHeight + navHeight + 'px' }">
            <scroll-view scroll-x class="scroll-view_H" :scroll-into-view="'view'+status">
               <view :class="item.id === status ? 'index-labs-row active' : 'index-labs-row'" v-for="(item, index) in list1" :id="'view'+item.id" :key="item.id" @click="clickOrderType(item.id)">
               <view :class=" item.id === status ? 'index-labs-row active' : 'index-labs-row'" v-for="(item, index) in list1" :id="'view'+item.id" :key="item.id" @click="clickOrderType(item.id)">
                  {{item.name}}
                  <view class="index-labs-row-x" v-if="item.id === status"></view>
                  <view class="index-labs-row-x" v-if=" item.id === status"></view>
               </view>
            </scroll-view>
         </view>
         <!-- 接单方 -->
         <view class="index-labs" v-if="typeViewId === 1" :style="{ top: statusbarHeight + navHeight + 'px' }">
            <scroll-view scroll-x class="scroll-view_H" :scroll-into-view="'view'+status">
               <view :class="item.id === status ? 'index-labs-row active' : 'index-labs-row'" v-for="(item, index) in list" :id="'view'+item.id" :key="item.id" @click="clickOrderType(item.id)">
               <view :class=" item.id === status ? 'index-labs-row active' : 'index-labs-row'" v-for="(item, index) in list" :id="'view'+item.id" :key="item.id" @click="clickOrderType(item.id)">
                  {{item.name}}
                  <view class="index-labs-row-x" v-if="item.id === status"></view>
                  <view class="index-labs-row-x" v-if=" item.id === status "></view>
               </view>
            </scroll-view>
         </view>
@@ -63,13 +63,13 @@
                  {{item.categoryName}}|{{item.priceNum2}}人
               </view>
               <view class="index-list-item-info" v-if="item.type === 0 && item.workType === 2&& item.carType === 0">
                  {{item.categoryName}}|{{item.priceNum1}}天 |{{item.priceNum2}}人
                  {{item.categoryName}}|{{item.priceNum1}}天 | {{item.priceNum2}}人
               </view>
               <view class="index-list-item-info" v-if="item.type === 0 && item.workType === 2&& item.carType === 1">
                  {{item.categoryName}}|{{item.priceNum1}}小时 |{{item.priceNum2}}人
                  {{item.categoryName}}|{{item.priceNum1}}小时 | {{item.priceNum2}}人
               </view>
               <view class="index-list-item-info" v-if="item.type === 0 && item.workType === 2&& item.carType === 2">
                  {{item.categoryName}}|{{item.priceNum1}}斤
                  {{item.categoryName}}|{{item.priceNum1}}斤 | {{item.priceNum2}}人
               </view>
               <view class="index-list-item-info" v-if="item.type === 1">
                  {{item.carUnit}} | {{item.transportTypeName}} | {{item.transportNum}}{{item.transportUnit}}|用车{{item.priceNum1}}{{item.carType === 0?"天":"次"}}
@@ -232,9 +232,9 @@
      },
      async onShow(options) {
         var flag = getApp().globalData.orderStatus
            console.log(getApp().globalData,"=====================================")
         this.status = ''
         this.commentStatus=''
         console.log(getApp().globalData,"=====================================")
         // this.status = ''
         // this.commentStatus=''
         // status: this.status === 5 ? 4 : this.status,
         // commentStatus: this.status === 5 ? 0 : '',
         if(flag =='1'){//发单方待接单
@@ -242,47 +242,69 @@
         }else if(flag =='2'){//发单方进行中
            this.status = 3 
         }else if(flag =='3'){//发单方待评价
            this.status = 5
            this.status = 6
         }else if(flag =='4'){//接单方已接单
            this.status =2            
         }else if(flag =='5'){//接单方进行中
            this.status =3   
         }else if(flag =='6'){//接单方已完成
            this.status =4
         }else if(flag =='0'){
            this.status = -1
         }
         console.log(getApp().globalData,this.status ,"=====================================")
         this.typeViewId = 0
         if(this.token && this.token != '' && this.userInfo && JSON.stringify(this.userInfo) != '{}'){
            console.log('已登陆')
            this.isLogin = true
            if (this.userInfo && this.userInfo.useIdentity == 1) {
               this.typeViewId = 1
            }
         /*    this.getOrderList()
            if (!this.isOnce) {
               this.commentStatus = ''
               this.orderList = []
               this.next = true
               this.page = 1
               this.getOrderList()
            }
            } */
         } else {
            this.isLogin = false
            console.log('未登陆')
         }
         if(this.isLogin){
            if(this.typeViewId !== this.userInfo.useIdentity || flag !=null){
               this.typeViewId = this.userInfo.useIdentity || 0
               //如果发生
               this.initOrderList()
            }else{
               //如果未发生变化不刷新
               this.typeViewId = this.userInfo.useIdentity || 0
               if(!this.orderList || !this.orderList.length){
                  this.initOrderList()
               }else{
                  if( this.tempOrderId){
                     this.getOrderData()
                  }
               }
               console.log('this.tempOrderId',this.tempOrderId)
            }
         }
         getApp().globalData.orderStatus =null
      },
      data() {
         return {
            show: false,
            isLogin: false,
            typeViewId: 0,
            typeViewId: -1,
            tempOrderId:null,
            list: [
               { name: '全部', id: '' },
               { name: '全部', id: -1 },
               { name: '已接单', id: 2 },
               { name: '进行中', id: 3 },
               { name: '待支付', id: 5 },
               { name: '已完成', id: 4 },
               // { name: '已取消', id: 99 },
            ],
            list1: [
               { name: '全部', id: '' },
               { name: '全部', id: -1 },
               { name: '待支付', id: 0 },
               { name: '待接单', id: 1 },
               { name: '已接单', id: 2 },
@@ -292,9 +314,8 @@
               { name: '待评价', id: 6 }
            ],
            orderId: null,
            status: '',
            commentStatus: '',
            status: -1,
            commentStatus: '',
            next: true,
            page: 1,
            orderList: [],
@@ -303,7 +324,7 @@
      },
      async onLoad() {
         await this.$onLaunched;
         uni.$on('refresh', (data) => {
         /* uni.$on('refresh', (data) => {
            console.log('我的订单页刷新');
            this.status = ''
            this.commentStatus = ''
@@ -311,17 +332,26 @@
            this.next = true
            this.page = 1
            this.getOrderList()
         })
         this.getOrderList()
         }) */
      },
      onReachBottom() {
         this.getOrderList()
         if(this.isLogin){
            this.getOrderList()
         }
      },
      methods: {
         toLogin() {
            uni.navigateTo({
               url: '/pages/login/login'
            })
         },
         initOrderList() {
            this.commentStatus = ''
            this.orderList = []
            this.next = true
            this.page = 1
            this.getOrderList()
         },
         startJobs(orderId) {
            this.$u.api.begin({ orderId })
@@ -341,9 +371,11 @@
            uni.navigateTo({
               url: `/pages/order-details/order-details?id=${item.id}&flag=${flag}`
            })
            this.tempOrderId = item.id
         },
         // 修改
         jumpEdit(item) {
            this.tempOrderId =item.id
            if (item.type === 0 && item.workType === 0) {
               uni.navigateTo({
                  url: `/pages/using-workers/using-workers?id=${item.id}`
@@ -372,14 +404,49 @@
                  this.next = true
                  this.page = 1
                  this.getOrderList()
               }
               }
            })
         },
         phoneCall(phoneNumber) {
            uni.makePhoneCall({
               phoneNumber
            });
         },
         getOrderData(){
            var that = this
            var param ={ orderId:that.tempOrderId}
            this.$u.api.getDetail(param).then(res =>{
               if(res.code ===200 && res.data){
                  var isDel = false
                  var tempIndex = -1
                  that.orderList.forEach((item,index) =>{
                     if(item.id == res.data.id){
                        item.status = res.data.status
                        item.isUpdate = res.data.isUpdate
                        item.commentStatus = res.data.commentStatus
                        tempIndex = index
                     }
                  })
                  if(tempIndex > -1 ){
                     console.log(tempIndex,that.status,res.data.status,"===================")
                     if(that.status >=0 ){
                        //如果有标签页
                        if(that.status ===6 && res.data.commentStatus == 1){
                           isDel =true
                           console.log(tempIndex,that.status,res.data.status,"==================1")
                        }else if(that.status !=6 && that.status !== res.data.status){
                           isDel =true
                           console.log(tempIndex,that.status,res.data.status,"===================2")
                        }
                     }
                     if(isDel){
                        console.log(tempIndex,that.status,res.data.status,"===================3")
                        that.orderList.splice(tempIndex,1)
                     }
                  }
               }
             })
         },
         // 订单分页
         getOrderList() {
@@ -389,7 +456,7 @@
               page: this.page,
               model: {
                  queryMyOrderType: this.userInfo.useIdentity,
                  status: this.status === 6 ? 4 : this.status,
                  status:  this.status === 6 ? 4 : (this.status ==-1?"":this.status),
                  commentStatus: this.status === 6 ? 0 : '',
                  queryLat: this.latitude,
                  queryLgt: this.longitude
@@ -408,23 +475,17 @@
                     item.wayInfo = JSON.parse(item.wayInfo)
                  }
               })
               this.orderList = [...this.orderList, ...res.data.records]
               if (this.orderList.length === res.data.total) {
               this.orderList = [...this.orderList, ...res.data.records]
               if (this.orderList.length >= res.data.total) {
                  this.next = false
               } else {
                  this.page += 1
               }
            })
         },
         clickOrderType(id) {
            // if (typeof id === 5) {
            //    this.status = 5
            //    // this.commentStatus = 0
            // } else {
               this.commentStatus = ''
               this.status = id
            // }
         clickOrderType(id) {
            this.commentStatus = ''
            this.status = id
            this.orderList = []
            this.next = true
            this.page = 1