xiaohaizhao 2 سال پیش
والد
کامیت
2f751d160e
4فایلهای تغییر یافته به همراه181 افزوده شده و 35 حذف شده
  1. 16 8
      pages/login/login.vue
  2. 30 11
      pages/login/modules/account.vue
  3. 82 0
      pages/login/modules/dispose.js
  4. 53 16
      pages/login/modules/phone.vue

+ 16 - 8
pages/login/login.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="container" style="background-image: url('../../static/login.gif');height:100vh;">
-		<view style="height: 200rpx;" />
+		<view :style="{ height: height }" />
 		<view class="logo">
 			<u--image src="/static/logo.png" width="294rpx" height="94rpx" mode="scaleToFill">
 				<template v-slot:loading>
@@ -9,8 +9,9 @@
 				<view slot="error" style="font-size: 24rpx;">加载失败</view>
 			</u--image>
 		</view>
-		<account v-show="loginMethod != 'account'" />
-		<phone v-show="loginMethod != 'phone'" />
+
+		<account v-show="loginMethod == 'account'" />
+		<phone v-show="loginMethod == 'phone'" />
 
 		<other-login :loginMethod="loginMethod" @onChange="changeLoginMethod" />
 	</view>
@@ -28,16 +29,23 @@ export default {
 	},
 	data() {
 		return {
-			loginMethod: "phone", //登录方式
+			loginMethod: "",
+			height: "",
 		};
 	},
