Răsfoiți Sursa

【feat】【v3】

1.页面逻辑优化
ChenYL 9 luni în urmă
părinte
comite
a164b95db0

+ 9 - 0
src/common/enums.js

@@ -53,4 +53,13 @@ export const STAT_PERIOD = {
   WEEK: 'WEEK',
   MONTH: 'MONTH',
   YEAR: 'YEAR'
+}
+
+/**
+ * 结算结果(已结算-SETTLED,撤销结算-REVOKE_SETTLED,无需结算-NOT_SETTLED)
+ */
+export const SETTLE_RESULT = {
+  SETTLED: 'SETTLED',
+  REVOKE_SETTLED: 'REVOKE_SETTLED',
+  NOT_SETTLED: 'NOT_SETTLED'
 }

+ 1 - 1
src/pages/reward/rewardList.vue

@@ -8,7 +8,7 @@
 
   <view class="reward-container">
     <view class="reward-item" v-for="reward in rewardList" :key="reward.id">
-      <view class="item-box" @click="goRewardEditPage(reward.id)">
+      <view class="item-box">
         <view class="item-header">
           <span class="item-title">{{ reward.rewardName }}</span>
           <view class="item-tag" v-if="reward.autoStatus && reward.autoStatus == COMMON_ENABLED_STATUS.ENABLED">自动兑换

+ 35 - 20
src/pages/statData.vue

@@ -28,23 +28,27 @@
 
   <!-- 打卡日志 -->
   <view v-if="currentTabIndex === 1">
-    <uni-calendar @change="calendarSwitchChange" />
+    <uni-calendar @change="calendarSwitchChange" :selected="calendarSelectedVOS" />
     <view class="log-box">
       <uni-section title="打卡记录" type="line">
-        <uni-list>
-          <uni-list-item v-for="piTaskHistory in piTaskHistoryData" :key="piTaskHistory.punchInDate">
+        <uni-list v-if="piTaskHistoryVOS && piTaskHistoryVOS.length > 0">
+          <uni-list-item v-for="(piTaskHistory, index) in piTaskHistoryVOS" :key="index">
             <template v-slot:body>
-              {{ piTaskHistory.punchInDate }}
+              {{ piTaskHistory.taskName }}
               <span v-if="piTaskHistory.punchInResult == PUNCH_IN_RESULT.DONE"> 完成打卡</span>
               <span v-else> 未完成打卡</span>
               <span v-if="piTaskHistory.punchInMethod == PUNCH_IN_METHOD.COUNT">,打卡{{ piTaskHistory.countTrack
               }}次</span>
