cuiqian2004
4 天以前 2af5f043b60c1f7ac38ecccc8f5bf44743134325
pages/task/log-list.vue
@@ -3,17 +3,17 @@
      <view class="list-content" v-if="list.length > 0">
         <view class="header">
            <view class="item">
               <view class="title">{{totalDuration}}<text class="text">min</text></view>
               <view class="text">累计时长</view>
               <view class="title">{{totalDuration}}<text class="text">{{translate("minute")}}</text></view>
               <view class="text">{{translate("cumulative_duration")}}</view>
            </view>
            <view class="item">
               <view class="title">{{totalCount}}</view>
               <view class="text">累计次数</view>
               <view class="text">{{translate("cumulative_count")}}</view>
            </view>
         </view>
         <view class="list">
            <!-- <view class="task-header" v-if="fixedList.length > 0">固定任务</view> -->
            <!-- <view class="task-header" v-if="fixedList.length > 0">{{translate("fixed_task")}</view> -->
            <template v-for="(group) in taskList" :key="group.date">
               <view class="task-header">{{group.date}}</view>
               <view class="task-list-view">
@@ -22,7 +22,7 @@
                  </TaskLogItemView>
               </view>
            </template>
            <!-- <view class="task-header" v-if="tempList.length > 0">临时任务</view>
            <!-- <view class="task-header" v-if="tempList.length > 0">{{translate("temporary_task")}</view>
            <template v-for="(group) in tempList" :key="group.date">
               <view class="task-header">{{group.date}}</view>
               <view class="task-list-view">
@@ -37,7 +37,7 @@
      <view class="list-no-content" v-else>
         <!-- <image class="img" src="/images/icon-park-outline_attention.svg" alt=" 图片" mode="aspectFit" />-->
         <uni-icons color="#ccc" type="info" size="128"></uni-icons>
         <view class="space">没有找到符合条件的任务记录</view>
         <view class="space">{{translate("no_task_history_found")}}</view>
      </view>
   </view>
</template>
@@ -69,8 +69,9 @@
         taskList() {
            const listRes = []
            this.list.forEach((ele) => {
               const dateStart = new Date(Number(ele.start_time))
               const date = `${dateStart.getMonth()}-${dateStart.getDay()}`;
               const dateStart = new Date(parseInt(ele.start_time))
               const date = `${dateStart.getMonth() +1}-${dateStart.getDate()}`;
               const curIndex = listRes.findIndex((a) => a.date == date)
               if (curIndex < 0) {
                  let group = {
@@ -121,10 +122,11 @@
            // this.list.forEach((item) => {
            //    d += item.duration || 0
            // })
            this.list.forEach((item) => {
               d +=( item.end_time -  item.start_time)
               d += Math.ceil((item.end_time- item.start_time) / (60* 1000)) //(item.end_time - item.start_time)
            })
            return Math.ceil(d / (60 * 1000))
            return d//Math.ceil(d / (60 * 1000))
         },
         totalCount() {
             let cnt =this.list.length
@@ -165,12 +167,15 @@
            try {
               this.list = await this.loadTaskLog()
            } catch (ex) {
               showError(ex)
               showError(ex, this.translate('error'))
            }
         },
         async loadTaskLog() {
            try {
               
               uni.showLoading({
                  title: this.translate("loading")
               })
               const now = new Date();
               const oneWeekAgo = new Date();
               const endTimeStamp = `${now.getTime()}`
@@ -182,12 +187,12 @@
               list.sort((a, b) => {
                  return a.end_time < b.end_time ? 1 : -1
               });
               showToast(`装载了${list.length}记录`)
               return list
            } catch (ex) {
               showError(ex)
               showError(ex, this.translate('error'))
               return []
            } finally {
               uni.hideLoading()
            } 
         },
@@ -196,6 +201,10 @@
            //    url: "/pages/task/index"
            // })
         },
         translate(t) {
            if (typeof this.$t == "function") return this.$t(`page.${t}`)
            else return t;
         },
      }
   }