Ver Fonte

【feat】【第二版开发】

1.页面联调修复
ChenYL há 1 ano atrás
pai
commit
d6a916b09b

+ 70 - 51
pages/index/index.vue

@@ -6,7 +6,7 @@
 				<view class="user-icon">
 					<uni-icons type="person" size="30"></uni-icons>	
 				</view>
-				<span class="nickname" v-if="!userInfo">登录</span>
+				<span class="nickname" v-if="!userInfo" @click="goUserInfoPage">登录</span>
 				<span class="user-btn" v-if="userInfo" @click="goUserInfoPage">用户中心</span>
 			</view>
 			
@@ -17,35 +17,35 @@
 					<view class="split-box">
 						<view class="line-box">
 							<span>投入</span>
-							<span class="number-box">50</span>
+							<span class="number-box">¥{{userInfo.lotteryInvestAmount}}</span>
 						</view>
 						<view class="under-line-box">
 							<span>中奖</span>
-							<span class="number-box">100</span>
+							<span class="number-box">¥{{userInfo.lotteryWinAmount}}</span>
 						</view>
 					</view>
 					<view class="split-box">
 						<view class="line-box">
 							<span>已领取</span>
-							<span class="number-box">68</span>
+							<span class="number-box">{{userInfo.claimedRewardNum}}</span>
 						</view>
 						<view  class="under-line-box">
 							<span>总奖励</span>
-							<span class="number-box">100</span>
+							<span class="number-box">{{userInfo.totalRewardNum}}</span>
 						</view>
 					</view>	
 				</view>
 				<!-- 待领取奖励区 -->
 				<view class="right-box">
 					<view class="reward-title">待领取奖励数</view>
-					<view class="reward-num">24</view>
+					<view class="reward-num">{{userInfo.unclaimedRewardNum}}</view>
 					<view class="reward-btn-group">
 						<view class="reward-btn-left">全部领取</view>
 						<view class="reward-btn-right">部分领取</view>
 					</view>
 				</view>
 				<!-- 刷新按钮 -->
-				<view class="refresh-btn">
+				<view class="refresh-btn" @click="getUserInfo">
 					<uni-icons type="refreshempty" color="#406CE7"></uni-icons>	
 				</view>
 			</view>
@@ -61,15 +61,15 @@
 					</view>
 				</view>
 				<view class="task-item" v-for="punchIn in punchIns" :key="punchIn.punchInId">
-					<view class="main-box" @click="goPunchInDetailPage">
+					<view class="main-box" @click="goPunchInDetailPage(punchIn.punchInId)">
 						<view class="item-header">
 							<span class="item-title">{{punchIn.taskName}}</span>
-							<span class="item-reward">x88</span>
+							<span class="item-reward">x{{punchIn.rewardNum}}</span>
 							<view class="item-tag" v-if="punchIn.fullAttendanceFlag">全勤奖励</view>
 							<view class="item-tag" v-if="punchIn.weekendDoubleFlag">周末双倍</view>
 						</view>
 						<view class="item-desc">
-							规则:最少做金刚功两次,四次八部金刚功+一次长寿宫
+							规则:{{punchIn.description}}
 						</view>
 						<view class="item-detail-list">
 							<view class="item-detail" v-for="punchInRecord in punchIn.punchInRecords"
@@ -89,9 +89,18 @@
 							</view>
 						</view>
 					</view>
-					<view class="func-box">
-						<span>06:30</span>
-						<span>已完成</span>
+					<view class="func-box" v-if="punchIn.category == 0" @click="doPunchIn(punchIn.punchInId)">
+						<span>完成</span>
+					</view>
+					<view class="func-box" v-if="punchIn.category == 1" @click="doPunchIn(punchIn.punchInId)">
+						<span>{{punchIn.countTrack}}</span>
+						<span>计数</span>
+					</view>
+					<view class="func-box" v-if="punchIn.category == 2" @click="doPunchIn(punchIn.punchInId)">
+						<span>
+							{{punchIn.timeTrack.slice(0, 5)}}
+						</span>
+						<span>计时</span>
 					</view>
 				</view>
 			</view>
@@ -110,32 +119,48 @@
 <script setup>
 	import { onMounted, ref } from 'vue';
 	import { onLoad, onPullDownRefresh, onShow } from "@dcloudio/uni-app";
