Explorar o código

登录页修改
增加记住密码功能

tanxue hai 1 mes
pai
achega
dc12d7f599
Modificáronse 2 ficheiros con 62 adicións e 95 borrados
  1. 32 0
      common/styles/global/pages.scss
  2. 30 95
      pages/login.vue

+ 32 - 0
common/styles/global/pages.scss

@@ -1,4 +1,36 @@
 /***** 这里存放通用页面样式 *****/
+.mobile-login-page {
+		width: 100%;height: 100%;background: #FFF;text-align: center;position: absolute;overflow: auto;
+		.login-top {height: 540rpx;background-size: cover;background-image: url("@/static/images/login/login-bj-sj.png");}
+		.login-logo {width: 266rpx;max-height: 100rpx;margin-top: 156rpx;}
+		.login-text {display: block;font-size: 64rpx;color: #FFF;margin: 24rpx 0 0;font-weight: 700}
+
+		// 登录区域
+		.login-body {
+			width: 100%;padding: 0 60px;box-sizing: border-box;margin: 140rpx auto 0;
+			.input-container {
+				display: flex;align-items: center;position: relative;
+				height: 100rpx;border-radius: 50rpx;background-color: #F7F7F7;
+				padding: 0;margin-bottom: 40rpx;
+			}
+			.input-icon {margin-left: 20rpx;color: #999;}
+
+		}
+
+		// 输入框
+		.login-btn {
+			width: 100%;height: 100rpx;margin-top: 60rpx;font-size: 36rpx;
+			letter-spacing: 7.2rpx;background: linear-gradient(0deg, #436aff 0%, #234ff7 100%);
+			border-radius: 50rpx;border: 0;color: #F7F7F7;line-height: 100rpx;
+		}
+
+		.login-change {
+			display: flex;justify-content: space-between;align-items: center;
+			.checkbox-zhanghao {font-size: 24rpx;color: #565656;}
+			.remember-checkbox-group{font-size: 28rpx;}
+		}
+	}
+	
 // 我的
 .mobile-my-page{
 	width:100%;height: calc(100vh - 180rpx);overflow: auto;background: #F3F5F7;padding-bottom: 60rpx;

+ 30 - 95
pages/login.vue

@@ -16,10 +16,8 @@
 				<input type="password" v-model="password" placeholder="请输入密码" class="input-item-1" />
 			</view>
 			<view class="login-change">
-				<checkbox-group>
-					<label class="checkbox-zhanghao">
-						<checkbox value="cb" color="#0550e5" checked="true"/>记住此账号
-					</label>
+				<checkbox-group  @change="rememberBtn" class="remember-checkbox-group">
+						<checkbox value="remember" color="#0550e5" checked="true" style="transform:scale(0.9)"/>记住此账号
 				</checkbox-group>
 				<text class="checkbox-zhanghao" @click="forgetPassword"> 忘记密码?</text>
 			</view>
@@ -43,6 +41,7 @@
 	let password = ref('')
 	let configData = ref(null)
 	let encryptedPassword = ref(''); // 用于存储加密后的密码
+	let rememberFlag = ref('remember');
 	 
 	// 密钥和偏移量(IV),需要转换为CryptoJS的WordArray格式
 	const key = CryptoJS.enc.Utf8.parse('ax58bc32hp54kt68');
@@ -61,8 +60,22 @@
 	 	getLoginInit()
 	 })
 	 
+	 // 记住密码
+	 function geiRemember(){
+		 if(rememberFlag.value ==='remember'){
+			 if(cacheManager.get('auth').userInfo){
+				 userName.value = cacheManager.get('auth').userInfo.userName;
+				 password.value = cacheManager.get('auth').userInfo.password;
+			 }
+		 }
+	 }
+	 function rememberBtn(data){
+		 rememberFlag.value = data.detail.value.toString();
+	 }
+	 
 	function getLoginInit(){
 		getLoginConfig();
+		geiRemember();
 	}
 	
 	function getLoginConfig(){
@@ -94,11 +107,21 @@
 			password: encryptedPassword.value,
 		}
 
-		console.log(req,'req');
 		login(req).then(res => {
 			// 接口数据记缓存
-			let mergedData = {...res.data, ...configData.value};
-			cacheManager.set('auth', mergedData)
+			if(rememberFlag.value ==='remember'){
+				let userInfo = {
+					userName: trimmedUserName,
+					password: password.value.trim(),
+				}
+				let mergedData = {...res.data, ...configData.value,userInfo};
+				cacheManager.set('auth', mergedData)
+			}else{
+				let mergedData = {...res.data, ...configData.value};
+				cacheManager.set('auth', mergedData)
+			}
+			
+			
 			// 待补充----判断checked信息,记缓存用户信息
 			
 			// 待补充根据后台返回值跳转不同页面
@@ -121,91 +144,3 @@
 		toast('请联系管理员修改密码!');
 	}
 </script>
-
-<style lang="scss" scoped>
-	.mobile-login-page {
-		width: 100%;
-		height: 100%;
-		background: #FFF;
-		text-align: center;
-		position: absolute;
-		overflow: auto;
-
-		.login-top {
-			height: 540rpx;
-			background-size: cover;
-			background-image: url("../static/images/login/login-bj-sj.png");
-			// logo
-
-		}
-
-		.login-logo {
-			width: 266rpx;
-			max-height: 100rpx;
-			margin-top: 156rpx;
-		}
-
-		.login-text {
-			display: block;
-			font-size: 64rpx;
-			color: #FFF;
-			margin: 24rpx 0 0;
-			font-weight: 700
-		}
-
-		// 登录区域
-		.login-body {
-			width: 100%;
-			padding: 0 60px;
-			box-sizing: border-box;
-			margin: 140rpx auto 0;
-
-			.input-container {
-				display: flex;
-				align-items: center;
-				/* 垂直对齐 */
-				position: relative;
-				height: 100rpx;
-				border-radius: 50rpx;
-				background-color: #F7F7F7;
-				padding: 0;
-				margin-bottom: 40rpx;
-
-			}
-
-			.input-icon {
-				margin-left: 20rpx;
-				/* 图标和输入框之间的间距 */
-				color: #999;
-			}
-
-
-		}
-
-		// 输入框
-		.login-btn {
-			width: 100%;
-			height: 100rpx;
-			margin-top: 60rpx;
-			font-size: 36rpx;
-			letter-spacing: 7.2rpx;
-			background: linear-gradient(0deg, #436aff 0%, #234ff7 100%);
-			border-radius: 50rpx;
-			border: 0;
-			color: #F7F7F7;
-			line-height: 100rpx;
-		}
-
-		.login-change {
-			display: flex;
-			justify-content: space-between;
-			align-items: center;
-
-			.checkbox-zhanghao {
-				font-size: 24rpx;
-				color: #565656;
-
-			}
-		}
-	}
-</style>