浏览代码

【feat】【第一版开发】

1.完善代码
ChenYL 1 年之前
父节点
当前提交
c0349fb335
共有 7 个文件被更改,包括 66 次插入21 次删除
  1. 3 3
      package.json
  2. 2 1
      pages.json
  3. 8 2
      pages/detail/detail.vue
  4. 28 4
      pages/index/index.vue
  5. 11 1
      pages/login/login.vue
  6. 12 1
      pages/userInfo/userInfo.vue
  7. 2 9
      utils/system.js

+ 3 - 3
package.json

@@ -6,21 +6,21 @@
 				"browser": "chrome",
 				"env": {
 					"UNI_PLATFORM": "h5",
-					"BASE_API_URL": "http://localhost:8080"
+					"BASE_API_URL": "/api"
 				}
 			},
 			"wp-dev": {
 				"title": "微信小程序 开发环境",
 				"env": {
 					"UNI_PLATFORM": "mp-weixin",
-					"BASE_API_URL": "http://localhost:8080"
+					"BASE_API_URL": "/api"
 				}
 			},
 			"wp-sit": {
 				"title": "微信小程序 sit-测试环境",
 				"env": {
 					"UNI_PLATFORM": "mp-weixin",
-					"BASE_API_URL": "http://192.168.1.41:8080"
+					"BASE_API_URL": "http://192.168.123.146:8080"
 				}
 			},
 			"wp-uat": {

+ 2 - 1
pages.json

@@ -3,7 +3,8 @@
 		{
 			"path": "pages/index/index",
 			"style": {
-				"navigationBarTitleText": "打卡结算"
+				"navigationBarTitleText": "打卡结算",
+				"enablePullDownRefresh": true
 			}
 		},
 		{

+ 8 - 2
pages/detail/detail.vue

@@ -56,7 +56,7 @@
 	import { ref } from 'vue';
 	import { onLoad } from '@dcloudio/uni-app';
 	import { punchInApi } from '@/service/apis';
-	import safeArea from '@/utils/system.js';
+	import { getSafeArea } from '@/utils/system.js';
 	
 	/**
 	 * 打卡任务
@@ -67,12 +67,18 @@
 		"fullAttendanceFlag": false
 	});
 	
+	/**
+	 * 安全区
+	 */
+	const safeArea = ref({});
+	
 	onLoad(async (e) => {
 		if (e.id) {
 			const res = await punchInApi.queryPunchInById({"id": e.id});
 			punchIn.value = res;
 		}
-	})
+		safeArea.value = getSafeArea();
+	});
 
 	const weekendDoubleSwitchChange = (e) => {
 		punchIn.value.weekendDoubleFlag = e.detail.value;

+ 28 - 4
pages/index/index.vue

@@ -14,7 +14,12 @@
 				height: safeArea.capsuleBarContentHeight+'px',
 				width: safeArea.capsuleBarContentHeight+'px',
 			}">
-				<uni-icons type="person" :size="safeArea.capsuleBarContentHeight" color="#FFFFFF"></uni-icons>
+				<!-- <uni-icons type="person" :size="safeArea.capsuleBarContentHeight" color="#FFFFFF"></uni-icons> -->
+				<image :style="{
+					height: safeArea.capsuleBarContentHeight+'px',
+					width: safeArea.capsuleBarContentHeight+'px',
+				}"
+			mode="aspectFill" src="https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132"></image>
 			</view>
 		</view>
 		
@@ -29,7 +34,8 @@
 			</view>
 			<view class="task-container">
 				<view class="task-header">
-					<view class="task-title">任务(3个)</view>
+					<view class="task-title" v-if="punchIns.length > 0">任务({{punchIns.lengt}}个)</view>
+					<view class="task-title" v-else>任务</view>
 					<view class="task-add-btn" @click="goPunchInDetailPage">
 						<uni-icons type="plusempty" size="30" color="#406CE7"></uni-icons>
 					</view>
@@ -76,8 +82,9 @@
 
 <script setup>
 	import { onMounted, ref } from 'vue';
+	import { onLoad, onPullDownRefresh } from "@dcloudio/uni-app";
 	import { rewardApi, punchInApi } from '@/service/apis.js';
-	import safeArea from '@/utils/system.js';
+	import { getSafeArea } from '@/utils/system.js';
 	
 	/**
 	 * 可领取奖励
@@ -94,6 +101,11 @@
 	 */
 	const claimRewardDialog = ref(null);
 	
+	/**
+	 * 安全区
+	 */
+	const safeArea = ref({});
+	
 	
 	/**
 	 * 领取奖励
@@ -151,7 +163,11 @@
 		uni.navigateTo({
 			url: "/pages/detail/detail"
 		})
-	}
+	};
+	
+	onLoad(() => {
+		safeArea.value = getSafeArea();
+	});
 	
 	onMounted(() => {
 		let token = uni.getStorageSync("token");
@@ -166,6 +182,14 @@
 		// 获取打卡
 		getPunchIn();
 	});
+	
+	onPullDownRefresh(() => {
+		// 获取奖励
+		getReward();
+		// 获取打卡
+		getPunchIn();
+		uni.stopPullDownRefresh();
+	});
 </script>
 
 <style lang="scss" scoped>

+ 11 - 1
pages/login/login.vue

@@ -38,8 +38,9 @@
 
 <script setup>
 	import { ref } from 'vue';
+	import { onLoad } from "@dcloudio/uni-app";
 	import { loginApi } from '@/service/apis.js';
-	import safeArea from '@/utils/system.js';
+	import { getSafeArea } from '@/utils/system.js';
 	
 	/**
 	 * 头像
@@ -51,6 +52,15 @@
 	 */
 	const nickname = ref("");
 	
+	/**
+	 * 安全区
+	 */
+	const safeArea = ref({});
+	
+	onLoad(() => {
+		safeArea.value = getSafeArea();
+	});
+	
 	const login = async () => {
 		// 获取供应商
 		let providerResult = await uni.getProvider({

+ 12 - 1
pages/userInfo/userInfo.vue

@@ -36,7 +36,18 @@
 </template>
 
 <script setup>
-	import safeArea from '@/utils/system.js';
+	import { ref } from 'vue';
+	import { onLoad } from "@dcloudio/uni-app";
+	import { getSafeArea } from '@/utils/system.js';
+	
+	/**
+	 * 安全区
+	 */
+	const safeArea = ref({});
+	
+	onLoad(() => {
+		safeArea.value = getSafeArea();
+	});
 	
 	const logout = () => {
 		uni.removeStorageSync("token");

+ 2 - 9
utils/system.js

@@ -72,17 +72,10 @@ export const getCapsuleBarInfo = () => {
  * capsuleBarContentHeight 胶囊按钮内容高度
  * @returns {{topHeight: number, bottomHeight: number, statusBarHeight: number, capsuleBarHeight: number, capsuleBarLeft: number, capsuleBarMarginTop: number, capsuleBarMarginBottom: number, capsuleBarContentHeight: number}}
  */
-const getSafeArea = () => {
+export const getSafeArea = () => {
 	let tempSafeArea = getCapsuleBarInfo();
 	tempSafeArea.statusBarHeight = getStatusBarHeight();
 	tempSafeArea.bottomHeight = SYSTEM_INFO.safeAreaInsets.bottom || 0;
 	tempSafeArea.topHeight = getStatusBarHeight() + tempSafeArea.capsuleBarHeight;
 	return tempSafeArea;
-}
-
-/**
- * 安全区数据
- */
-const safeArea = getSafeArea();
-
-export default safeArea;
+}