MrShi
2025-07-18 6513c0b26da5896a462b89dbd0241aafb838f120
small-program/pages/index/index.vue
@@ -11,14 +11,12 @@
         <view class="search" :style="{ top: statusbarHeight + navHeight + 'px' }">
            <view class="index-j-cate">
               <view class="index-j-cate-item" v-for="(item, index) in searchType" :key="index" @click="clickCate(item.id)">
                  <text :style="{ color: typeVal === item.id ? '##222222' : '' }">{{item.name}}</text>
                  <text :style="{ color: typeVal === item.id ? '#222222' : '', fontSize: typeVal === item.id ? '36rpx' : '', fontWeight: typeVal === item.id ? '600' : '' }">{{item.name}}</text>
                  <view class="index-j-cate-item-x" v-if="typeVal === item.id"></view>
               </view>
            </view>
            <view class="index-j-search">
               <view class="index-j-search-item active">最新发布</view>
               <view class="index-j-search-item">距离优先</view>
               <view class="index-j-search-item">价格从高到低</view>
               <view :class="sortType === item.id ? 'index-j-search-item active' : 'index-j-search-item'" v-for="(item, index) in sortList" :key="index" @click="clickSort(item.id)">{{item.name}}</view>
            </view>
         </view>
         <view class="index-j-list">
@@ -40,31 +38,43 @@
                  {{item.categoryName}}|{{item.priceNum1}}斤
               </view>
               <view class="index-list-item-info" v-if="item.type === 0 && item.workType === 1">
                  {{item.categoryName}}|{{item.priceNum1}}斤
                  {{item.categoryName}}|{{item.priceNum1}}人
               </view>
               <view class="index-list-item-info" v-if="item.type === 0 && item.workType === 2">
                  {{item.categoryName}}|{{item.priceNum1}}斤
                  {{item.categoryName}}|{{item.priceNum1}}人
               </view>
               <view class="index-list-item-info" v-if="item.type === 1">
                  {{item.categoryName}}|{{item.priceNum1}}斤
                  {{item.transportTypeName}} | {{item.transportNum}}{{item.transportUnit}}|用车{{item.priceNum1}}天
               </view>
               <view class="index-list-item-info" v-if="item.type === 2">
                  {{item.wayInfoCopy}}
               </view>
               <view class="index-list-item-dz">
                  <image src="/static/icon/order_ic_location@2x.png" mode="widthFix"></image>
                  <text>{{item.location}}</text>
               <view class="address" v-if="item.type === 1">
                  <view class="address-xian"></view>
                  <view class="address-row" v-for="(address, i) in item.wayInfo" :key="i">
                     <image src="/static/icon/ic_qidian@2x.png" mode="widthFix" v-if="i === 0"></image>
                     <image src="/static/icon/ic_jingguo@2x.png" mode="widthFix" v-else-if="i !== 0 && i !== item.wayInfo.length - 1"></image>
                     <image src="/static/icon/ic_zhongdian@2x.png" mode="widthFix" v-else-if="i === item.wayInfo.length - 1"></image>
                     <text>{{item.location}}</text>
                  </view>
               </view>
               <view class="index-list-item-dz">
                  <image src="/static/icon/order_ic_time@2x.png" mode="widthFix"></image>
                  <text>{{item.startDate}} 至 {{item.endDate}}({{item.priceNum1}}天)</text>
               </view>
               <template v-if="[0, 2].includes(item.type)">
                  <view class="index-list-item-dz">
                     <image src="/static/icon/order_ic_location@2x.png" mode="widthFix"></image>
                     <text>{{item.location}}</text>
                  </view>
                  <view class="index-list-item-dz">
                     <image src="/static/icon/order_ic_time@2x.png" mode="widthFix"></image>
                     <text>{{item.startDate}} 至 {{item.endDate}}({{item.priceNum1}}天)</text>
                  </view>
               </template>
               <view class="index-list-item-price">
                  <text>预估:</text>
                  <text>¥{{item.estimatedAccount / 100}}</text>
               </view>
               <view class="eidt">
                  <sunui-mverify @change="mverify($event, item.id)"></sunui-mverify>
                  <sunui-mverify @change="getaccept($event, item.id, index)"></sunui-mverify>
               </view>
            </view>
         </view>