-              <span v-if="piTaskHistory.punchInMethod == PUNCH_IN_METHOD.TIMING">,打卡时长{{ piTaskHistory.timeTrack
+              <span v-if="piTaskHistory.punchInMethod == PUNCH_IN_METHOD.TIMING">,打卡时长{{
+                piTaskHistory.timeTrack }}</span>
+              <span v-if="piTaskHistory.settleResult == SETTLE_RESULT.SETTLED">,已结算,结算积分:{{ piTaskHistory.settlePoints
               }}</span>
+              <span v-if="piTaskHistory.settleResult == SETTLE_RESULT.NOT_SETTLED">,无需结算</span>
+              <span v-if="!piTaskHistory.settleResult">,未结算</span>
             </template>
           </uni-list-item>
         </uni-list>
-        <uni-load-more status="no-more" v-if="!piTaskHistoryData || piTaskHistoryData.length == 0" />
+        <uni-load-more status="no-more" v-if="!piTaskHistoryVOS || piTaskHistoryVOS.length == 0" />
       </uni-section>
     </view>
   </view>
@@ -55,7 +59,8 @@
 import { ref } from 'vue';
 import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app';
 import { statApi, punchInApi } from '@/apis/apis';
-import { PUNCH_IN_RESULT, PUNCH_IN_METHOD, STAT_PERIOD } from '@/common/enums';
+import { PUNCH_IN_RESULT, PUNCH_IN_METHOD } from '@/common/enums';
+import { SETTLE_RESULT } from '@/common/enums';
 
 // 属性
 /**
@@ -78,9 +83,14 @@ const queryData = ref({
 });
 
 /**
- * 打卡日历数据
+ * 日历打点数据
  */
-const piTaskHistoryData = ref([]);
+const calendarSelectedVOS = ref([]);
+
+/**
+ * 打卡记录
+ */
+const piTaskHistoryVOS = ref([]);
 
 /**
  * 图表加载动画
@@ -131,9 +141,7 @@ const chartsData = ref({
 const switchTab = (e) => {
   if (currentTabIndex.value !== e.currentIndex) {
     currentTabIndex.value = e.currentIndex
-    if (e.currentIndex == 1) {
-      loadPunchInHistoryData();
-    }
+    loadData();
   }
 }
 
@@ -141,7 +149,6 @@ const switchTab = (e) => {
  * 日历月份切换
  */
 const calendarSwitchChange = (e) => {
-  console.log("出发啦啦啦");
   queryData.value = e;
   loadPunchInHistoryData();
 }
@@ -176,7 +183,19 @@ const loadStatTaskData = async () => {
 const loadPunchInHistoryData = async () => {
   let punchInDate = `${queryData.value.year}-${queryData.value.month.toString().padStart(2, "0")}-${queryData.value.date.toString().padStart(2, "0")}`;
   let res = await punchInApi.queryPunchInHistory({ punchInDate });
-  piTaskHistoryData.value = res ? res : [];
+  calendarSelectedVOS.value = res.calendarSelectedVOS;
+  piTaskHistoryVOS.value = res.piTaskHistoryVOS;
+}
+
+// 加载数据
+const loadData = () => {
+  if (currentTabIndex.value == 0) {
+    loadStatPointsData();
+    loadStatNewUserData();
+    loadStatTaskData();
+  } else {
+    loadPunchInHistoryData();
+  }
 }
 
 
@@ -189,15 +208,11 @@ onLoad(() => {
 });
 
 onShow(() => {
-  loadStatPointsData();
-  loadStatNewUserData();
-  loadStatTaskData();
+  loadData();
 });
 
 onPullDownRefresh(() => {
-  loadStatPointsData();
-  loadStatNewUserData();
-  loadStatTaskData();
+  loadData();
   uni.stopPullDownRefresh();
 });
 </script>

+ 23 - 15
src/pages/task/taskDetail.vue

@@ -48,29 +48,29 @@
     <view class="stat-board-content">
       <view class="stat-item">
         <view class="stat-item-label">{{ currentTabIndex === 0 ? '本月' : '全年' }}需打卡</view>
-        <view class="stat-item-value">{{ statData.punchInTotalCount }}次</view>
+        <view class="stat-item-value">{{ statData.punchInTotalCount ? statData.punchInTotalCount : 0 }}次</view>
       </view>
       <view class="stat-item">
         <view class="stat-item-label">{{ currentTabIndex === 0 ? '本月' : '全年' }}已打卡</view>
-        <view class="stat-item-value">{{ statData.punchInCount }}次</view>
+        <view class="stat-item-value">{{ statData.punchInCount ? statData.punchInCount : 0 }}次</view>
       </view>
       <view class="stat-item">
         <view class="stat-item-label">完成打卡</view>
-        <view class="stat-item-value">{{ statData.punchInDoneCount }}次</view>
+        <view class="stat-item-value">{{ statData.punchInDoneCount ? statData.punchInDoneCount : 0 }}次</view>
       </view>
     </view>
     <view class="stat-board-content stat-mt16">
       <view class="stat-item">
         <view class="stat-item-label">打卡率</view>
-        <view class="stat-item-value">{{ statData.punchInRate }}%</view>
+        <view class="stat-item-value">{{ statData.punchInRate ? statData.punchInRate : 0 }}%</view>
       </view>
       <view class="stat-item">
         <view class="stat-item-label">完成率</view>
-        <view class="stat-item-value">{{ statData.punchInDoneRate }}%</view>
+        <view class="stat-item-value">{{ statData.punchInDoneRate ? statData.punchInDoneRate : 0 }}%</view>
       </view>
       <view class="stat-item">
         <view class="stat-item-label">{{ currentTabIndex === 0 ? '本月' : '全年' }}获取积分数</view>
-        <view class="stat-item-value">{{ statData.points }}</view>
+        <view class="stat-item-value">{{ statData.points ? statData.points : 0 }}</view>
       </view>
     </view>
   </view>
@@ -81,27 +81,32 @@
   </view>
 
   <uni-section title="打卡日志" padding="16px" type="line">
-    <uni-list>
-      <uni-list-item v-for="taskHistory in statData.piTaskHistoryStatVOS" :key="taskHistory.punchInDate">
+    <uni-list v-if="statData.piTaskHistoryVOS && statData.piTaskHistoryVOS.length > 0">
+      <uni-list-item v-for="taskHistory in statData.piTaskHistoryVOS" :key="taskHistory.punchInDate">
         <template v-slot:body>
           {{ taskHistory.punchInDate }}
           <span v-if="taskHistory.punchInResult == PUNCH_IN_RESULT.DONE"> 完成打卡</span>
           <span v-else> 未完成打卡</span>
           <span v-if="taskHistory.punchInMethod == PUNCH_IN_METHOD.COUNT">,打卡{{ taskHistory.countTrack }}次</span>
           <span v-if="taskHistory.punchInMethod == PUNCH_IN_METHOD.TIMING">,打卡时长{{ taskHistory.timeTrack }}</span>
+          <span v-if="taskHistory.settleResult == SETTLE_RESULT.SETTLED">,已结算,结算积分:{{ taskHistory.settlePoints
+          }}</span>
+          <span v-if="taskHistory.settleResult == SETTLE_RESULT.NOT_SETTLED">,无需结算</span>
+          <span v-if="!taskHistory.settleResult">,未结算</span>
         </template>
       </uni-list-item>
     </uni-list>
-    <uni-load-more status="no-more" v-if="statData.piTaskHistoryStatVOS.length == 0" />
+    <uni-load-more status="no-more" v-if="!statData.piTaskHistoryVOS || statData.piTaskHistoryVOS.length == 0" />
   </uni-section>
 
 </template>
 
 <script setup>
 import { ref } from 'vue';
-import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app';
+import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app';
 import { punchInApi } from '@/apis/apis';
 import { PUNCH_IN_RESULT, PUNCH_IN_METHOD, STAT_PERIOD } from '@/common/enums';
+import { SETTLE_RESULT } from '@/common/enums';
 
 // 属性
 /**
@@ -144,7 +149,7 @@ const defaultStatData = {
   punchInRate: 0,
   punchInDoneRate: 0,
   points: 0,
-  piTaskHistoryStatVOS: [],
+  piTaskHistoryVOS: [],
   lineVO: {}
 };
 
@@ -245,14 +250,11 @@ const plusYear = (num) => {
  * 加载数据
  */
 const loadData = async () => {
-  // chatLoadingType.value = 2;
   let res = await punchInApi.queryStat({
     "statPeriod": currentStatPeriod.value,
     "statTime": currentStatPeriod.value == STAT_PERIOD.MONTH ? currentMonth.value : currentYear.value,
     "taskId": currentTaskId.value
   });
-  // chatLoadingType.value = 0;
-  // 统计数据为空,则使用默认数据
   statData.value = res ? res : defaultStatData;
 }
 
@@ -267,10 +269,16 @@ onLoad(async (e) => {
 
   if (e.id) {
     currentTaskId.value = e.id;
-    loadData();
+    uni.setNavigationBarTitle({
+      title: e.title
+    });
   }
 });
 
+onShow(() => {
+  loadData();
+});
+
 onPullDownRefresh(() => {
   loadData();
   uni.stopPullDownRefresh();

+ 3 - 3
src/pages/taskList.vue

@@ -11,7 +11,7 @@
     </view>
     <view>
       <view class="task-item" v-for="task in tasks" :key="task.id">
-        <view class="main-box" @click="goTaskDetailPage(task.id)">
+        <view class="main-box" @click="goTaskDetailPage(task.id, task.taskName)">
           <view class="item-header">
             <span class="item-title">{{ task.taskName }}</span>
             <span class="item-reward">x{{ task.points }}</span>
@@ -109,9 +109,9 @@ const tasks = ref([]);
 /**
  * 跳转打卡任务详情页面
  */
-const goTaskDetailPage = (id) => {
+const goTaskDetailPage = (id, title) => {
   uni.navigateTo({
-    url: router.TASK_DETAIL_PAGE + "?id=" + id
+    url: router.TASK_DETAIL_PAGE + "?id=" + id + "&title=" + title
   });
 };
 

+ 3 - 3
src/pages/taskTodo.vue

@@ -11,7 +11,7 @@
       </view>
     </view>
     <view class="task-item" v-for="task in tasks" :key="task.id">
-      <view class="main-box" @click="goTaskDetailPage(task.id)">
+      <view class="main-box" @click="goTaskDetailPage(task.id, task.taskName)">
         <view class="item-header">
           <span class="item-title">{{ task.taskName }}</span>
           <span class="item-reward">x{{ task.points }}</span>
@@ -187,9 +187,9 @@ const goTaskEditPage = () => {
 /**
  * 跳转打卡详情页面
  */
-const goTaskDetailPage = (id) => {
+const goTaskDetailPage = (id, title) => {
   uni.navigateTo({
-    url: router.TASK_DETAIL_PAGE + "?id=" + id
+    url: router.TASK_DETAIL_PAGE + "?id=" + id + "&title=" + title
   });
 };