Browse Source

修改登录,添加组织号登录

11wqe1 1 month ago
parent
commit
2656f7a6f7

+ 4 - 0
src/api/user.js

@@ -6,6 +6,10 @@ import { baseApi } from '@/config'
 export function eduGet() {
   return axios.get('//beta.api.cocorobo.cn/api/getcookieuserid')
 }
+// 获取组织
+export function GetSuffix(data) {
+  return axios.post('https://api.edu.cocorobo.cn/edu/admin/selectorganize', [data])
+}
 export function eduLogout() {
   return axios.post('//beta.api.cocorobo.cn/api/logout')
 }

File diff suppressed because it is too large
+ 0 - 0
src/assets/login/orgh.svg


File diff suppressed because it is too large
+ 0 - 0
src/assets/login/wxh.svg


File diff suppressed because it is too large
+ 0 - 0
src/assets/login/wxl.svg


+ 1 - 0
src/assets/login/zhh.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1753256030231" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="21700" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M962.2918493333334 320.4392023333333a488.106434 488.106434 0 0 0-104.935569-155.647926A488.106434 488.106434 0 0 0 511.04939733333333 21.333821333333333a488.106434 488.106434 0 0 0-346.306883 143.457455A488.106434 488.106434 0 0 0 21.333821333333333 511.04939733333333a488.106434 488.106434 0 0 0 143.457455 346.306883 488.106434 488.106434 0 0 0 346.258121 143.457455 488.106434 488.106434 0 0 0 346.306883-143.457455 488.106434 488.106434 0 0 0 143.457455-346.306883 486.741102 486.741102 0 0 0-38.521886-190.658957z m-46.470073 361.618114a437.686649 437.686649 0 0 1-92.550052 137.996124c-32.572937-110.689471-123.855179-196.656668-238.250553-222.988084a178.468486 178.468486 0 0 0 106.788521-162.913446c0-98.596524-80.944723-178.56601-180.760295-178.56601-99.76681 0-180.711533 79.969486-180.711533 178.56601a178.468486 178.468486 0 0 0 106.788521 162.913446c-114.444136 26.331416-205.677616 112.298613-238.250554 222.939322a437.686649 437.686649 0 0 1-127.073463-308.955281 437.832934 437.832934 0 0 1 128.633844-310.613185 437.881696 437.881696 0 0 1 310.613185-128.633844 437.832934 437.832934 0 0 1 310.613185 128.633844 437.832934 437.832934 0 0 1 128.682606 310.613185 436.41884 436.41884 0 0 1-34.523412 171.007919z" fill="#212121" p-id="21701"></path></svg>

+ 1 - 0
src/assets/login/zhl.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1753256030231" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="21700" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M962.2918493333334 320.4392023333333a488.106434 488.106434 0 0 0-104.935569-155.647926A488.106434 488.106434 0 0 0 511.04939733333333 21.333821333333333a488.106434 488.106434 0 0 0-346.306883 143.457455A488.106434 488.106434 0 0 0 21.333821333333333 511.04939733333333a488.106434 488.106434 0 0 0 143.457455 346.306883 488.106434 488.106434 0 0 0 346.258121 143.457455 488.106434 488.106434 0 0 0 346.306883-143.457455 488.106434 488.106434 0 0 0 143.457455-346.306883 486.741102 486.741102 0 0 0-38.521886-190.658957z m-46.470073 361.618114a437.686649 437.686649 0 0 1-92.550052 137.996124c-32.572937-110.689471-123.855179-196.656668-238.250553-222.988084a178.468486 178.468486 0 0 0 106.788521-162.913446c0-98.596524-80.944723-178.56601-180.760295-178.56601-99.76681 0-180.711533 79.969486-180.711533 178.56601a178.468486 178.468486 0 0 0 106.788521 162.913446c-114.444136 26.331416-205.677616 112.298613-238.250554 222.939322a437.686649 437.686649 0 0 1-127.073463-308.955281 437.832934 437.832934 0 0 1 128.633844-310.613185 437.881696 437.881696 0 0 1 310.613185-128.633844 437.832934 437.832934 0 0 1 310.613185 128.633844 437.832934 437.832934 0 0 1 128.682606 310.613185 436.41884 436.41884 0 0 1-34.523412 171.007919z" fill="#0663FE" p-id="21701"></path></svg>

