From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 28 五月 2025 16:48:52 +0800
Subject: [PATCH] 初始化项目

---
 pages/sys/login/userPassword.vue |  177 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 177 insertions(+), 0 deletions(-)

diff --git a/pages/sys/login/userPassword.vue b/pages/sys/login/userPassword.vue
new file mode 100644
index 0000000..42d1f45
--- /dev/null
+++ b/pages/sys/login/userPassword.vue
@@ -0,0 +1,177 @@
+<template>
+  <view>
+    <view class="list">
+      <view class="list-call">
+        <u-icon class="u-icon" size="40" name="account"></u-icon>
+        <input
+          class="u-input"
+          type="text"
+          v-model="userInfo.username"
+          maxlength="32"
+          :placeholder="$t('login.placeholderAccount')"
+        />
+      </view>
+      <view class="list-call">
+        <u-icon class="u-icon" size="40" name="lock"></u-icon>
+        <input
+          class="u-input"
+          type="text"
+          v-model="userInfo.password"
+          maxlength="32"
+          :placeholder="$t('login.placeholderPassword')"
+          :password="!showPassword"
+        />
+        <image
+          class="u-icon-right"
+          :src="
+            '/static/custom/login/eye_' +
+            (showPassword ? 'open' : 'close') +
+            '.png'
+          "
+          @click="showPass()"
+        ></image>
+      </view>
+      <u-radio-group v-model="remember" style="margin-top: 30rpx;" @change="checkboxChange">
+        <u-radio shape="square" name="1" :checked="1" >璁颁綇瀵嗙爜</u-radio>
+      </u-radio-group>
+    </view>
+    <view class="button custom-botton" hover-class="button-hover" @click="submit()">
+      <text>{{ $t("login.loginButton") }}</text>
+    </view>
+  </view>
+</template>
+
+<script>
+import { encryption } from "@/utils";
+
+export default {
+	name: "userPassword",
+	data() {
+		return {
+			userInfo: {
+				username: "",
+				password: ""
+			},
+			showPassword: false,
+			remember: '',
+			baseUrl: "",
+		};
+	},
+	created() {
+		if (process.env.NODE_ENV == 'development') {
+			// this.userInfo = {
+			//      username: "admin",
+			// 	password: "zttZTT123!"
+			// }
+		}
+		this.remember = uni.getStorageSync('remember');
+		// 妫�鏌ユ湰鍦板瓨鍌ㄤ腑鏄惁鏈夎浣忕殑鐢ㄦ埛鍚嶅拰瀵嗙爜
+		const savedUsername = uni.getStorageSync('username');
+		const savedPassword = uni.getStorageSync('password');
+		if (savedUsername && savedPassword) {
+			this.userInfo.username = savedUsername;
+			this.userInfo.password = savedPassword;
+		}
+	},
+	methods: {
+		showPass() {
+			this.showPassword = !this.showPassword;
+		},
+		//鐧诲綍
+		submit() {
+			//琛ㄥ崟鏍¢獙
+			if (this.userInfo.username.length === 0) {
+				this.$u.toast("璇疯緭鍏ヨ处鍙�");
+				return;
+			}
+			if (this.userInfo.password.length === 0) {
+				this.$u.toast("璇疯緭鍏ュ瘑鐮�");
+				return;
+			}
+
+			//鏋勯�犵櫥褰曞弬鏁�
+			const user = encryption({
+				data: this.userInfo,
+				key: "pigxpigxpigxpigx",
+				param: ["password"],
+			});
+
+			let grant_type = "password";
+			//鐧诲綍鎺ュ彛
+			this.$u.api
+					.login(
+							{
+								randomStr: 'blockPuzzle',
+								code: '',
+								grant_type
+							},
+							{
+								username: user.username,
+								password: user.password
+							},
+							{
+								Authorization: "Basic cGlnOnBpZw==",
+								"content-type": "application/x-www-form-urlencoded",
+								isToken: false,
+								"TENANT-ID": "1",
+							}
+					)
+					.then((res) => {
+						//鎻愮ず
+						this.$u.toast("鎭枩鎮紝鐧诲綍鎴愬姛锛�");
+						if (this.remember == 1) {
+							uni.setStorageSync('username', this.userInfo.username);
+							uni.setStorageSync('password', this.userInfo.password);
+							uni.setStorageSync('remember', this.remember);
+						} else {
+							// 濡傛灉鐢ㄦ埛鏈嬀閫夆�滆浣忔垜鈥濓紝娓呴櫎鏈湴瀛樺偍涓殑鐢ㄦ埛鍚嶅拰瀵嗙爜
+							uni.removeStorageSync('username');
+							uni.removeStorageSync('password');
+							uni.removeStorageSync('remember');
+						}
+						console.log('dadasd', res)
+						// 鐧婚檰鎴愬姛锛屽瓨鍌ㄧ浉鍏充俊鎭�
+						this.$u.vuex("vuex_token", res.access_token);
+						this.$u.vuex("vuex_refresh_token", res.refresh_token);
+						this.$u.vuex("vuex_username", res.user_info.staffName);
+						this.$u.vuex("vuex_userId", res.user_info.id);
+						//this.$u.vuex("vuex_client_id", res.client_id);
+						this.$u.vuex("vuex_user", res.user_info);
+
+						//鏌ヨ鐢ㄦ埛璇︾粏淇℃伅骞跺偍瀛�
+						/*this.$u.api.user.getUserInfo().then((res) => {
+            console.log("鑾峰彇鐢ㄦ埛淇℃伅:", res);
+            this.$u.vuex("vuex_user", res.data.sysUser);
+          });*/
+
+						//璺宠浆椤甸潰
+						setTimeout(() => {
+							uni.reLaunch({
+								url: "/pages/sys/home/index",
+							});
+						}, 500);
+					})
+					.catch((e) => {
+						this.$u.toast(e);
+					});
+		},
+		checkboxChange(e) {
+			console.log('e---', e)
+			this.remember = e
+			console.log('this.remember222---', this.remember)
+		}
+	}
+}
+</script>
+
+<style lang="scss">
+@import "index.scss";
+
+.custom-botton{
+		height: 96rpx;
+		background: #214DED;
+		box-shadow: 0rpx 6rpx 8rpx 0rpx rgba(4,49,212,0.3);
+		border-radius: 16rpx;
+		line-height: 96rpx;
+	}
+</style>

--
Gitblit v1.9.3