rk
2025-08-27 58d63637b67a7c565618379268da604e6231fc4c
small-program/pages/index/index.vue
@@ -1,7 +1,7 @@
<template>
   <view class="index">
      <!-- 接单方 -->
      <view class="index-j" v-if="typeViewId === 1">
      <view class="index-j" v-if="userInfo && userInfo.useIdentity === 1">
         <view class="index-j-head">
            <view :style="{ width: '100%', height: statusbarHeight + 'px' }"></view>
            <view class="index-c-title" :style="{ height: navHeight + 'px' }">
@@ -74,14 +74,15 @@
                  <text>¥{{item.estimatedAccount / 100}}</text>
               </view>
               <view class="eidt">
                  <sunui-mverify @change="getaccept($event, item.id, index)"></sunui-mverify>
                  <!-- <sunui-mverify @change="getaccept($event, item.id, index)"></sunui-mverify> -->
                  <view class="eidt-btn" @click="show1 = true, orderId = item.id">抢单</view>
               </view>
            </view>
         </view>
      </view>
      
      <!-- 发单方 -->
      <view class="index-c" v-if="typeViewId === 0">
      <!-- 发单方  -->
      <view class="index-c" v-if="!userInfo || userInfo.useIdentity === 0">
         <view :style="{ width: '100%', height: statusbarHeight + 'px' }"></view>
         <view class="index-c-title" :style="{ height: navHeight + 'px' }" @click="selectAddress(-1)">
            <text class="index-c-title-logo">近快</text>
@@ -119,12 +120,13 @@
                           <view class="radio-item-label">{{item.name}}</view>
                           <view class="radio-item-list">
                              <view class="radio-item-list-l">
                                 <view :class="child.active ? 'radio-item-list-item active' : 'radio-item-list-item'" v-for="(child, childIndex) in item.list" :key="childIndex" @click="selectMenu(index, childIndex)">{{child.price}}元</view>
                                 <view v-if="child.price" :class="child.active ? 'radio-item-list-item active' : 'radio-item-list-item'" v-for="(child, childIndex) in item.list" :key="childIndex" @click="selectMenu(index, childIndex)">{{child.price||0}}元</view>
                              </view>
                              <view class="radio-item-list-data">
                                 <text>份数:</text>
                                 <text style="flex-shrink: 0;">份数:</text>
                                 <input type="number" v-model="item.num" placeholder="请输入">
                                 <text style="color: #999999;">份</text>
                                 <view class="radio-item-list-data-btn" @click="clear(index)">取消</view>
                              </view>
                           </view>
                        </view>
@@ -194,7 +196,7 @@
               </view>
               <view class="box-hz-btn" :style="{ backgroundImage: 'url(' + btn + ')' }">
                  <view class="box-hz-btn-kf" @click="contactPhone()">客服</view>
                  <view class="box-hz-btn-next" @click="submit">下一步</view>
                  <view class="box-hz-btn-next" @click="submit">立即下单</view>
               </view>
            </view>
         </template>
@@ -256,14 +258,14 @@
                        <view :class="form.startDate ? 'box-hz-list-item-val active' : 'box-hz-list-item-val'">
                           <view class="box-hz-list-item-val-left">
                              <image class="icon" src="/static/icon/ic_time@2x.png" mode="widthFix"></image>
                              <text>{{ form.startDate ? form.startDate + ' 至 ' + form.endDate : '请选择用工时间'}}</text>
                              <text>{{ form.startDate ? form.startDate + ' 至 ' + form.endDate : '请选择用车时间'}}</text>
                           </view>
                           <u-icon name="arrow-right" color="#111111" size="16"></u-icon>
                        </view>
                     </view>
                     <view class="box-hz-list-item">
                        <view class="box-hz-list-item-label">
                           <text>用车时间:</text>
                           <text>用车地点:</text>
                           <text @click="addAddr">+增加途经点</text>
                        </view>
                        <view class="item-d">