-	import { rewardApi, punchInApi } from '@/service/apis.js';
+	import { rewardApi, punchInApi, userApi } from '@/service/apis.js';
 	import router from '@/common/constants/router.js';
 
 	/**
-	 * 可领取奖励
+	 * 用户信息
 	 */
-	const reward = ref(0);
-
+	const userInfo = ref({
+		totalRewardNum: 0,
+		unclaimedRewardNum: 0,
+		claimedRewardNum: 0,
+		lotteryInvestAmount: 0.00,
+		lotteryWinAmount: 0.00
+	});
+	
 	/**
 	 * 打卡任务
 	 */
 	const punchIns = ref([]);
+	
+	/**
+	 * 获取用户信息
+	 */
+	const getUserInfo = async () => {
+		let res = await userApi.queryUserInfo();
+		userInfo.value = res;
+	}
 
 	/**
-	 * 领取奖励对话框
+	 * 获取打卡
 	 */
-	const claimRewardDialog = ref(null);
+	const getPunchIns = async () => {
+		let res = await punchInApi.queryPunchIns();
+		punchIns.value = res;
+	}
+	
 
 	/**
-	 * 用户信息
+	 * 领取奖励对话框
 	 */
-	const userInfo = ref(null);
+	const claimRewardDialog = ref(null);
 
-	const handleUserInfo = (e) => {
-		console.log(e);
-	}
+	
 
 	/**
 	 * 领取奖励
@@ -151,25 +176,10 @@
 		await rewardApi.claimReward({
 			"claimRewardNum": val
 		});
-		getReward();
+		// getReward();
 		claimRewardDialog.value.close();
 	}
 
-	/**
-	 * 获取奖励
-	 */
-	const getReward = async () => {
-		let res = await rewardApi.queryReward();
-		reward.value = res.unclaimedRewardNum;
-	}
-
-	/**
-	 * 获取打卡
-	 */
-	const getPunchIn = async () => {
-		let res = await punchInApi.queryPunchIn();
-		punchIns.value = res;
-	}
 
 	/**
 	 * 打卡
@@ -178,7 +188,7 @@
 		await punchInApi.doPunchIn({
 			id
 		});
-		getPunchIn();
+		getPunchIns();
 	}
 
 	/**
@@ -196,16 +206,16 @@
 	const goPunchInEditPage = () => {
 		uni.navigateTo({
 			url: router.PUNCHIN_EDIT_URL
-		})
+		});
 	};
 	
 	/**
 	 * 跳转打卡详情页面
 	 */