-	onLoad() {
-		if (uni.getStorageSync('loginMethod')) this.loginMethod = uni.getStorageSync('loginMethod')
+	created() {
+		this.loginMethod = uni.getStorageSync('loginMethod') || 'account';//登录方式
+		// #ifdef H5
+		this.height = "200rpx";
+		// #endif
+		// #ifndef H5
+		this.height = "300rpx";
+		// #endif 
 	},
 	methods: {
 		/* 修改登录方式 */
-		changeLoginMethod(e) {
-			this.loginMethod = e;
+		changeLoginMethod(Method) {
+			this.loginMethod = Method;
 		}
 	}
 }

+ 30 - 11
pages/login/modules/account.vue

@@ -10,7 +10,7 @@
 		</view>
 		<view class="assist">
 			<label @click="memory = memory == '1' ? '0' : '1'">
-				<checkbox :class="memory == 1 ? 'checked blue' : 'blue'" />记住密码
+				<checkbox :checked="memory == 1" :class="memory == 1 ? 'checked blue' : 'blue'" />记住密码
 			</label>
 			<navigator url="#">忘记密码?</navigator>
 		</view>
@@ -24,6 +24,7 @@
 
 <script>
 import { hexMD5 } from "./md5";
+import { loginMsg } from "./dispose";
 export default {
 	name: "Account",
 	data() {
@@ -37,9 +38,10 @@ export default {
 		};
 	},
 	created() {
-		if (uni.getStorageSync("memory") != "") this.memory = uni.getStorageSync("memory");
-		if (uni.getStorageSync("account")) this.account = uni.getStorageSync("account");
+		this.account = uni.getStorageSync("account") || "";
+		this.memory = uni.getStorageSync("memory") || 0;
 	},
+
 	methods: {
 		/* 输入框输入内容 */
 		onInput(e) {
@@ -47,16 +49,33 @@ export default {
 		},
 		/* 开始登录 */
 		startLogging() {
+			if (this.loading) return;
 			this.loading = true;
-			uni.setStorageSync("memory", this.memory)
-			uni.setStorageSync("account", {
-				account: this.account.account,
-				password: this.memory == 1 ? this.account.password : ''
-			})
-			uni.setStorageSync("loginMethod", 'account')
-			setTimeout(() => {
+			this.$Http.login({
+				"accountno": this.account.account,
+				"password": hexMD5(this.account.password),
+				"systemclient": "wechat"
+			}).then(res => {
+				console.log("账号密码登录", res)
 				this.loading = false;
-			}, 1000)
+				if (res.code == 0) {
+					uni.showToast({
+						title: res.msg,
+						duration: 2000,
+						icon: "none"
+					});
+				} else {
+					//存储是否记住密码 以及登录方式
+					uni.setStorageSync("memory", this.memory + '');
+					uni.setStorageSync("loginMethod", 'account')
+					uni.setStorageSync("account", {
+						account: this.account.account,
+						password: this.memory == 1 ? this.account.password : ''
+					});
+					loginMsg(res.account_list)
+				}
+			})
+
 		}
 	}
 }

+ 82 - 0
pages/login/modules/dispose.js

@@ -0,0 +1,82 @@
+let count = 0; //接口完成数量
+
+function loginMsg(account_list) {
+    console.log(account_list)
+    uni.setStorageSync("account_list", account_list);
+    if (account_list.length == 1) {
+        uni.setStorageSync('userMsg', account_list[0])
+        query_userauth();
+        query_adspacelist();
+        querySite_Parameter();
+    } else {
+        wx.redirectTo({
+            url: '/pages/login/selectSite',
+            success: (res) => {},
+            fail: (res) => {},
+            complete: (res) => {
+                console.log(res)
+            },
+        })
+    }
+}
+/* 获取用户权限 */
+function query_userauth() {
+    _Http.basic({
+        "classname": "sysmanage.develop.userauth.userauth",
+        "method": "query_userauth",
+        content: {
+            nocache: true
+        }
+    }).then(res => {
+        console.log("查询用户权限", res)
+        if (res.msg != '成功') return uni.showToast({
+            title: res.msg,
+            icon: "none"
+        });
+        uni.setStorageSync('userauth', res.data);
+        count += 1;
+        toHome();
+    });
+}
+/* 查询站点数据 */
+function querySite_Parameter() {
+    _Http.basic({
+        id: 20230608103802,
+        "content": {}
+    }).then(res => {
+        console.log("查询站点数据", res)
+        if (res.msg != '成功') return uni.showToast({
+            title: res.msg,
+            icon: "none"
+        });
+        uni.setStorageSync('siteP', res.data);
+        count += 1;
+        toHome();
+    })
+}
+/* 查询轮播图 */
+function query_adspacelist(i = 0) {
+    _Http.basic({
+        id: 20230608100802,
+        "content": {}
+    }).then(res => {
+        console.log("查询轮播图", res)
+        if (res.msg != '成功') return uni.showToast({
+            title: res.msg,
+            icon: "none"
+        });
+        uni.setStorageSync('banner_list', res.data)
+        count += 1;
+        toHome();
+    })
+}
+
+function toHome() {
+    if (count < 3) return;
+    console.log("跳转首页")
+}
+/* 站点数据查询 */
+module.exports = {
+    loginMsg,
+    query_userauth
+}

+ 53 - 16
pages/login/modules/phone.vue

@@ -22,6 +22,9 @@
 <script>
 let countDown = null;
 import { hexMD5 } from "./md5";
+import { CheckPhoneNumber } from "../../../utils/basicInspection";
+import { loginMsg } from "./dispose";
+
 export default {
 	name: "Phone",
 	data() {
@@ -39,18 +42,31 @@ export default {
 		/* 获取验证码 */
 		getAuthcode() {
 			if (this.butText == '获取验证码' || this.butText == '重新获取') {
-				var count = 30;
-				this.butText = count + 's';
-				countDown = setInterval(() => {
-					if (count == 0) {
-						clearInterval(countDown);
-						this.butText = '重新获取';
-					} else {
-						count = count - 1;
-						this.butText = count + 's';
-					}
-				}, 1000)
-			}
+				if (!CheckPhoneNumber(this.phoneNumber, '请输入正确的手机号码')) return;
+				this.$Http.getpassword({
+					"phonenumber": this.phoneNumber,
+					"systemclient": "wechat"
+				}).then(res => {
+					console.log("获取验证码", res)
+					uni.showToast({
+						title: res.msg,
+						duration: 3000,
+						icon: "none",
+					});
+					if (res.code == 0) return;
+					var count = 30;
+					this.butText = count + 's';
+					countDown = setInterval(() => {
+						if (count == 0) {
+							clearInterval(countDown);
+							this.butText = '重新获取';
+						} else {
+							count = count - 1;
+							this.butText = count + 's';
+						}
+					}, 1000)
+				});
+			};
 		},
 		/* 输入框输入内容 */
 		onInput(e) {
@@ -58,12 +74,33 @@ export default {
 		},
 		/* 开始登录 */
 		startLogging() {
+			if (this.loading) return;
+			if (!CheckPhoneNumber(this.phoneNumber, '请输入正确的手机号码')) return;
+			if (this.password == "") return uni.showToast({
+				title: '还未填写验证码',
+				duration: 2000,
+				icon: "none",
+			});
 			this.loading = true;
-			uni.setStorageSync("loginMethod", 'phone');
-			uni.setStorageSync("phoneNumber", this.phoneNumber);
-			setTimeout(() => {
+			this.$Http.login({
+				"phonenumber": this.phonenumber,
+				"password": hexMD5(this.password),
+				"systemclient": "wechat"
+			}).then(res => {
+				console.log("验证码登录", res)
 				this.loading = false;
-			}, 1000)
+				if (res.code == 0) {
+					uni.showToast({
+						title: res.msg,
+						duration: 2000,
+						icon: "none"
+					});
+				} else {
+					uni.setStorageSync("phoneNumber", this.phoneNumber);
+					uni.setStorageSync("loginMethod", 'phone');
+					loginMsg(res.account_list)
+				}
+			})
 		}
 	}
 }