@@ -311,7 +321,7 @@
   export default {
      components: { sunuiMverify },
      computed: {
         ...mapState(['navHeight', 'statusbarHeight','userInfo','token','openid']),
         ...mapState(['navHeight', 'statusbarHeight','userInfo','token','openid', 'latitude', 'longitude']),
         totalPrice() {
            return this.form.estimatedAccount / 100
         }
@@ -346,6 +356,11 @@
               { name: '分拣工', id: 1 },
               { name: '包装工', id: 2 }
            ],
            sortList: [
               { name: '最新发布', id: 0 },
               { name: '距离优先', id: 1 },
               { name: '价格从高到低', id: 2 }
            ],
            car: [],
            btn: require('@/static/image/btn.png'),
            typeViewId: 0,
@@ -375,13 +390,15 @@
               estimatedAccount: '',
               price: ''
            },
            sortType: 0,
            orderList: [],
            typeVal: '',
            page: 1
            page: 1,
            next: true
         }
      },
      onLoad() {
      async onLoad() {
         await this.$onLaunched;
         this.getCategoryLists()
         this.getOrderList()
         this.form.linkPhone = this.userInfo.telephone
@@ -389,29 +406,23 @@
      watch: {
         typeId: {
            handler(news, old) {
               this.form = {
                  startDate: '',
                  endDate: '',
                  latitude: '',
                  longitude: '',
                  location: '',
                  locationEnd: '',
                  wayInfoDTOList: [],
                  workType: 0,
                  categoryId: '',
                  categoryName: '',
                  days: '',
                  locationRemark: '',
                  supplement: '',
                  multifileList: [],
                  linkName: '',
                  linkPhone: '',
                  estimatedAccount: '',
                  price: ''
               }
               this.form.startDate = ''
               this.form.endDate = ''
               this.form.latitude = ''
               this.form.longitude = ''
               this.form.location = ''
               this.form.locationEnd = ''
               this.form.wayInfoDTOList = ''
               this.form.workType = ''
               this.form.days = ''
               this.form.locationRemark = ''
               this.form.supplement = ''
               this.form.multifileList = []
               this.form.linkName = ''
               this.form.estimatedAccount = ''
               this.form.price = ''
               this.viewStatus = false
               this.carImage = ''
               this.carRemark = ''
            }
         },
         orderFood: {
@@ -440,21 +451,49 @@
            }
         }
      },
      onReachBottom() {
         this.getOrderList()
      },
      methods: {
         // 手动接单
         getaccept(e, orderId, index) {
            this.$u.api.accept({ orderId })
               .then(res => {
                  uni.showToast({ title: '抢单成功!', icon: 'success', duration: 2000 })
                  setTimeout(() => {
                     this.page = 1
                     this.next = true
                     this.orderList = []
                     this.getOrderList()
                  }, 2000)
               })
         },
         clickSort(id) {
            this.sortType = id
            this.page = 1
            this.next = true
            this.orderList = []
            this.getOrderList()
         },
         clickCate(id) {
            this.typeVal = id
            this.page = 1
            this.list = []
            this.next = true
            this.orderList = []
            this.getOrderList()
         },
         // 订单分页
         getOrderList() {
            if (!this.next) return;
            this.$u.api.orderPage({
               capacity: 10,
               page: this.page,
               model: {
                  queryMyOrderType: 2,
                  type: this.typeVal
                  type: this.typeVal,
                  sortType: this.sortType,
                  queryLat: this.latitude,
                  queryLgt: this.longitude
               }
            }).then(res => {
               res.data.records.forEach(item => {
@@ -463,10 +502,16 @@
                     item.wayInfoCopy = JSON.parse(item.wayInfo).map(item => {
                        return `${item.name}${item.price / 100}元(${item.num}份)`
                     }).join(' | ')
                  // 运货
                  } else if (item.type === 1) {
                     item.wayInfo = JSON.parse(item.wayInfo)
                  }
               })
               console.log(res.data.records)
               this.orderList = [...this.orderList, ...res.data.records]
               if (this.orderList.length === res.data.total) {
                  this.next = false
               }
            })
         },
         // 提交订单
@@ -604,6 +649,12 @@
         },
         clickType(e) {
            this.typeId = e
            if (e === 2) {
               this.form.categoryId = this.car[0].id
               this.form.categoryName = this.car[0].name
               this.carRemark = this.car[0].remark
               this.carImage = this.car[0].iconFull
            }
         },
         clickTypeWork(e) {
            this.form.workType = e
@@ -681,9 +732,6 @@
                  url: `/pages/freight/freight`
               })
            }
         },
         mverify(e, id){
            console.log('验证结果:', e, id);
         },
         // 选择套餐
         selectMenu(a, b) {