@@ -304,15 +306,16 @@
               
               <view class="box-hz-btn" :style="{ backgroundImage: 'url(' + btn + ')' }">
                  <view class="box-hz-btn-kf"  @click="contactPhone()" >客服</view>
                  <view class="box-hz-btn-next" @click="jump()">下一步</view>
                  <view class="box-hz-btn-next" @click="jump()">立即下单</view>
               </view>
            </view>
         </view>
      </view>
      
      <!-- 选择日期范围 -->
      <u-calendar :show="show" color="#00BC12" mode="range" @close="show = false" @confirm="confirmDate"></u-calendar>
      <u-popup :show="showPhone" round="15" mode="bottom"   @close="contactPhone()" :closeable="true" :closeOnClickOverlay="true">
      <u-calendar :show="show" color="#00BC12" :allowSameDay="true" mode="range" @close="show = false" @confirm="confirmDate"></u-calendar>
      <u-popup :show="showPhone" round="15" mode="bottom" :safeAreaInsetBottom="true"  @close="contactPhone()" :closeable="true" :closeOnClickOverlay="true">
         <view class="phone">
            <view class="phone-head">
               <view></view>
@@ -322,9 +325,25 @@
                <view></view>
                <text>{{item}}</text> 
             </view>  
             <view style="width: 100%; height: 30rpx;"></view>
            <!-- <view class="phone-botton"  @click="contactPhone()" >关闭</view> -->
         </view>
      </u-popup>
      <u-modal
         title="温馨提示"
         :show="show1"
         closeOnClickOverlay
         showCancelButton
      >
         <view class="slot-content">
            是否确认抢单?
         </view>
         <view slot="confirmButton" style="display: flex; justify-content: space-between; align-items: center; width: 100%;">
            <view class="btn1" @click="show1 = false">取消</view>
            <view class="btn2" @click="getaccept1">确认</view>
         </view>
      </u-modal>
   </view>
</template>
@@ -401,7 +420,8 @@
               linkName: '',
               linkPhone: '',
               estimatedAccount: '',
               price: ''
               price: '',
               address: ''
            },
            sortType: 0,
            orderList: [],
