MrShi
2025-07-18 de1ef43c565e1666484d7d71203afd7526f4e3de
small-program/pages/index/index.vue
@@ -323,10 +323,10 @@
                     </view>
                     <view class="box-hz-list-item" @click="selectAddress(1)">
                        <view class="box-hz-list-item-label"><text>用工地点:</text></view>
                        <view :class="form.address ? 'box-hz-list-item-val active' :'box-hz-list-item-val'">
                        <view :class="form.location ? '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_location@2x.png" mode="widthFix"></image>
                              <text>{{form.address ? form.address : '请选择用工地点'}}</text>
                              <text>{{form.location ? form.location : '请选择用工地点'}}</text>
                           </view>
                           <u-icon name="arrow-right" color="#111111" size="16"></u-icon>
                        </view>
@@ -337,65 +337,64 @@
               <!-- 运货 -->
               <template v-if="typeId === 1">
                  <view class="box-hz-cate">
                     <view :class="carId === item.id ? 'box-hz-cate-item active' : 'box-hz-cate-item'" v-for="(item, index) in car" :key="index" @click="clickCar(item.id)">
                     <view :class="form.categoryId === item.id ? 'box-hz-cate-item active' : 'box-hz-cate-item'" v-for="(item, index) in car" :key="index" @click="clickCar(item)">
                        <text>{{item.name}}</text>
                        <view class="box-hz-cate-item-x" v-if="carId === item.id"></view>
                        <view class="box-hz-cate-item-x" v-if="form.categoryId === item.id"></view>
                     </view>
                  </view>
                  <view class="box-hz-car">
                     <view class="box-hz-car-image">
                        <image src="/static/image/ic_sanlunche@2x.png" mode="widthFix" v-if="carId === 1"></image>
                        <image src="/static/image/ic_xiaohuoche@2x.png" mode="widthFix" v-else-if="carId === 2"></image>
                        <image :src="carImage" mode="widthFix"></image>
                     </view>
                     <view class="box-hz-car-info" v-if="carId === 1">
                        厢长3.8~4.0米  载重1.5~2.0吨  载方12.3~18.4方
                     </view>
                     <view class="box-hz-car-info" v-else-if="carId === 2">
                        厢长3.8~4.0米  载重1.5~2.0吨  载方12.3~18.4方
                     <view class="box-hz-car-info" v-if="carRemark">
                        {{carRemark || ''}}
                     </view>
                  </view>
                  <view class="box-hz-list">
                     <view class="box-hz-list-item">
                     <view class="box-hz-list-item" @click="show = true">
                        <view class="box-hz-list-item-label"><text>用车时间:</text></view>
                        <view class="box-hz-list-item-val">
                        <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>请选择用车时间</text>
                              <text>{{ form.startDate ? form.startDate + ' 至 ' + form.endDate : '请选择用工时间'}}</text>
                           </view>
                           <image class="icon1" src="/static/icon/home_ar_next@2x.png" mode="widthFix"></image>
                           <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">
                           <view class="item-d-row">
                           <view class="item-d-row" @click="selectAddress(2)">
                              <view class="item-d-row-icon">
                                 <image src="/static/icon/ic_qidian@2x.png" mode="widthFix"></image>
                              </view>
                              <view class="item-d-row-val">
                                 <text>请选择用车起点</text>
                                 <image src="/static/icon/home_ar_next@2x.png" mode="widthFix"></image>
                                 <text>{{form.address ? form.address : '请选择用车起点'}}</text>
                                 <u-icon name="arrow-right" color="#111111" size="16"></u-icon>
                              </view>
                           </view>
                           <view class="item-d-row">
                           <view class="item-d-row" v-for="(item, index) in form.wayInfoDTOList" :key="index" @click="selectAddress(4, index)">
                              <view class="item-d-row-icon">
                                 <image src="/static/icon/ic_jingguo@2x.png" mode="widthFix"></image>
                              </view>
                              <view class="item-d-row-val">
                                 <text style="color: #999999;">请选择途经地点</text>
                                 <image src="/static/icon/home_ar_next@2x.png" mode="widthFix"></image>
                                 <text>{{item.location ? item.location : '请选择途经地点'}}</text>
                                 <view style="display: flex; align-items: center; flex-shrink: 0;">
                                    <image src="/static/icon/ic_delete@2x.png" style="margin-right: 22rpx; width: 32rpx; height: 32rpx;" @click.stop="form.wayInfoDTOList.splice(index, 1)" mode="widthFix"></image>
                                    <u-icon name="arrow-right" color="#111111" size="16"></u-icon>
                                 </view>
                              </view>
                           </view>
                           <view class="item-d-row">
                           <view class="item-d-row" @click="selectAddress(3)">
                              <view class="item-d-row-icon">
                                 <image src="/static/icon/ic_zhongdian@2x.png" mode="widthFix"></image>
                              </view>
                              <view class="item-d-row-val">
                                 <text>请选择用车终点</text>
                                 <image src="/static/icon/home_ar_next@2x.png" mode="widthFix"></image>
                                 <text>{{form.locationEnd ? form.locationEnd : '请选择用车终点'}}</text>
                                 <u-icon name="arrow-right" color="#111111" size="16"></u-icon>
                              </view>
                           </view>
                        </view>