File diff suppressed because it is too large
+ 0 - 0
src/assets/login/zzl.svg


+ 11 - 1
src/common/axios.config.js

@@ -34,7 +34,17 @@ axios.interceptors.request.use((config) => {
 		}else if (config.data && config.data[0].post === '1' && config.method === 'post') {
         // 如果 data 的第一个元素 post 值为 '1',则进行自定义序列化
         config.data = 'mode=' + Object.values(config.data[0]).join(',');
-    } else if (config.method === 'post' && config.data) {
+    } else if (config.method === 'post' && config.url.indexOf('https://api.edu.cocorobo.cn/edu/admin/selectorganize') !==-1 && config.data) {
+        // 处理其他 post 请求的参数序列化
+        const encoded = {};
+        for (const key in config.data[0]) {
+            if (Object.hasOwnProperty.call(config.data[0], key)) {
+                encoded[key] = encodeURIComponent(config.data[0][key]);
+            }
+        }
+        config.data = encoded; // 使用 qs 序列化数据
+    }
+     else if (config.method === 'post' && config.data) {
         // 处理其他 post 请求的参数序列化
         const encoded = {};
         for (const key in config.data[0]) {

+ 72 - 15
src/views/login/loginPage.vue

@@ -15,10 +15,24 @@
 					</div>
 					<span>{{ showLoginMessage.name }}</span>
 				</div>
-				<span v-if="['default', 'weChat'].includes(loginType)">登录</span>
+				<span v-if="['default', 'weChat','orgL'].includes(loginType)">登录</span>
 				<span v-if="['bind'].includes(loginType)">绑定账号</span>
 				<div class="lp_r_b_formArea">
-					<div class="fa_input" v-if="['default', 'bind'].includes(loginType)">
+					<div class="fa_input" v-if="['default', 'bind','orgL'].includes(loginType)">
+						<div class="fa_i_item" style="position: relative;" v-if="loginType == 'orgL'">
+							<span>组织号</span>
+							<div>
+								<input
+									type="text"
+									placeholder="请输入组织号"
+									v-model="SuffixData"
+									@input="getSuffix"
+								/>
+							</div>
+							<div style="border: none;font-size: 12px;position: absolute;left: 0;bottom: -70%;" v-if="SuffixData.trim()">
+								{{ orginfo.length ? orginfo[0].name :'该学校编号不存在' }}
+							</div>
+						</div>	
 						<div class="fa_i_item">
 							<span>账号</span>
 							<div>
@@ -78,7 +92,7 @@
 
 				<div
 					class="lp_r_b_btn"
-					v-if="loginType == 'default'"
+					v-if="['default','orgL'].includes(loginType)"
 					@click="loginFn"
 					v-loading="loading"
 				>
@@ -98,28 +112,41 @@
 					<div class="lp_r_b_btn" @click="loginType = 'default'">返回登录</div>
 				</div>
 				<div class="lp_r_b_line">
-					<template v-if="['default', 'weChat'].includes(loginType)">
+					<template v-if="['default', 'weChat','orgL'].includes(loginType)">
 						<div></div>
 						<span>其他登录方式</span>
 						<div></div>
 					</template>
 				</div>
 				<div class="lp_r_b_iconBtn">
+
+					<div
+						@click="loginType = 'orgL'"
+						v-if="['default', 'weChat','orgL'].includes(loginType)"
+					>
+						<el-tooltip effect="dark" content="组织号登录" placement="bottom">
+							<img :src="loginType == 'orgL' ? require('../../assets/login/zzl.svg') :require('../../assets/login/orgh.svg') "
+							:class="[loginType == 'orgL' ? 'backWin' : '']" />
+						</el-tooltip>
+					</div>
+
 					<div
 						@click="wechatLogin"
-						v-if="['default', 'weChat'].includes(loginType)"
+						v-if="['default', 'weChat','orgL'].includes(loginType)"
 					>
 						<el-tooltip effect="dark" content="微信登录" placement="bottom">
-							<img src="@/assets/login/wechat.svg" />
+							<img :src="loginType == 'weChat' ? require('../../assets/login/wxl.svg') :require('../../assets/login/wxh.svg') "
+							:class="[loginType == 'weChat' ? 'backWin' : '']" />
 						</el-tooltip>
 					</div>
 
 					<div
-						@click="loginType = 'default'"
-						v-if="['default', 'weChat'].includes(loginType)"
+						@click="loginType = 'default',SuffixData = ''"
+						v-if="['default', 'weChat','orgL'].includes(loginType)"
 					>
 						<el-tooltip effect="dark" content="账号密码登录" placement="bottom">
-							<img src="@/assets/login/account.svg" />
+							<img :src="loginType == 'default' ? require('../../assets/login/zhl.svg') :require('../../assets/login/zhh.svg') "
+							:class="[loginType == 'default' ? 'backWin' : '']" />
 						</el-tooltip>
 					</div>
 				</div>
@@ -135,6 +162,8 @@ import { API_CONFIG } from "@/common/apiConfig";
 import "@/common/wxLogin";
 import { getUser } from "@/api/user";
 import { loginOut } from "@/api/user";
+import { GetSuffix } from "@/api/user";
+
 import { myMixin } from "@/mixins/mixin.js"
 
 export default {
@@ -142,6 +171,12 @@ export default {
 	name: "loginPage",
 	data() {
 		return {
+			// 判断显示组织号区域 
+			SuffixShow: false,
+			// 组织号查询区域结果
+			SuffixData:'',
+			orginfo:[],
+			// 后缀 
 			org: "",
 			account: "",
 			password: "",
@@ -214,9 +249,24 @@ export default {
 			login: "user/login",
 			logout: "user/logout",
 		}),
+		// 获取组织后缀
+		async getSuffix(){
+			let res = await GetSuffix({mode: this.SuffixData})	
+			console.log('res.data[0]',res.data[0]);
+				
+			if (res.data[0].length) {
+				this.orginfo = res.data[0]
+				this.org = this.orginfo[0].mail
+			}else{
+				this.orginfo = []
+				this.org = ''
+			}
+		},
 		async loginFn() {
 			if (this.loading) return;
-			await this.getOrgData();
+			if (this.loginType != 'orgL') {
+				await this.getOrgData();	
+			}
 
 			const regEmail = new RegExp(
 				"^[A-Za-z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$"
@@ -232,11 +282,15 @@ export default {
 			}
 
 			let str = this.account.replace(/(^\s*)|(\s*$)/g, "");
-
 			if (!this.org && !regEmail.test(str)) {
-				return this.$message.error(
-					"请在账号后添加组织后缀(账号@组织号.com 如:123456@cocorobo.com)"
+				// this.$message.error(
+				// 	"请在账号后添加组织后缀(账号@组织号.com 如:123456@cocorobo.com)"
+				// );
+				this.$message.error(
+					"登录失败,请输入组织号"
 				);
+				this.loginType = 'orgL'
+				return
 			}
 
 			if (this.allowOrgList.findIndex((i) => i.area) != -1) {
@@ -244,7 +298,7 @@ export default {
 				let _list = this.allowOrgList[_index].list;
 				if (this.OrgOptions.find((i) => i.Uorg == this.org) && !_list.includes(this.OrgOptions.find((i) => i.Uorg == this.org).id)
 				) {
-					return this.$message.error("账号不可登陆,请联系管理员。");
+					return this.$message.error("账号不可使用,请使用您的专属网站。");
 				}
 			} else {
 				let mergedList = this.allowOrgList.reduce((acc, curr) => {
@@ -255,7 +309,7 @@ export default {
 						this.OrgOptions.find((i) => i.Uorg == this.org).id
 					)
 				) {
-					return this.$message.error("账号不可登陆,请联系管理员。");
+					return this.$message.error("账号不可使用,请使用您的专属网站。");
 				}
 			}
 
@@ -849,4 +903,7 @@ export default {
 	display: flex;
 	gap: 10px;
 }
+.backWin{
+	/* box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); */
+}
 </style>

Some files were not shown because too many files changed in this diff