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/index.vue |  322 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 322 insertions(+), 0 deletions(-)

diff --git a/pages/sys/login/index.vue b/pages/sys/login/index.vue
new file mode 100644
index 0000000..4fa471d
--- /dev/null
+++ b/pages/sys/login/index.vue
@@ -0,0 +1,322 @@
+<template>
+	<view class="wrap">
+		<view class="login-back-img"></view>
+		<!--鍥介檯鍖�-->
+		<js-lang title="login.title" :showBtn="false"></js-lang>
+		<view
+			style="background-color: #fff;z-index:20;width:750rpx;margin-top:514rpx;padding-bottom: 70rpx;border-radius: 20rpx;">
+			<view class="logo">娆㈣繋鐧诲綍</view>
+
+			<!--鐢ㄦ埛鍚嶅瘑鐮佺櫥褰�-->
+			<user-password />
+
+
+			<view class="chooseServer" @click="chooseServer.visible = true" v-if="env == 'production'">
+				鏈嶅姟鍣ㄥ湴鍧�閫夋嫨
+			</view>
+		</view>
+		<u-popup v-model="chooseServer.visible" mode="bottom">
+			<view class="chooseServer__content">
+				<u-radio-group v-model="chooseServer.type" :wrap="true">
+					<u-radio v-for="(item, index) in serverList" :key="item.type" :name="item.type">
+						<view v-if="index < 2">
+							<u-field v-model="item.url" :label="item.name" label-width="70" disabled />
+						</view>
+						<view v-else>
+							<u-field v-model="chooseServer.url" label-width="70" :label="item.name" />
+						</view>
+					</u-radio>
+				</u-radio-group>
+				<view class="button" hover-class="button-hover" @click="serverSure()">
+					<text>纭</text>
+				</view>
+			</view>
+		</u-popup>
+
+		<!-- #ifdef MP -->
+		<button class="button" @click.stop="getUserProfile" :disabled="btnLoading" :loading="btnLoading">
+			<text>{{ $t("login.vxLoginButton") }}</text>
+		</button>
+		<!-- #endif -->
+		<!-- <view class="login-bottom-box">
+			<view class="copyright">
+				姹熻嫃涓ぉ浜掕仈绉戞妧鏈夐檺鍏徃鐗堟潈鎵�鏈�</br>Copyright 漏2024.All Rights Reserved.
+			</view>
+		</view> -->
+	</view>
+</template>
+<script>
+import userPassword from "./userPassword";
+import config from '@/common/config.js';
+
+export default {
+	components: {
+		userPassword
+	},
+	data() {
+		return {
+			env: config.env,
+			btnLoading: false,
+			chooseServer: {
+				visible: false,
+				type: 2,
+				url: ''
+			}
+		};
+	},
+	computed: {
+		serverList() {
+			return [{
+				type: 0,
+				name: '鍐呯綉',
+				url: 'http://rfcable.chinaztt.cn'
+			}, {
+				type: 1,
+				name: '澶栫綉',
+				url: 'http://rfcable.chinaztt.cn:8200'
+			}, {
+				type: 2,
+				name: '鍏朵粬',
+				url: ''
+			}]
+		}
+	},
+	onLoad() {
+		//宸茬粡鐧诲綍 璺宠浆鍒伴椤�
+		if (this.vuex_token) {
+			uni.reLaunch({
+				url: "/pages/sys/home/index",
+			});
+		}
+	},
+	onShow() {
+		if (this.vuex_config.baseUrl === 'http://rfcable.chinaztt.cn') {
+			this.chooseServer.type = 0
+		} else if (this.vuex_config.baseUrl === 'http://rfcable.chinaztt.cn:8200') {
+			this.chooseServer.type = 1
+		} else {
+			this.chooseServer.type = 2
+			this.chooseServer.url = this.vuex_config.baseUrl
+		}
+	},
+	methods: {
+		serverSure() {
+			let baseUrl = ''
+			if (this.chooseServer.type == 0) {
+				baseUrl = 'http://rfcable.chinaztt.cn'
+			} else if (this.chooseServer.type == 1) {
+				baseUrl = 'http://rfcable.chinaztt.cn:8200'
+			} else {
+				if (this.IsURL(this.chooseServer.url)) {
+					baseUrl = this.chooseServer.url
+				} else {
+					this.$u.toast("鍦板潃杈撳叆涓嶆纭�");
+					return
+				}
+			}
+			let config = this.vuex_config
+			config.baseUrl = baseUrl
+			this.$u.vuex("vuex_config", config);
+			this.$u.http.setConfig({
+				baseUrl
+			});
+			this.$u.toast("璁剧疆鎴愬姛");
+			this.chooseServer.visible = false
+		},
+		IsURL(str_url) {
+			var strRegex = "^((https|http|ftp|rtsp|mms)?://)" +
+				"?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp鐨剈ser@ 
+				+
+				"(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP褰㈠紡鐨刄RL- 199.194.52.184 
+				+
+				"|" // 鍏佽IP鍜孌OMAIN锛堝煙鍚嶏級
+				+
+				"([0-9a-z_!~*'()-]+\.)*" // 鍩熷悕- www. 
+				+
+				"([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 浜岀骇鍩熷悕 
+				+
+				"[a-z]{2,6})" // first level domain- .com or .museum 
+				+
+				"(:[0-9]{1,4})?" // 绔彛- :80 
+				+
+				"((/?)|" // a slash isn't required if there is no file name 
+				+
+				"(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
+			var re = new RegExp(strRegex);
+			//re.test()
+			if (re.test(str_url)) {
+				return (true);
+			} else {
+				return (false);
+			}
+		},
+		getUserProfile() {
+			this.btnLoading = true;
+			//鑾峰彇code锛岀劧鍚庤皟鐢ㄥ井淇$櫥褰曟帴鍙e垽鏂槸鍚︾櫥褰� 401鍒欒烦杞埌缁戝畾椤甸潰
+			var tmp = this;
+			uni.login({
+				provider: "weixin",
+				success: function (res) {
+					console.log("code", res.code);
+
+					let grant_type = "mobile";
+					let code = res.code;
+
+					tmp.$u.api
+						.vxLogin({
+							grant_type,
+							code,
+						}, {
+							Authorization: "Basic c29jaWFsOnNvY2lhbA==",
+						})
+						.then((res) => {
+							tmp.btnLoading = false;
+							//鎻愮ず
+							tmp.$u.toast("鎭枩鎮紝鐧诲綍鎴愬姛锛�");
+
+							// 鐧婚檰鎴愬姛锛屽瓨鍌ㄧ浉鍏充俊鎭�
+							tmp.$u.vuex("vuex_token", res.access_token);
+							tmp.$u.vuex("vuex_refresh_token", res.refresh_token);
+							tmp.$u.vuex("vuex_username", res.username);
+							tmp.$u.vuex("vuex_userId", res.user_id);
+							tmp.$u.vuex("vuex_client_id", res.client_id);
+
+							//鏌ヨ鐢ㄦ埛璇︾粏淇℃伅骞跺偍瀛�
+							tmp.$u.api.user.getUserInfo().then((res) => {
+								console.log("鑾峰彇鐢ㄦ埛淇℃伅:", res);
+								tmp.$u.vuex("vuex_user", res.data.sysUser);
+							});
+
+							//璺宠浆椤甸潰
+							setTimeout(() => {
+								uni.reLaunch({
+									url: "/pages/sys/home/index",
+								});
+							}, 500);
+						})
+						.catch((e) => {
+							tmp.btnLoading = false;
+							if (e.statusCode === 401 || e.message === "鐢ㄦ埛涓嶅瓨鍦�") {
+								console.log(
+									"鐢ㄦ埛鏈粦瀹氾紝璇蜂娇鐢� sys_user 琛ㄥ瓨鍦ㄧ殑鎵嬫満鍙疯繘琛岀粦瀹�"
+								);
+								tmp.$u.toast(
+									"鐢ㄦ埛鏈粦瀹氾紝璇蜂娇鐢� sys_user 琛ㄥ瓨鍦ㄧ殑鎵嬫満鍙疯繘琛岀粦瀹�"
+								);
+								uni.reLaunch({
+									url: "/pages/sys/login/bindUser",
+								});
+								console.log("椤甸潰璺宠浆...");
+							}
+						});
+				},
+			});
+		},
+	},
+};
+</script>
+<style lang="scss">
+@import "index.scss";
+
+.login-back-img {
+	background-image: url('~@/static/custom/login/img_bg.png');
+	background-size: 100% auto;
+	background-repeat: no-repeat;
+	position: absolute;
+	left: 0;
+	top: 0;
+	width: 750rpx;
+	height: 540rpx;
+}
+
+
+.logo {
+	width: 90%;
+	font-size: 48rpx;
+	color: #333333;
+	margin: 50rpx auto 0;
+	margin-left: 80rpx;
+	text-align: left;
+	font-weight: bold;
+}
+
+.list-call-icon {
+	color: #ff0000;
+}
+
+.currentPhone-box {
+	text-align: center;
+	padding: 40rpx 80rpx;
+
+	.number-text {
+		color: #000000;
+		font-size: 60rpx;
+	}
+
+	.other-text {
+		color: #999999;
+		font-size: 26rpx;
+		padding: 20rpx 0;
+	}
+
+	.u-btn {
+		margin: 30rpx auto;
+	}
+
+	.u-hairline-border {
+		border: 1px solid #fff;
+	}
+}
+
+
+
+.register {
+	display: inline-block;
+	color: #497bff;
+	height: 40rpx;
+	line-height: 40rpx;
+	font-size: 28rpx;
+	float: right;
+	margin-top: 6rpx;
+}
+
+.register-link {
+	float: right;
+	padding: 0 16rpx;
+}
+
+.reg-link {
+	display: inline-block;
+	color: #497bff;
+}
+
+.oauth2 {
+	display: flex;
+	flex-direction: row;
+	justify-content: space-around;
+	margin: 0rpx 100rpx 30rpx;
+
+	image {
+		height: 80rpx;
+		width: 80rpx;
+	}
+}
+
+.u-tabs {
+	padding: 0 70rpx;
+}
+
+.chooseServer {
+	margin: 20px 35px 20px 35px;
+	text-align: right;
+	text-decoration: underline;
+}
+
+.chooseServer__content {
+	padding: 20rpx 40rpx;
+
+	::v-deep .u-radio__label {
+		flex: 1;
+	}
+}
+</style>

--
Gitblit v1.9.3