@@ -439,7 +438,6 @@
            show: false,
            isLogin: false,
            typeId: 0,
            carId: 1,
            type: [
               { name: '用工', id: 0 },
               { name: '运货', id: 1 },
@@ -450,47 +448,62 @@
               { name: '分拣工', id: 1 },
               { name: '包装工', id: 2 }
            ],
            car: [
               { name: '三轮车', id: 1 },
               { name: '小货车', id: 2 }
            ],
            car: [],
            btn: require('@/static/image/btn.png'),
            typeViewId: 0,
            carImage: '',
            carRemark: '',
            
            form: {
               startDate: '',
               endDate: '',
               latitude: '',
               longitude: '',
               address: '',
               location: '',
               locationEnd: '',
               wayInfoDTOList: [],
               workType: 0,
               categoryId: '',
               categoryName: '',
               days: ''
            }
         }
      },
      onLoad() {
         this.getCategoryLists()
      },
      methods: {
         addAddr() {
            this.form.wayInfoDTOList.push({
               lat: '',
               lgt: '',
               location: ''
            })
         },
         confirmDate(e) {
            this.form.startDate = e[0]
            this.form.endDate = e[e.length - 1]
            this.form.days = e.length;
            this.show = false
         },
         selectAddress(type) {
         selectAddress(type, index) {
            uni.chooseLocation({
               success: (res) => {
                  if (type === 1) {
                  if ([1,2].includes(type)) {
                     this.form.latitude = res.latitude
                     this.form.longitude = res.longitude
                     this.form.address = res.address
                  } else if (type === 3) {
                     this.form.locationEnd = 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
                  }
               }
            });
            // uni.getLocation({
            //    type: 'gcj02',
            //    success: function (res) {
            //       console.log(res)
            //    }
            // });
         },
         clickType(e) {
            this.typeId = e
@@ -498,8 +511,11 @@
         clickTypeWork(e) {
            this.form.workType = e
         },
         clickCar(e) {
            this.carId = e
         clickCar(item) {
            this.form.categoryId = item.id
            this.form.categoryName = item.name
            this.carImage = item.iconFull
            this.carRemark = item.remark
         },
         jump() {
            if(!this.userInfo || !this.token){
@@ -511,31 +527,76 @@
            
            const { form } = this;
            
            if (!form.startDate || !form.endDate) {
               return uni.showToast({ title: '请选择用工时间', icon: 'none' })
            } else if (!form.latitude || !form.longitude) {
               return uni.showToast({ title: '请选择用工地点', icon: 'none' })
            }
            // 采摘工
            if (this.form.workType === 0) {
            // 用工
            if (this.typeId === 0) {
               if (!form.startDate || !form.endDate) {
                  return uni.showToast({ title: '请选择用工时间', icon: 'none' })
               } else if (!form.latitude || !form.longitude) {
                  return uni.showToast({ title: '请选择用工地点', icon: 'none' })
               }
               // 采摘工
               if (this.form.workType === 0) {
                  uni.navigateTo({
                     url: `/pages/using-workers/using-workers?days=${form.days}&startDate=${form.startDate}&endDate=${form.endDate}&latitude=${form.latitude}&longitude=${form.longitude}&address=${form.location}&workType=${form.workType}`
                  })
               // 分拣工
               } else if (this.form.workType === 1) {
                  uni.navigateTo({
                     url: `/pages/sorting/sorting?days=${form.days}&startDate=${form.startDate}&endDate=${form.endDate}&latitude=${form.latitude}&longitude=${form.longitude}&address=${form.location}&workType=${form.workType}`
                  })
               // 包装工
               } else if (this.form.workType === 2) {
                  uni.navigateTo({
                     url: `/pages/packaging-worker/packaging-worker?days=${form.days}&startDate=${form.startDate}&endDate=${form.endDate}&latitude=${form.latitude}&longitude=${form.longitude}&address=${form.location}&workType=${form.workType}`
                  })
               }
            // 运货
            } else if (this.typeId === 1) {
               if (!form.startDate || !form.endDate) {
                  return uni.showToast({ title: '请选择用车时间', icon: 'none' })
               } else if (!form.latitude || !form.longitude) {
                  return uni.showToast({ title: '请选择用车起点', icon: 'none' })
               } else if (!form.latEnd || !form.lgtEnd) {
                  return uni.showToast({ title: '请选择用车终点', icon: 'none' })
               }
               let carData = {
                  startDate: form.startDate,
                  endDate: form.endDate,
                  lat: form.latitude,
                  lgt: form.longitude,
                  location: form.address,
                  latEnd: form.latEnd,
                  lgtEnd: form.lgtEnd,
                  locationEnd: form.locationEnd,
                  wayInfoDTOList: form.wayInfoDTOList,
                  categoryId: form.categoryId,
                  categoryName: form.categoryName,
                  days: form.days
               }
               uni.setStorageSync('carData', carData);
               uni.navigateTo({
                  url: `/pages/using-workers/using-workers?days=${form.days}&startDate=${form.startDate}&endDate=${form.endDate}&latitude=${form.latitude}&longitude=${form.longitude}&address=${form.address}&workType=${form.workType}`
               })
            // 分拣工
            } else if (this.form.workType === 1) {
               uni.navigateTo({
                  url: `/pages/sorting/sorting?days=${form.days}&startDate=${form.startDate}&endDate=${form.endDate}&latitude=${form.latitude}&longitude=${form.longitude}&address=${form.address}&workType=${form.workType}`
               })
            // 包装工
            } else if (this.form.workType === 2) {
               uni.navigateTo({
                  url: `/pages/packaging-worker/packaging-worker?days=${form.days}&startDate=${form.startDate}&endDate=${form.endDate}&latitude=${form.latitude}&longitude=${form.longitude}&address=${form.address}&workType=${form.workType}`
                  url: `/pages/freight/freight`
               })
            }
         },
         mverify(e){
            console.log('验证结果:',e);
         },
         getCategoryLists() {
            this.$u.api.getCategoryList({ type: 1 })
               .then(res => {
                  this.car = res.data
                  this.form.categoryId = res.data[0].id
                  this.form.categoryName = res.data[0].name
                  this.carRemark = res.data[0].remark
                  this.carImage = res.data[0].iconFull
               })
         }
      }
   }
@@ -1179,9 +1240,12 @@
                  .box-hz-car-image {
                     width: 432rpx;
                     height: 200rpx;
                     display: flex;
                     align-items: center;
                     justify-content: center;
                     overflow: hidden;
                     image {
                        width: 100%;
                        height: 100%;
                     }
                  }
                  .box-hz-car-info {
@@ -1244,7 +1308,8 @@
                        border: 2rpx solid #FD9E24;
                        .item-d-row {
                           width: 100%;
                           height: 100rpx;
                           // height: 100rpx;
                           height: auto;
                           display: flex;
                           align-items: center;
                           justify-content: space-between;
@@ -1260,7 +1325,9 @@
                           }
                           .item-d-row-val {
                              flex: 1;
                              height: 100%;
                              // height: 100%;
                              padding: 30rpx 0;
                              box-sizing: border-box;
                              display: flex;
                              align-items: center;
                              justify-content: space-between;