-
zhangwei
2024-09-12 f7aa204aa8d20b090d7943969ddeb9871a1fad76
src/pages/index/index.vue
@@ -1,115 +1,240 @@
<template>
   <view class="full-page">
      <scroll-view  enable-flex="true">
         <view class="list chuany-flex chuany-flex-direction chuany-align-center c-p-b-30"
            v-if="state.currentIdex==0">
            <view class="content c-p-b-18" v-for="(item,index) in list2" @click='toDetail' :key='item.id'>
               <view class="bgblue c-p-18 chuany-flex chuany-justify-between chuany-font34 chuany-text-bold">
                  <text class=''>
                     {{item.time}}
                  </text>
      <up-sticky bgColor="#fff">
         <view class="coreshop-ff c-p-10">
            <!-- <up-search placeholder="请点击选择日期" @clear='clear' @clickIcon='clickTime' @custom='search'
               v-model="workTime" search-icon="calendar" @search='search'></up-search> -->
            <up-search placeholder="请输入工作名称" @clear='clear' @custom='search' v-model="state.orderName"
               @search='search'></up-search>
         </view>
      </up-sticky>
      <scroll-view enable-flex="true" v-if="listO.orderList">
         <view class="list chuany-flex chuany-flex-direction chuany-align-center c-p-b-30 "
            v-if="listO.orderList.length>0">
            <view class="content c-p-b-18" v-for="(item,index) in listO.orderList" @click='toDetail(item.id)'
               :key='item.id'>
               <view
                  class="bgblue c-p-l-18 c-p-r-18 c-p-t-10 c-p-b-10 chuany-flex chuany-justify-between chuany-font30">
                  <view class="chuany-flex chuany-flex-direction">
                     <text class=''>
                        {{$util.formatDate(item.startTime)}}
                     </text>
                  </view>
                  <text>
                     招{{item.zhaodao}}/{{item.peoplenum}}人
                     招{{item.worderCounted}}/{{item.worderCount}}人
                  </text>
               </view>
               <view class="c-p-18 chuany-font44 chuany-text-bold">
                  {{item.name}}
               <view class="c-p-l-18 c-p-b-10 c-p-t-10 c-p-r-18 chuany-font34">
                  {{item.orderComName}}
               </view>
               <view class="chuany-flex c-p-l-18">
               <view class="c-p-l-18 c-p-b-10 c-p-r-18 chuany-font34">
                  {{item.orderName}}
               </view>
               <!-- <view class="chuany-flex c-p-l-18">
                  <up-tag class='c-p-r-14' :text="item" plain v-for="(item,index) in item.tags" :key="index">
                  </up-tag>
               </view> -->
               <view class="chuany-flex chuany-flex-direction">
                  <text class='c-p-l-18 c-p-b-10 c-p-r-18 text-69'>
                     日期:{{item.wordStartTimeName}} 至 {{item.wordEndTimeName}}
                  </text>
                  <text class='c-p-l-18 c-p-b-10 c-p-r-18 text-69'>
                     时间:{{item.startTimeName}} 至 {{item.endTimeName}}
                  </text>
               </view>
               <view class="chuany-flex chuany-flex-direction">
                  <text class='c-p-18'>
                     要求:{{item.yaoqiu}}
                  <text class='c-p-l-18 c-p-b-10 c-p-r-18 text-69'>
                     要求:{{item.demand}}
                  </text>
                  <text class='c-p-l-18 c-p-b-16'>
                     地址:{{item.adress}}
                  <text class='c-p-l-18 c-p-b-10 c-p-r-18 text-69'>
                     地址:{{item.worderAddress}}
                  </text>
               </view>
               <view class='chuany-flex chuany-justify-between c-p-l-18 c-p-r-18'>
                  <view class="redcla">
                     <text class="chuany-font40 chuany-text-bold">
                        {{item.price}}
                     <text class="chuany-font40">
                        {{item.workPrice}}
                     </text>
                     <text class='chuany-font20'>
                        元/小时
                        {{item.workerType==0?'元/小时':'元/件'}}
                     </text>
                  </view>
                  <up-tag text="去抢活" type="warning" shape="circle"></up-tag>
                  <up-tag text="去抢活" v-if="identity !== 'enterprise'" type="warning" shape="circle"
                     @click.stop='deliver(item.id)'></up-tag>
                  <!-- <up-tag text="去抢活" type="warning" shape="circle"></up-tag> -->
               </view>
            </view>
            <up-loadmore :status="loadStatus" />
         </view>
         <view v-else>
            <up-empty mode="order" icon="http://cdn.uviewui.com/uview/empty/order.png">
            </up-empty>
         </view>
      </scroll-view>
      </scroll-view>
      <view v-else>
         <up-empty text='暂无' icon="/static/order.png">
         </up-empty>
      </view>
      <fui-date-picker range :show="datePickerShow" type="5" @change="changePicker"
         @cancel="cancel"></fui-date-picker>
   </view>
