Преглед изворни кода

refactor(edit):新增个人信息修改项
fix(edit,personal_message):个人信息没有正常回显

HMY пре 1 година
родитељ
комит
52c9dc9cfa

+ 12 - 0
api/mine.js

@@ -179,3 +179,15 @@ export function getAttendanceRule(unitId) {
 	})
 }
 
+//修改个人信息
+export function updateMyInfo({ userId,qqnum,sex,birthday,email }) {
+	return request({
+		url: preUrl,
+		method: 'post',
+		data: {
+			serviceId: "miniapp_updateMyInfo",
+			params: { userId,qqnum,sex,birthday,email }
+		}
+	})
+}
+

+ 23 - 22
pages/login.vue

@@ -54,32 +54,33 @@ function handleLogin() {
 	}
 }
 function loginSuccess() {
-	userStore.GetInfo()
-	// 是否在上班打卡时间段
-	configStore.GetAttRule(userStore.user).then(()=>{
-		console.log('======',configStore.signInTimeRange);
-		if (isInTimeRange(...configStore.signInTimeRange)) {
-			const now = new Date()
-			const params = {
-				universalid: userStore.useId,
-				rizi: (now.getFullYear()) + '-' + (now.getMonth() + 1) + '-' + (now.getDate())
-			}
-			// 获取当天考勤信息
-			checkAttendance(params).then(({ returnParams }) => {
-				if (returnParams.list.length) {
-					// 已签到 跳转消息页
-					$tab.reLaunch('/pages/message/index')
-				} else {
-					// 未签到 跳转考勤页面
-					$tab.reLaunch('/pages/message/index?to=clockIn')
+	userStore.GetInfo().then(()=>{
+		// 是否在上班打卡时间段
+		configStore.GetAttRule(userStore.user).then(()=>{
+			if (isInTimeRange(...configStore.signInTimeRange)) {
+				const now = new Date()
+				const params = {
+					universalid: userStore.useId,
+					rizi: (now.getFullYear()) + '-' + (now.getMonth() + 1) + '-' + (now.getDate())
 				}
-			})
-		} else {
-			$tab.reLaunch('/pages/message/index')
-		}
+				// 获取当天考勤信息
+				checkAttendance(params).then(({ returnParams }) => {
+					if (returnParams.list.length) {
+						// 已签到 跳转消息页
+						$tab.reLaunch('/pages/message/index')
+					} else {
+						// 未签到 跳转考勤页面
+						$tab.reLaunch('/pages/message/index?to=clockIn')
+					}
+				})
+			} else {
+				$tab.reLaunch('/pages/message/index')
+			}
+		})
 	})
 	
 	
+	
 }
 //判断时间是否在区间内
 function isInTimeRange(start, end) {

+ 11 - 5
pages/mine/checkIn/checkIn.vue

@@ -478,15 +478,18 @@
 						data: [
 							{
 								"name": "缺勤",
-								"value": myWeekAttData.type6
+								"value": myWeekAttData.type6,
+								"labelText": "缺勤:" + myWeekAttData.type6 + "次"
 							},
 							{
 								"name": "迟到",
-								"value": myWeekAttData.type4
+								"value": myWeekAttData.type4,
+								"labelText": "迟到:" + myWeekAttData.type4 + "次"
 							},
 							{
 								"name": "早退",
-								"value": myWeekAttData.type5
+								"value": myWeekAttData.type5,
+								"labelText": "迟到:" + myWeekAttData.type5 + "次"
 							},
 							{
 								"name": "出勤",
@@ -495,15 +498,18 @@
 							},
 							{
 								"name": "外出",
-								"value": myWeekAttData.type1
+								"value": myWeekAttData.type1,
+								"labelText": "外出:" + myWeekAttData.type1 + "次"
 							},
 							{
 								"name": "公休",
-								"value": myWeekAttData.type2
+								"value": myWeekAttData.type2,
+								"labelText": "公休:" + myWeekAttData.type2 + "次"
 							},
 							{
 								"name": "未排班",
 								"value": myWeekAttData.type3,
+								"labelText": "未排班:" + myWeekAttData.type3 + "次"
 							}
 						]
 					}],

+ 120 - 46
pages/mine/edit/edit.vue

@@ -8,33 +8,33 @@
 		</view> -->
 
 		<!-- 邮箱输入框 -->
-		<!-- <view class="input-group">
+		<view class="input-group">
 			<text class="title">邮箱:</text>
-			<input type="text" v-model="userInfo.mail" placeholder="请输入邮箱地址" />
-		</view> -->
+			<input type="text" v-model="userInfo.email" placeholder="请输入邮箱地址" />
+		</view>
 		
-		<!-- qq输入框 -->
+		<!-- qqnum输入框 -->
 		<view class="input-group">
 			<text class="title">qq:</text>
-			<input type="text" v-model="userInfo.qq" placeholder="请输入qq" />
+			<input type="text" v-model="userInfo.qqnum" placeholder="请输入qq" />
 		</view>
 		
 		<!-- msn输入框 -->
-		<view class="input-group">
+		<!-- <view class="input-group">
 			<text class="title">msn:</text>
 			<input type="text" v-model="userInfo.msn" placeholder="请输入msn" />
-		</view>
+		</view> -->
 
 		<!-- 用户生日输入框 -->
-		<!-- <view class="input-group">
+		<view class="input-group">
 			<text class="title">用户生日:</text>
 			<view class="example-body">
 				<uni-datetime-picker type="date" :clear-icon="false" v-model="userInfo.birthday" @maskClick="maskClick" />
 			</view>
-		</view> -->
+		</view>
 		
 		<!-- 性别选择器 -->
-		<!-- <view class="sex-selector">
+		<view class="sex-selector">
 			<radio-group @change="handleGenderChange">
 				<text class="title">性别:</text>
 				<view class="sexLabel">
@@ -46,7 +46,7 @@
 					</label>
 				</view>
 			</radio-group>
-		</view> -->
+		</view>
 
 		<!-- 提交按钮 -->
 		<view class="primaryBtn">
@@ -56,24 +56,21 @@
 </template>
 
 <script setup lang="ts">
-	import {
-		ref,
-		reactive,
-		onMounted
-	} from 'vue';
+	import {ref,reactive,onMounted} from 'vue';
 	import { useUserStore } from '@/store/user';
-	import { modifyMe } from '@/api/mine';
-	import $modal from '@/plugins/modal.js'
+	import { modifyMe,updateMyInfo } from '@/api/mine';
+	import $modal from '@/plugins/modal.js';
+	import $tab from '@/plugins/tab.js'
 	// 定义用户信息的响应式对象
 	const thisUser=useUserStore().user;
 	let userInfo = reactive({
-		staffId:thisUser.useId,
+		userId:thisUser.useId,
 		// desktopPhone: thisUser.desktopPhone,
-		// mail: thisUser.email,
-		// sex: thisUser.sex,
-		// birthday: thisUser.birthday,
-		qq:thisUser.qqnum,
-		msn:thisUser.msnnum
+		email: thisUser.email,
+		sex: thisUser.sex,
+		birthday: thisUser.birthday,
+		qqnum:thisUser.qqnum,
+		// msn:thisUser.msnnum
 	});
 	onMounted(()=>{
 		console.log('thisUser',thisUser);
@@ -81,9 +78,9 @@
 	})
 	
 	
-	// function handleGenderChange(event) {
-	// 	userInfo.sex = event.detail.value; // 更新性别
-	// };
+	function handleGenderChange(event) {
+		userInfo.sex = event.detail.value; // 更新性别
+	};
 	
 	// // 校验手机号码格式
 	// function validatePhone(desktopPhone) {
@@ -91,11 +88,11 @@
 	// 	return desktopPhoneRegex.test(desktopPhone);
 	// }
 
-	// // 校验邮箱格式
-	// function validateEmail(mail) {
-	// 	const mailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; // 邮箱格式正则
-	// 	return mailRegex.test(mail);
-	// }
+	// 校验邮箱格式
+	function validateEmail(email) {
+		const mailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; // 邮箱格式正则
+		return mailRegex.test(email);
+	}
 
 	// 处理提交事件
 	function handleSubmit() {
@@ -107,22 +104,29 @@
 		// 	return; // 终止提交
 		// }
 		
-		// if (!validateEmail(userInfo.mail)) {
-		// 	uni.showToast({
-		// 		title: '邮箱格式不正确',
-		// 		icon: 'none'
-		// 	});
-		// 	return; // 终止提交
-		// }
-		modifyMe(userInfo).then(res=>{
-			// console.log(res);
+		if (userInfo.email!==""&&!validateEmail(userInfo.email)) {
+			$modal.showToast('邮箱格式不正确')
+			return; // 终止提交
+		}
+		// modifyMe(userInfo).then(res=>{
+		// 	// console.log(res);
+		// 	if("success"==res.returnMsg){
+		// 		$modal.showToast('修改成功');
+		// 		useUserStore().GetInfo().then(res=>{
+		// 			console.log("GetInfo",res);
+		// 		})
+		// 	}
+		// })
+		updateMyInfo(userInfo).then(res=>{
 			if("success"==res.returnMsg){
 				$modal.showToast('修改成功');
 				useUserStore().GetInfo().then(res=>{
 					console.log("GetInfo",res);
 				})
+				setTimeout(()=>{
+					$tab.navigateBack();
+				},1000)
 			}
-			
 		})
 
 		
@@ -155,15 +159,85 @@
 			margin-bottom: 20rpx;
 		}
 	}
-
-	.sex-selector label {
-		margin-right: 15rpx;
+	.sex-selector{
+		.sexLabel {
+			margin-top: 10px;
+			padding: 20rpx 20rpx;
+			background-color: white;
+			border: 1px solid gainsboro;
+			label {
+				margin-right: 15rpx;
+			}
+		}
 	}
-
+	
 	.primaryBtn {
 		margin-top: 70rpx;
 		button {
 			font-size: calc(18px + .5*(1rem - 16px));
 		}
 	}
+	::v-deep .uni-date {
+		.uni-date-x {
+			padding: 10rpx 20rpx !important;
+			height: 70rpx !important;
+			.uni-icons {
+				font-size: calc(22px + 1.2*(1rem - 16px)) !important;
+				font-weight: 500;
+			}
+		
+			.uni-date__x-input {
+				height: auto;
+				font-size: calc(14px + 1.2*(1rem - 16px)) !important;
+				font-weight: 500;
+			}
+		}
+	}
+	::v-deep .uni-calendar__content {
+		margin: -20px;
+		margin-top: 20px;
+		.uni-calendar__header {
+			.uni-calendar__header-text {
+				font-size: calc(14px + .5*(1rem - 16px)) !important;
+			}
+			.uni-calendar__backtoday {
+				padding: 2px 8px 2px 10px !important;
+				font-size: calc(0.75rem + 0px) !important;
+			}
+		}
+		.uni-calendar__box {
+			.uni-calendar__weeks {
+				.uni-calendar__weeks-day {
+					.uni-calendar__weeks-day-text {
+						font-size: calc(14px + .5*(1rem - 16px)) !important;
+					}
+				}
+				.uni-calendar__weeks-item {
+					.uni-calendar-item__weeks-box-item {
+						.uni-calendar-item__weeks-box-circle {
+							width: calc(8px + .5*(1rem - 16px)) !important;
+							height: calc(8px + .5*(1rem - 16px)) !important;
+							top: calc(5px - .25*(1rem - 16px)) !important;
+							right: calc(5px - .25*(1rem - 16px)) !important;
+						}
+						.uni-calendar-item__weeks-box-text {
+							font-size: calc(14px + .5*(1rem - 16px)) !important;
+						}
+						.uni-calendar-item__weeks-lunar-text {
+							font-size: calc(12px + .5*(1rem - 16px)) !important;
+						}
+					}
+				}
+			}
+		}
+		.uni-date-changed {
+			.uni-date-changed--time-date {
+				font-size: calc(14px + 1*(1rem - 16px)) !important;
+			}
+			.uni-datetime-picker-text {
+				font-size: calc(14px + 1*(1rem - 16px)) !important;
+			}
+		}
+	}
+
 </style>

+ 15 - 6
pages/mine/personal_message/personal_message.vue

@@ -17,33 +17,40 @@
 		<view class="contact-info">
 			<view class="info-item">
 				<view>
-					<uni-icons type="phone" size="20"></uni-icons>
+					<uni-icons type="phone-filled" size="20"></uni-icons>
 					<text>手机</text>
 				</view>
-				<text v-if="userInfo.desktop_phone==null" class="lastText">{{ '暂无' }}</text>
+				<text v-if="!userInfo.desktop_phone" class="lastText">{{ '暂无' }}</text>
 				<text v-else class="copyText" @click="copyPhone">{{ userInfo.desktop_phone }}</text>
 			</view>
 			<view class="info-item">
 				<view>
-					<uni-icons type="email" size="20"></uni-icons>
+					<uni-icons type="email-filled" size="20"></uni-icons>
 					<text>邮箱</text>
 				</view>
 				<text class="lastText">{{ userInfo.email || '暂无' }}</text>
 			</view>
+			<view class="info-item">
+				<view>
+					<uni-icons type="qq" size="20"></uni-icons>
+					<text>qq</text>
+				</view>
+				<text class="lastText">{{ userInfo.qqnum || '暂无' }}</text>
+			</view>
 		</view>
 
 		<!-- 个人信息 -->
 		<view class="personal-info">
 			<view class="info-item">
 				<view>
-					<uni-icons type="person" size="20"></uni-icons>
+					<uni-icons type="person-filled" size="20"></uni-icons>
 					<text>性别</text>
 				</view>
 				<text class="lastText">{{ sexDict[userInfo.sex] || '暂无' }}</text>
 			</view>
 			<view class="info-item">
 				<view>
-					<uni-icons type="star" size="20"></uni-icons>
+					<uni-icons type="star-filled" size="20"></uni-icons>
 					<text>生日</text>
 				</view>
 				<text class="lastText">{{ userInfo.birthday || '暂无' }}</text>
@@ -89,7 +96,9 @@
 	})
 	const headImg=ref()
 	function setHeadImg() { // TODO 直接返回 不创建变量
-		headImg.value=config.baseUrlPre + (userInfo.value.photo==""?config.defaultAvatarPath:userInfo.value.photo)
+		const isEmpty = (value) => value == "" || value == null || value == undefined
+		console.log('isEmpty(userInfo.value.photo): ',isEmpty(userInfo.value.photo));
+		headImg.value=config.baseUrlPre + (isEmpty(userInfo.value.photo)?config.defaultAvatarPath:userInfo.value.photo)
 	}
 	function copyPhone() {
 		uni.showModal({

+ 46 - 0
pages/process/index.vue

@@ -433,4 +433,50 @@ function handleToCancelProcess(process) {
 		}
 	}
 }
+::v-deep .uni-calendar__content {
+	margin: -20px;
+	margin-top: 20px;
+	.uni-calendar__header {
+		.uni-calendar__header-text {
+			font-size: calc(14px + .5*(1rem - 16px)) !important;
+		}
+		.uni-calendar__backtoday {
+			padding: 2px 8px 2px 10px !important;
+			font-size: calc(0.75rem + 0px) !important;
+		}
+	}
+	.uni-calendar__box {
+		.uni-calendar__weeks {
+			.uni-calendar__weeks-day {
+				.uni-calendar__weeks-day-text {
+					font-size: calc(14px + .5*(1rem - 16px)) !important;
+				}
+			}
+			.uni-calendar__weeks-item {
+				.uni-calendar-item__weeks-box-item {
+					.uni-calendar-item__weeks-box-circle {
+						width: calc(8px + .5*(1rem - 16px)) !important;
+						height: calc(8px + .5*(1rem - 16px)) !important;
+						top: calc(5px - .25*(1rem - 16px)) !important;
+						right: calc(5px - .25*(1rem - 16px)) !important;
+					}
+					.uni-calendar-item__weeks-box-text {
+						font-size: calc(14px + .5*(1rem - 16px)) !important;
+					}
+					.uni-calendar-item__weeks-lunar-text {
+						font-size: calc(12px + .5*(1rem - 16px)) !important;
+					}
+				}
+			}
+		}
+	}
+	.uni-date-changed {
+		.uni-date-changed--time-date {
+			font-size: calc(14px + 1*(1rem - 16px)) !important;
+		}
+		.uni-datetime-picker-text {
+			font-size: calc(14px + 1*(1rem - 16px)) !important;
+		}
+	}
+}
 </style>

+ 11 - 11
store/user.js

@@ -18,6 +18,7 @@ import {
 	reLogin,
 	keepSession
 } from '@/api/login.js'
+import $modal from '@/plugins/modal.js'
 
 
 export const useUserStore = defineStore('user', () => {
@@ -46,10 +47,10 @@ export const useUserStore = defineStore('user', () => {
 			login(username, password)
 				.then(res => {
 					useId.value = res.returnParams.useId // 设置staffId
-					user.value = res.returnParams
+					// user.value = res.returnParams
 					//保存账号密码
 					uni.setStorageSync('loginInfo', loginInfo)
-					if(username.includes('@')){
+					if (username.includes('@')) {
 						username = username.split('@')[0]
 					}
 					reLogin(username, password).then((res) => {
@@ -69,17 +70,16 @@ export const useUserStore = defineStore('user', () => {
 
 	function GetInfo(index) {
 		const roleIndex = index || 0
+		if (useId.value == 0) {
+			useId.value = uni.getStorageSync('userInfo').useId
+		}
 		return new Promise((resolve, reject) => {
 			getInfo(useId.value).then(res => {
-					const source = res.returnParams[roleIndex]
-					Object.keys(source).forEach(key => {
-						// 目标对象没有该属性或者该属性为 null,则赋值
-						if (!(key in user.value) || user.value[key] === null || user.value[
-								key] === "") {
-							user.value[key] = source[key] === undefined ? user.value[key] :
-								source[key];
-						}
-					});
+					if ("Exception" == res.returnMsg) {
+						$modal.msgError(res.returnParams)
+						reject(res.returnParams)
+					}
+					user.value = res.returnParams[roleIndex]
 					// 保存 用户信息
 					uni.setStorageSync('userInfo', user.value)
 					resolve(res)