@@ -409,21 +429,24 @@
            page: 1,
            next: true,
            
            isOnce: true
            isOnce: true,
            show1: false,
            orderId: null
         }
      },
      async onLoad() { 
         await this.$onLaunched;
         if (this.token && this.token != '' && this.userInfo && JSON.stringify(this.userInfo) != '{}' && this.userInfo.useIdentity === 1) {
            this.getOrderList()
         }
         console.log('2')
         // if (this.token && this.token != '' && this.userInfo && JSON.stringify(this.userInfo) != '{}' && this.userInfo.useIdentity === 1) {
         //    this.getOrderList()
         // }
         
         this.getCategoryLists()
         this.getDictInfo()
         
         if (this.token && this.token != '' && this.userInfo && JSON.stringify(this.userInfo) != '{}') {
            this.form.linkPhone = this.userInfo.telephone
            this.form.linkPhone = this.userInfo.telephone || ''
            this.form.linkName = this.userInfo.name || ''
         }
         
         this.qqmapsdk = new QQMapWX({
@@ -438,16 +461,15 @@
            this.form.location = ''
            this.form.locationEnd = ''
            this.form.wayInfoDTOList = []
            this.form.workType = 0
            this.form.workType = 0
            this.form.days = ''
            this.form.locationRemark = ''
            this.form.supplement = ''
            this.form.multifileList = []
            this.form.linkName = ''
            this.form.estimatedAccount = ''
            this.form.price = ''
            this.form.address = ''
            this.orderFood = []
            this.clearAll()
         })
         // 刷新首页数据
         uni.$on('refresh', () => {
@@ -459,13 +481,35 @@
            }
         })
      },
      onShow(options) {
         this.typeViewId = 0
      async onShow(options) {
         await this.$onLaunched;
         console.log('2')
         this.form.startDate = ''
         this.form.address = ''
         this.form.endDate = ''
         this.form.latitude = ''
         this.form.longitude = ''
         this.form.location = ''
         this.form.locationEnd = ''
         this.form.wayInfoDTOList = []
         this.form.workType = 0
         this.form.days = ''
         this.form.locationRemark = ''
         this.form.supplement = ''
         this.form.multifileList = []
         this.form.estimatedAccount = ''
         this.form.price = ''
         this.viewStatus = false
         this.clearAll()
         if(this.token && this.token != '' && this.userInfo && JSON.stringify(this.userInfo) != '{}') {
            console.log('已登陆')
            this.isLogin = true
            
            if (!this.isOnce && this.userInfo.useIdentity == 1) {
            // this.typeViewId = this.userInfo.useIdentity
            // !this.isOnce &&
            if (this.userInfo.useIdentity === 1) {
               console.log('已登陆111')
               this.page = 1
               this.next = true
               this.orderList = []
@@ -476,16 +520,13 @@
            this.isLogin = false
            console.log('未登陆')
         }
         if (this.userInfo && this.userInfo.useIdentity == 1) {
            this.typeViewId = 1
         }
      },
      watch: {
         typeId: {
            handler(news, old) {
               console.log('typeId')
               this.form.startDate = ''
               this.form.address = ''
               this.form.endDate = ''
               this.form.latitude = ''
               this.form.longitude = ''
@@ -497,10 +538,10 @@
               this.form.locationRemark = ''
               this.form.supplement = ''
               this.form.multifileList = []
               this.form.linkName = ''
               this.form.estimatedAccount = ''
               this.form.price = ''
               this.viewStatus = false
               this.clearAll()
            }
         },
         orderFood: {
@@ -535,6 +576,20 @@
         }
      },
      methods: {
         clear(index) {
            this.orderFood[index].num = ''
            this.orderFood[index].list.forEach(item => {
               item.active = false
            })
         },
         clearAll() {
            this.orderFood.forEach(p=>{
               p.num=null
               p.list.forEach(item => {
                  item.active = false
               })
            })
         },
         getDictInfo(){
            var that = this;
            this.$u.api.getPlatformAboutUs({}).then(res =>{ 
@@ -553,20 +608,33 @@
            }
         },
         // 手动接单
         getaccept(e, orderId, index) {
            if (!e.msg) return;
            this.$u.api.accept({ orderId })
               .then(res => {
                  if (res.code === 200) {
         getaccept() {
            var that = this;
            that.$u.api.accept({ orderId: this.orderId })
               .then(res1 => {
                  if (res1.code === 200) {
                     uni.showToast({ title: '抢单成功!', icon: 'success', duration: 2000 })
                     setTimeout(() => {
                        this.page = 1
                        this.next = true
                        this.orderList = []
                        this.getOrderList()
                        that.page = 1
                        that.next = true
                        that.orderList = []
                        that.getOrderList()
                     }, 2000)
                  }
               })
         },
         getaccept1() {
            var that = this;
            this.show1 = false
            uni.requestSubscribeMessage({
               tmplIds: ['tDpYImlrdv-0d3euTrHbYZ1cEZvjVHTNlqHvV0tpLHg'],
               success(res) {
                  that.getaccept()
               },
               fail(err) {
                  that.getaccept()
               }
            })
         },
         clickSort(id) {
            this.sortType = id
@@ -592,8 +660,8 @@
                  queryMyOrderType: 2,
                  type: this.typeVal,
                  sortType: this.sortType,
                  queryLat: this.latitude,
                  queryLgt: this.longitude
                  queryLat: uni.getStorageSync('address').latitude,
                  queryLgt: uni.getStorageSync('address').longitude
               }
            }).then(res => {
               if (res.code !== 200) return;
@@ -620,11 +688,34 @@
         },
         // 提交订单
         submit() {
            var that = this
            if (!this.form.startDate) {
               return uni.showToast({ title: '请选择用餐时间', icon: 'none' })
            }
            let cateringDTOList = []
            let valid = true
            let msg ='请选择'
            that.orderFood.forEach(item => {
               item.list.forEach(child => {
                  if (child.active) {
                     // (Number(child.price) * Number(item.num))
                     if( !item.num){
                        msg =msg +'【'+item.name+'】';
                        valid =false
                     }
                     cateringDTOList.push({
                        name: item.name,
                        num: item.num,
                        price: child.price * 100
                     })
                  }
               })
            })
            if(!valid){
               return uni.showToast({ title: msg+'用餐份数', icon: 'none' })
            }
            if (this.form.price === 0) {
               return uni.showToast({ title: '请选择用餐时间', icon: 'none' })
            if (cateringDTOList.length === 0) {
               return uni.showToast({ title: '请选择用餐标准', icon: 'none' })
            }
            if (!this.form.address) {
               return uni.showToast({ title: '请选择用餐地点', icon: 'none' })
@@ -632,52 +723,48 @@
            if (!this.form.linkPhone) {
               return uni.showToast({ title: '请输入联系电话', icon: 'none' })
            }
            let cateringDTOList = []
            this.orderFood.forEach(item => {
               item.list.forEach(child => {
                  if (child.active) {
                     cateringDTOList.push({
                        name: item.name,
                        num: item.num,
                        price: (Number(child.price) * Number(item.num)) * 100
                     })
                  }
               })
            })
            this.$u.api.release({
               ...this.form,
               type: 2,
               price: Number(this.form.price) * 100,
               priceNum1: this.form.days,
               location: this.form.address,
               lat: this.form.latitude,
               lgt: this.form.longitude,
               cateringDTOList
            }).then(res => {
               if (res.code == 200) {
                  wx.requestPayment({
                     timeStamp: res.data.object.timeStamp,
                     nonceStr: res.data.object.nonceStr,
                     package: res.data.object.packageVal,
                     signType: res.data.object.signType,
                     paySign: res.data.object.paySign,
                     success (res1) {
                        if (res1.errMsg = 'requestPayment:ok') {
                           uni.showToast({ title: '支付成功', icon: 'success', duration: 2000 });
                           setTimeout(() => {
                              uni.navigateTo({
                                 url: `/pages/success/success?orderId=${res.data.id}`
                              })
                           }, 1500)
                        }
                     },
                     fail(err) {
                        console.log(err)
            uni.requestSubscribeMessage({
               tmplIds: ['oVjOBLcHxIlGzOMJsdInmgI5CHGXh-UTvMzQqfFOnIg'],
               success(res) {
                  that.$u.api.release({
                     ...that.form,
                     type: 2,
                     price: Number(that.form.price) * 100,
                     priceNum1: that.form.days,
                     location: that.form.address,
                     lat: that.form.latitude,
                     lgt: that.form.longitude,
                     cateringDTOList
                  }).then(res => {
                     if (res.code == 200) {
                        wx.requestPayment({
                           timeStamp: res.data.object.timeStamp,
                           nonceStr: res.data.object.nonceStr,
                           package: res.data.object.packageVal,
                           signType: res.data.object.signType,
                           paySign: res.data.object.paySign,
                           success (res1) {
                              if (res1.errMsg = 'requestPayment:ok') {
                                 uni.showToast({ title: '支付成功', icon: 'success', duration: 2000 });
                                 setTimeout(() => {
                                    uni.navigateTo({
                                       url: `/pages/success/success?orderId=${res.data.id}`
                                    })
                                 }, 1500)
                              }
                           },
                           fail(err) {
                              console.log(err)
                           }
                        })
                     }
                  })
                  console.log(cateringDTOList)
               },
               fail(err) {
                  console.log(err)
               }
            })
            console.log(cateringDTOList)
         },
         uploadImg() {
            uni.chooseImage({
@@ -729,7 +816,10 @@
         confirmDate(e) {
            this.form.startDate = e[0]
            this.form.endDate = e[e.length - 1]
            this.form.days = e.length;
            let time = this.form.startDate == this.form.endDate ? 1 : 0
            this.form.days = e.length - time;
            this.show = false
            if (this.typeId === 2) {
               this.getPrice()
@@ -738,18 +828,19 @@
         selectAddress(type, index) {
            uni.chooseLocation({
               success: (res) => { 
                  console.log("==================",res)
                  if ([1,2].includes(type)) {
                     this.form.latitude = res.latitude
                     this.form.longitude = res.longitude
                     this.form.address = res.address
                     this.form.address = res.name ||res.address
                  } else if (type === 3) {
                     this.form.locationEnd = res.address
                     this.form.locationEnd = res.name ||res.address
                     this.form.latEnd = res.latitude
                     this.form.lgtEnd = res.longitude
                  } else if (type === 4) {
                     this.form.wayInfoDTOList[0].lat = res.latitude
                     this.form.wayInfoDTOList[0].lgt = res.longitude
                     this.form.wayInfoDTOList[0].location = res.address
                     this.form.wayInfoDTOList[index].lat = res.latitude
                     this.form.wayInfoDTOList[index].lgt = res.longitude
                     this.form.wayInfoDTOList[index].location = res.name||  res.address
                  }else if (type == -1) {
                     console.log(res)
                     this.location.latitude = res.latitude
@@ -760,6 +851,12 @@
            });
         },
         clickType(e) {
            if (!this.token) {
               uni.navigateTo({
                  url: '/pages/login/login'
               })
               return
            }
            this.typeId = e
            if (e === 2) {
               this.form.categoryId = this.car[0].id
@@ -895,6 +992,36 @@
<style lang="scss" scoped>
   .index {
      width: 100%;
      .slot-content {
         width: 100%;
         text-align: center;
         font-weight: 400;
         font-size: 30rpx;
         color: #333333;
         margin: 30rpx 0;
      }
      .btn1 {
         width: 264rpx;
         height: 88rpx;
         line-height: 88rpx;
         text-align: center;
         font-weight: 400;
         font-size: 32rpx;
         color: #666666;
         border-radius: 44rpx;
         border: 1rpx solid #B2B2B2;
      }
      .btn2 {
         width: 264rpx;
         height: 88rpx;
         line-height: 88rpx;
         text-align: center;
         font-weight: 500;
         font-size: 32rpx;
         color: #FFFFFF;
         background: #00BC12;
         border-radius: 44rpx;
      }
      .index-j {
         width: 100%;
         .index-j-head {
@@ -1001,6 +1128,17 @@
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  .eidt-btn {
                     width: 100%;
                     height: 88rpx;
                     line-height: 88rpx;
                     text-align: center;
                     background: #00BC12;
                     border-radius: 44rpx;
                     font-weight: 500;
                     font-size: 32rpx;
                     color: #FFFFFF;
                  }
                  // background: #00BC12;
                  // border-radius: 50rpx;
                  // text {
@@ -1270,7 +1408,7 @@
                     .radio-item {
                        width: 100%;
                        display: flex;
                        align-items: self-end;
                        align-items: flex-start;
                        margin-bottom: 30rpx;
                        border-bottom: 1rpx solid #E5E5E5;
                        &:last-child {
@@ -1329,6 +1467,18 @@
                              justify-content: flex-end;
                              margin-top: 42rpx;
                              margin-bottom: 34rpx;
                              .radio-item-list-data-btn {
                                 width: 110rpx;
                                 height: 64rpx;
                                 line-height: 64rpx;
                                 margin-left: 20rpx;
                                 font-weight: 400;
                                 font-size: 24rpx;
                                 color: #666666;
                                 text-align: center;
                                 border: 1rpx solid #B2B2B2;
                                 border-radius: 34rpx;
                              }
                              text {
                                 font-weight: 400;
                                 font-size: 30rpx;