</template>
<script setup>
   import {
      onLoad,
      onShow,
      onReachBottom,
      onPullDownRefresh,
      onHide
   } from "@dcloudio/uni-app";
   import {
      reactive,
      ref
      ref,
      getCurrentInstance
   } from 'vue';
   let state = reactive({
      currentIdex: 0
   const {
      $upload,
      $api,
      $util,
      $db
   } = getCurrentInstance().appContext.config.globalProperties
   const userToken = $db.get("userToken");
   let identity = ref('')
   let workTime = ref('')
   let datePickerShow = ref(false)
   const state = reactive({
      pageIndex: 1,
      pageSize: 20,
      orderName: ''
   })
   // 创建响应式数据
   const list1 = reactive([{
         name: '新任务'
      },
      {
         name: '我的订单'
      },
   ]);
   const list2 = reactive([{
         id: 1,
         time: '明天 19:00-23:00',
         name: '临时工',
         tags: ['4小时', '可无经验', '手脚麻利'],
         adress: '武侯区桂溪街道4.0km',
         yaoqiu: '不限',
         price: 50,
         peoplenum: 3,
         zhaodao: 1
      },
      {
         id: 2,
         time: '明天 19:00-23:00',
         name: '临时工',
         tags: ['4小时', '可无经验', '手脚麻利'],
         adress: '武侯区桂溪街道4.0km',
         price: 50,
         yaoqiu: '不限',
         peoplenum: 3,
         zhaodao: 1
      },
      {
         id: 3,
         time: '今天 19:00-23:00',
         name: '包装工',
         tags: ['4小时', '可无经验', '手脚麻利'],
         adress: '武侯区桂溪街道4.0km',
         price: 50,
         yaoqiu: '男/18-55岁',
         peoplenum: 3,
         zhaodao: 1
      },
   ]);
   let listO = reactive({
      orderList: []
   })
   const search = (index) => {
      PostListPage()
   }
   const changePicker = (val) => {
      console.log(val);
      workTime.value = val.startDate.result + '至' + val.endDate.result
      state.wordStartTime = new Date(val.startDate.result) //工作开始时间
      state.wordEndTime = new Date(val.endDate.result)
   }
   const clear = () => {
      state.orderName = ''
      state.wordStartTime = ""
      state.wordEndTime = ""
   }
   const clickTime = () => {
      datePickerShow.value = !datePickerShow.value
   }
   let loadStatus = ref('loadmore')
   onReachBottom(() => {
      if (loadStatus.value != 'nomore') {
         PostListPage();
      }
   })
   onPullDownRefresh(() => {
      state.pageIndex = 1
      state.pageSize = 20
      loadStatus.value = 'loadmore'
      PostListPage();
      uni.stopPullDownRefresh();
   })
   onShow(() => {
      identity.value = $db.get('identity')
      console.log(identity.value);
      PostListPage()
   })
   onHide(() => {
      listO.orderList = []
   })
   const PostListPage = (orderStatus) => {
      console.log(identity.value, 'identity----------');
      let data = {
         pageIndex: state.pageIndex,
         pageSize: state.pageSize,
      }
      if (orderStatus) {
         data.orderStatus = orderStatus
      }
      if (state.orderName) {
         data.orderName = state.orderName
      }
      loadStatus.value = 'loading';
      if (identity.value == 'enterprise') {
         $api.PostMyListPageCompany(data).then(res => {
            if (res.code == 1) {
               console.log(res, res.code, '-----------123’');
               if (state.pageIndex == 1) {
                  listO.orderList = res.data.items
               } else {
                  listO.orderList.concat(...res.data.items)
               }
               console.log(listO.orderList, 'listO.orderList’');
               // totalPages.value = res.data.totalCount
               // 根据count数量判断是否还有数据
               if (res.data.totalCount > listO.orderList.length) {
                  loadStatus.value = 'loadmore'
                  state.pageIndex++
               } else {
                  // 数据已加载完毕
                  loadStatus.value = 'nomore'
               }
            } else {
               // _that.$refs.uToast.show({ message: res.msg, type: 'error' });
            }
         })
      } else {
         $api.PostListPage(data).then(res => {
            if (res.code == 1) {
               console.log(res, res.code, '-----------123’');
               if (state.pageIndex == 1) {
                  listO.orderList = res.data.items
               } else {
                  listO.orderList.concat(...res.data.items)
               }
               console.log(listO.orderList, 'listO.orderList’');
               // totalPages.value = res.data.totalCount
               // 根据count数量判断是否还有数据
               if (res.data.totalCount > listO.orderList.length) {
                  loadStatus.value = 'loadmore'
                  state.pageIndex++
               } else {
                  // 数据已加载完毕
                  loadStatus.value = 'nomore'
               }
            } else {
               // _that.$refs.uToast.show({ message: res.msg, type: 'error' });
            }
         })
      }
   }
   const click = () => {
   }
   const cancel = () => {
   }
   const change = (e) => {
      state.currentIdex = e.index
   }
   const toDetail = (e) => {
   const toDetail = (val) => {
      if (identity.value !== 'enterprise') {
         uni.navigateTo({
            url: `/pages/detail/detail?orderid=${val}`
         })
      } else {
         uni.navigateTo({
            url: `/pages/order/detail?orderid=${val}`
         });
      }
   }
   const deliver = (val) => {
      uni.navigateTo({
         url: '/pages/detail/detail'
         url: `/pages/detail/detail?orderid=${val}`
      })
      // $api.saveBaoMing({orderId:e}).then(res => {
      // })
   }
</script>
@@ -119,7 +244,7 @@
   }
   .content {
      height: 430rpx;
      min-height: 330rpx;
      width: 90%;
      background-color: #fff;
      border-radius: 20rpx;