-	const goPunchInDetailPage = () => {
+	const goPunchInDetailPage = (id) => {
 		uni.navigateTo({
-			url: router.PUNCHIN_DETAIL_URL
-		})
+			url: router.PUNCHIN_DETAIL_URL + "?id=" + id
+		});
 	};
 	
 	/**
@@ -214,21 +224,29 @@
 	const loadData = async () => {
 		let token = uni.getStorageSync("token");
 		// 如果还没登录就结束获取数据
+		console.log(token);
 		if (!token) {
-			reward.value = 0;
+			userInfo.value = ref({
+				totalRewardNum: 0,
+				unclaimedRewardNum: 0,
+				claimedRewardNum: 0,
+				lotteryInvestAmount: 0.00,
+				lotteryWinAmount: 0.00
+			});
 			punchIns.value = [];
 			return;
 		}
 		
+		console.log("开始啦啦啦");
 		try {
 			uni.showLoading({
 				title: '加载中',
 				mask: true
 			});
-			// 获取奖励
-			getReward();
+			// 获取用户信息
+			getUserInfo();
 			// 获取打卡
-			getPunchIn();
+			getPunchIns();
 		} finally {
 			uni.hideLoading();
 		}
@@ -240,6 +258,7 @@
 	});
 
 	onPullDownRefresh(() => {
+		console.log('触发下拉刷星');
 		loadData();
 		uni.stopPullDownRefresh();
 	});
@@ -252,14 +271,13 @@
 		position: relative;
 		
 		.user-icon {
-			display: inline-block !important;
+			display: inline-flex !important;
 			
 			width: 72rpx;
 			height: 72rpx;
 			background: #FFFFFF;
 			border-radius: 50%;
 			
-			display: flex;
 			justify-content: center;
 			align-items: center;
 		}
@@ -591,6 +609,7 @@
 			}
 			
 			.func-box {
+				flex-shrink: 0;
 				width: 160rpx;
 				border-radius: 0rpx 24rpx 24rpx 0rpx;
 				background: #406CE7;

+ 48 - 8
pages/punchin-detail/punchin-detail.vue

@@ -1,5 +1,5 @@
 <template>
-	<main-layout :showHome="true">
+	<main-layout :showHome="true" :showBack="true">
 		<uni-calendar />	
 		<viwe class="info-box">
 			<view class="left">打卡:12次</view>
@@ -20,41 +20,81 @@
 </template>
 
 <script setup>
+	import { ref } from 'vue';
+	import { onLoad } from '@dcloudio/uni-app';
 	import router from '@/common/constants/router';
+	import { punchInApi } from '@/service/apis.js';
+	
+	const punchInId = ref(null);
 
 	const content = [{
 			text: '删除',
 			active: false,
 			iconPath: '/static/delete.svg',
-			selectedIconPath: '/static/delete-active.svg'
+			selectedIconPath: '/static/delete-active.svg',
+			func: "delete"
 		},
 		{
 			text: '归档',
 			active: false,
 			iconPath: '/static/archive.svg',
-			selectedIconPath: '/static/archive-active.svg'
+			selectedIconPath: '/static/archive-active.svg',
+			func: "archive"
+		},
+		{
+			text: '撤销',
+			active: false,
+			iconPath: '/static/revoke.svg',
+			selectedIconPath: '/static/revoke_active.svg',
+			func: "revoke"
 		},
 		{
 			text: '补卡',
 			active: false,
 			iconPath: '/static/append.svg',
-			selectedIconPath: '/static/append-active.svg'
+			selectedIconPath: '/static/append-active.svg',
+			func: "remake"
 		},
 		{
 			text: '编辑',
 			active: false,
 			iconPath: '/static/edit.svg',
-			selectedIconPath: '/static/edit-active.svg'
+			selectedIconPath: '/static/edit-active.svg',
+			func: "edit"
 		}
 	];
 	
 	const trigger = (e) => {
-		if (e.index == 3) {
+		if (e.item.func == 'delete') {
+			punchInApi.deletePunchIn({id: punchInId.value});
+			return;
+		}
+		if (e.item.func == 'archive') {
+			punchInApi.archivePunchIn({id: punchInId.value});
+			return;
+		}
+		if (e.item.func == 'revoke') {
+			punchInApi.revokePunchIn({id: punchInId.value});
+			return;
+		}
+		if (e.item.func == 'remake') {
+			punchInApi.revokePunchIn({id: punchInId.value});
+			return;
+		}
+		if (e.item.func == 'edit') {
 			uni.navigateTo({
-				url: router.PUNCHIN_EDIT_URL
-			})
+				url: router.PUNCHIN_EDIT_URL + "?id=" + punchInId.value
+			});
+			return;
 		}
 	}
+	
+	onLoad(async (e) => {
+		if (e.id) {
+			punchInId.value = e.id;
+			console.log(punchInId.value);
+		}
+	});
 </script>
 
 <style lang="scss" scoped>

+ 28 - 18
pages/punchin-edit/punchin-edit.vue

@@ -4,7 +4,7 @@
 			<uni-forms ref="baseForm" :modelValue="punchInData" :label-width="80">
 				<uni-section title="基本信息" padding="16px" type="line">
 					<uni-forms-item label="任务名称" required>
-						<uni-easyinput v-model="punchInData.name" placeholder="请输入任务名称" />
+						<uni-easyinput v-model="punchInData.taskName" placeholder="请输入任务名称" />
 					</uni-forms-item>
 					<uni-forms-item label="奖励数" required>
 						<uni-easyinput v-model="punchInData.rewardNum" placeholder="请输入奖励数" type="number" />
@@ -16,33 +16,33 @@
 						<uni-data-checkbox v-model="punchInData.fullAttendanceFlag" :localdata="range"></uni-data-checkbox>
 					</uni-forms-item>
 					<uni-forms-item label="打卡类型" required>
-						<uni-data-select :localdata="punchInTypeRange"></uni-data-select>
+						<uni-data-select :localdata="punchInTypeRange" v-model="punchInData.category"></uni-data-select>
 					</uni-forms-item>
 					<uni-forms-item label="规则描述">
-						<uni-easyinput type="textarea" v-model="punchInData.desc" placeholder="请输入自我介绍" />
+						<uni-easyinput type="textarea" v-model="punchInData.description" placeholder="请输入任务描述" />
 					</uni-forms-item>
 				</uni-section>
-				<uni-section title="计数配置" padding="16px" type="line">
+				<uni-section title="计数配置" padding="16px" type="line" v-if="punchInData.category == 1">
 					<uni-forms-item label="判断规则" required>
-						<uni-data-select :localdata="judgeTypeRange"></uni-data-select>
+						<uni-data-select :localdata="judgeTypeRange" v-model="punchInData.rule"></uni-data-select>
 					</uni-forms-item>
 					<uni-forms-item label="数值" required>
-						<uni-easyinput v-model="punchInData.rewardNum" placeholder="请输入奖励数" type="digit" />
+						<uni-easyinput v-model="punchInData.countTrack" placeholder="请输入目标数值" type="digit" />
 					</uni-forms-item>
 				</uni-section>
-				<uni-section title="计时配置" padding="16px" type="line">
+				<uni-section title="计时配置" padding="16px" type="line" v-if="punchInData.category == 2">
 					<uni-forms-item label="判断规则" required>
-						<uni-data-select :localdata="judgeTypeRange"></uni-data-select>
+						<uni-data-select :localdata="judgeTypeRange" v-model="punchInData.rule"></uni-data-select>
 					</uni-forms-item>
 					<uni-forms-item label="时间" required>
-						<picker mode="time" :value="punchInData.time">
-							<view class="pick-box">{{punchInData.time}}</view>
+						<picker mode="time" :value="punchInData.timeTrack" @change="timeChange">
+							<view class="pick-box">{{punchInData.timeTrack}}</view>
 						</picker>
 					</uni-forms-item>
 				</uni-section>
 				<view class="button-container">
-					<button type="default" style="width:300rpx;">取消</button>
-					<button type="primary" style="color:#ffffff;backgroundColor:#2A82E4;width:300rpx;">保存</button>
+					<button type="default" style="width:300rpx;" @click="cancel">取消</button>
+					<button type="primary" style="color:#ffffff;backgroundColor:#2A82E4;width:300rpx;" @click="savePunchIn">保存</button>
 				</view>
 			</uni-forms>
 		</template>
@@ -66,7 +66,10 @@
 		"rewardNum": 1,
 		"weekendDoubleFlag": 1,
 		"fullAttendanceFlag": 1,
-		"time": '12:00'
+		"category": 0,
+		"rule": 0,
+		"countTrack": 10,
+		"timeTrack": "00:00"
 	});
 	
 	/**
@@ -89,7 +92,7 @@
 	const punchInTypeRange = [
         { value: 0, text: "单次打卡" },
         { value: 1, text: "计数" },
-        { value: 2, text: "时" },
+        { value: 2, text: "时" },
       ];
 	  
 	const judgeTypeRange = [
@@ -102,23 +105,23 @@
 	onLoad(async (e) => {
 		if (e.id) {
 			const res = await punchInApi.queryPunchInById({"id": e.id});
-			punchIn.value = res;
+			punchInData.value = res;
 		}
 	});
 
 	const weekendDoubleSwitchChange = (e) => {
-		punchIn.value.weekendDoubleFlag = e.detail.value;
+		punchInData.value.weekendDoubleFlag = e.detail.value;
 	}
 	
 	const fullAttendanceSwitchChange = (e) => {
-		punchIn.value.fullAttendanceFlag = e.detail.value;
+		punchInData.value.fullAttendanceFlag = e.detail.value;
 	}
 	
 	/**
 	 * 保存打卡任务
 	 */
 	const savePunchIn = () => {
-		punchInApi.addPunchIn(punchIn.value).then(() => {
+		punchInApi.addPunchIn(punchInData.value).then(() => {
 			uni.showToast({
 				title: '保存成功',
 				icon: 'success',
@@ -136,6 +139,13 @@
 	const cancel = () => {
 		uni.navigateBack();
 	}
+	
+	/**
+	 * 时间选择监听
+	 */
+	const timeChange = (e) => {
+		punchInData.value.timeTrack = e.detail.value;
+	}
 </script>
 
 <style lang="scss" scoped>

+ 4 - 2
service/apis.js

@@ -1,9 +1,11 @@
 import * as loginApi from './loginApi.js';
 import * as punchInApi from './punchInApi.js';
 import * as rewardApi from './rewardApi.js';
+import * as userApi from './userApi.js';
 
 export {
 	loginApi,
 	punchInApi,
-	rewardApi
-}
+	rewardApi,
+	userApi
+}

+ 38 - 2
service/punchInApi.js

@@ -3,9 +3,9 @@ import request from "@/utils/request";
 /**
  * 查询打卡任务列表
  */
-export function queryPunchIn() {
+export function queryPunchIns() {
   return request({
-    url: "/punchIn/queryPunchIn"
+    url: "/punchIn/queryPunchIns"
   });
 }
 
@@ -75,4 +75,40 @@ export function queryPunchInById(data) {
     method: "post",
     data
   });
+}
+
+/**
+ * 归档打卡任务
+ * @param {Object} data
+ */
+export function archivePunchIn(data) {
+  return request({
+    url: "/punchIn/archivePunchIn",
+    method: "post",
+    data
+  });
+}
+
+/**
+ * 补卡
+ * @param {Object} data
+ */
+export function remakPunchIn(data) {
+  return request({
+    url: "/punchIn/remakPunchIn",
+    method: "post",
+    data
+  });
+}
+
+/**
+ * 撤销打卡
+ * @param {Object} data
+ */
+export function revokePunchIn(data) {
+  return request({
+    url: "/punchIn/revokePunchIn",
+    method: "post",
+    data
+  });
 }

+ 11 - 0
service/userApi.js

@@ -0,0 +1,11 @@
+import request from "@/utils/request";
+
+/**
+ * 获取用户信息
+ */
+export function queryUserInfo() {
+	return request({
+		url: '/user/queryUserInfo',
+		method: 'get'
+	});
+}

+ 1 - 0
static/revoke.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1734267918462" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1462" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M396.544 135.968L73.28 459.2a44.8 44.8 0 0 0 0 63.36l323.264 323.264a35.2 35.2 0 0 0 24.896 10.304l3.84-0.192a35.2 35.2 0 0 0 31.36-35.008l-0.032-189.024 10.656 0.416c146.08 7.2 278.304 80.256 359.68 196.032l47.36 67.456 10.56-81.792c2.272-17.856 3.424-35.936 3.424-54.144l-0.096-9.792c-5.216-227.968-191.84-412.096-424.672-422.144l-6.88-0.224V160.832a35.2 35.2 0 0 0-60.096-24.864z m-3.904 94.368v163.04l33.408-1.44c5.76-0.256 11.584-0.384 17.408-0.384l9.696 0.096c189.888 4.608 345.024 143.552 368.16 321.92l1.152 10.304-2.496-2.56c-97.664-96.768-232.192-153.536-376.512-153.536-6.688 0-13.344 0.096-19.968 0.32l-30.848 1.152v182.176L132.096 490.88l260.544-260.544z" fill="#2c2c2c" p-id="1463"></path></svg>

+ 1 - 0
static/revoke_active.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1734267918462" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1462" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M396.544 135.968L73.28 459.2a44.8 44.8 0 0 0 0 63.36l323.264 323.264a35.2 35.2 0 0 0 24.896 10.304l3.84-0.192a35.2 35.2 0 0 0 31.36-35.008l-0.032-189.024 10.656 0.416c146.08 7.2 278.304 80.256 359.68 196.032l47.36 67.456 10.56-81.792c2.272-17.856 3.424-35.936 3.424-54.144l-0.096-9.792c-5.216-227.968-191.84-412.096-424.672-422.144l-6.88-0.224V160.832a35.2 35.2 0 0 0-60.096-24.864z m-3.904 94.368v163.04l33.408-1.44c5.76-0.256 11.584-0.384 17.408-0.384l9.696 0.096c189.888 4.608 345.024 143.552 368.16 321.92l1.152 10.304-2.496-2.56c-97.664-96.768-232.192-153.536-376.512-153.536-6.688 0-13.344 0.096-19.968 0.32l-30.848 1.152v182.176L132.096 490.88l260.544-260.544z" fill="#1296db" p-id="1463"></path></svg>