loginPage.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926
  1. <template>
  2. <div class="loginPage">
  3. <div class="lp_left">
  4. <img :src="showLoginMessage.banner" />
  5. </div>
  6. <div class="lp_right">
  7. <div class="lp_r_box">
  8. <div class="lp_r_b_logo">
  9. <div>
  10. <el-image
  11. v-if="showLoginMessage.logo"
  12. style="width: 35px; height: 35px; border-radius: 50%"
  13. :src="showLoginMessage.logo"
  14. ></el-image>
  15. </div>
  16. <span v-if="showLoginMessage.name">{{ showLoginMessage.name }}</span>
  17. <span style="margin: 0;" v-else>可可乐博智慧教育平台</span>
  18. </div>
  19. <span v-if="['default', 'weChat','orgL'].includes(loginType)">登录</span>
  20. <span v-if="['bind'].includes(loginType)">绑定账号</span>
  21. <div class="lp_r_b_formArea">
  22. <div class="fa_input" v-if="['default', 'bind','orgL'].includes(loginType)">
  23. <div class="fa_i_item" style="position: relative;" v-if="loginType == 'orgL'">
  24. <span>组织号</span>
  25. <div>
  26. <input
  27. type="text"
  28. placeholder="请输入组织号"
  29. v-model="SuffixData"
  30. @input="getSuffix"
  31. />
  32. </div>
  33. <div style="border: none;font-size: 12px;position: absolute;left: 0;bottom: -70%;" v-if="SuffixData.trim()">
  34. {{ orginfo.length ? orginfo[0].name :'该学校编号不存在' }}
  35. </div>
  36. </div>
  37. <div class="fa_i_item">
  38. <span>账号</span>
  39. <div>
  40. <!-- @change="getOrgData" -->
  41. <input
  42. type="text"
  43. placeholder="请输入账号"
  44. v-model="account"
  45. @keyup.enter="loginFn"
  46. />
  47. </div>
  48. </div>
  49. <!-- <div class="fa_i_item">
  50. <span>组织</span>
  51. <div>
  52. <el-select
  53. v-model="org"
  54. :popper-append-to-body="false"
  55. placeholder="请选择"
  56. :disabled="
  57. (OrgOptions.length == 1 && org) || OrgOptions.length == 0
  58. "
  59. >
  60. <el-option
  61. v-for="item in OrgOptions"
  62. :key="item.Uorg"
  63. :label="
  64. item.name
  65. ? item.name + '-' + item.schoolName
  66. : item.schoolName
  67. "
  68. :value="item.Uorg"
  69. >
  70. </el-option>
  71. </el-select>
  72. </div>
  73. </div> -->
  74. <div class="fa_i_item">
  75. <span>密码</span>
  76. <div>
  77. <input
  78. type="password"
  79. placeholder="请输入密码"
  80. v-model="password"
  81. @keyup.enter="loginFn"
  82. />
  83. </div>
  84. </div>
  85. </div>
  86. <div class="fa_weChat" v-if="['weChat'].includes(loginType)">
  87. <div id="QRcode" class="QRcode" ref="QRcode"></div>
  88. <!-- @click="loginType = 'bind'" -->
  89. </div>
  90. </div>
  91. <div
  92. class="lp_r_b_btn"
  93. v-if="['default','orgL'].includes(loginType)"
  94. @click="loginFn"
  95. v-loading="loading"
  96. >
  97. 登录
  98. </div>
  99. <div
  100. class="lp_r_b_btn"
  101. v-if="loginType == 'weChat'"
  102. style="opacity: 0; cursor: default"
  103. >
  104. 账号密码登录
  105. </div>
  106. <div class="btn_box" v-if="loginType == 'bind'">
  107. <div class="lp_r_b_btn" @click="loginFn" v-loading="loading">
  108. 确认绑定
  109. </div>
  110. <div class="lp_r_b_btn" @click="loginType = 'default'">返回登录</div>
  111. </div>
  112. <div class="lp_r_b_line">
  113. <template v-if="['default', 'weChat','orgL'].includes(loginType)">
  114. <div></div>
  115. <span>其他登录方式</span>
  116. <div></div>
  117. </template>
  118. </div>
  119. <div class="lp_r_b_iconBtn">
  120. <div
  121. @click="loginType = 'orgL'"
  122. v-if="['default', 'weChat','orgL'].includes(loginType) && (allowOrgList.findIndex((i) => i.area) == -1)"
  123. >
  124. <el-tooltip effect="dark" content="组织号登录" placement="bottom">
  125. <img :src="loginType == 'orgL' ? require('../../assets/login/zzl.svg') :require('../../assets/login/orgh.svg') "
  126. :class="[loginType == 'orgL' ? 'backWin' : '']" />
  127. </el-tooltip>
  128. </div>
  129. <div
  130. @click="wechatLogin"
  131. v-if="['default', 'weChat','orgL'].includes(loginType)"
  132. >
  133. <el-tooltip effect="dark" content="微信登录" placement="bottom">
  134. <img :src="loginType == 'weChat' ? require('../../assets/login/wxl.svg') :require('../../assets/login/wxh.svg') "
  135. :class="[loginType == 'weChat' ? 'backWin' : '']" />
  136. </el-tooltip>
  137. </div>
  138. <div
  139. @click="loginType = 'default',SuffixData = ''"
  140. v-if="['default', 'weChat','orgL'].includes(loginType)"
  141. >
  142. <el-tooltip effect="dark" content="账号密码登录" placement="bottom">
  143. <img :src="loginType == 'default' ? require('../../assets/login/zhl.svg') :require('../../assets/login/zhh.svg') "
  144. :class="[loginType == 'default' ? 'backWin' : '']" />
  145. </el-tooltip>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. </template>
  152. <script>
  153. import { mapActions } from "vuex";
  154. import axios from "axios";
  155. import qs from "qs";
  156. import { API_CONFIG } from "@/common/apiConfig";
  157. import "@/common/wxLogin";
  158. import { getUser } from "@/api/user";
  159. import { loginOut } from "@/api/user";
  160. import { GetSuffix } from "@/api/user";
  161. import { myMixin } from "@/mixins/mixin.js"
  162. export default {
  163. mixins: [ myMixin ],
  164. name: "loginPage",
  165. data() {
  166. return {
  167. // 判断显示组织号区域
  168. SuffixShow: false,
  169. // 组织号查询区域结果
  170. SuffixData:'',
  171. orginfo:[],
  172. // 后缀
  173. org: "",
  174. account: "",
  175. password: "",
  176. loading: false,
  177. loginType: "default",
  178. redirect: this.$route.query["redirect"],
  179. org2:
  180. this.$route.query["org"] ||
  181. (window.location.href.includes("/liyuan")
  182. ? window.sessionStorage.getItem("org2")
  183. : ""),
  184. oid: this.$route.query["oid"],
  185. // 组织列表
  186. OrgOptions: [],
  187. form: {},
  188. showName: "",
  189. oloading: false,
  190. openid: "",
  191. allowOrgList: [
  192. {
  193. area:
  194. parent.location.href.includes("lyxx") ||
  195. parent.location.href.includes("liyuan"),
  196. banner:"https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/20250421-1139511745206807965.jpg",
  197. logo:"https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/image%2051744962188550.svg",
  198. name:"荔园小学教育集团",
  199. list: [
  200. "3823a6a5-1b6e-11f0-a66a-005056924926",
  201. "292e34dc-1b6e-11f0-a66a-005056924926",
  202. "21d6b367-1b6e-11f0-a66a-005056924926",
  203. "1a1a172d-1b6e-11f0-a66a-005056924926",
  204. "1197f86b-1b6e-11f0-a66a-005056924926",
  205. "f235659b-1b6d-11f0-a66a-005056924926",
  206. "d87b62d3-1b6d-11f0-a66a-005056924926",
  207. "c25ea59b-1b6d-11f0-a66a-005056924926",
  208. ],
  209. },
  210. ],
  211. };
  212. },
  213. watch: {
  214. loginType(newValue) {
  215. if (newValue != "weChat") {
  216. this.$refs.QRcode.innerHTML = "";
  217. }
  218. },
  219. },
  220. computed:{
  221. showLoginMessage(){
  222. let _result = {
  223. banner:require("@/assets/login2.jpg"),
  224. logo:"",
  225. name:"",
  226. };
  227. if(this.allowOrgList.findIndex((i) => i.area) != -1){
  228. let _index = this.allowOrgList.findIndex((i) => i.area);
  229. let _obj = this.allowOrgList[_index];
  230. _result.banner = _obj.banner;
  231. _result.name = _obj.name;
  232. _result.logo = _obj.logo
  233. }
  234. return _result;
  235. },
  236. },
  237. methods: {
  238. ...mapActions({
  239. login: "user/login",
  240. logout: "user/logout",
  241. }),
  242. // 获取组织后缀
  243. async getSuffix(){
  244. let res = await GetSuffix({mode: this.SuffixData})
  245. console.log('res.data[0]',res.data[0]);
  246. if (res.data[0].length) {
  247. this.orginfo = res.data[0]
  248. this.org = this.orginfo[0].mail
  249. }else{
  250. this.orginfo = []
  251. this.org = ''
  252. }
  253. },
  254. async loginFn() {
  255. if (this.loading) return;
  256. if (this.loginType != 'orgL') {
  257. await this.getOrgData();
  258. }
  259. const regEmail = new RegExp(
  260. "^[A-Za-z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$"
  261. );
  262. if (this.account.length <= 0) {
  263. this.$message.error("请输入账号");
  264. return;
  265. }
  266. if (this.password.length < 6 || /[\u4e00-\u9fa5]/.test(this.password)) {
  267. this.$message.error("密码长度不少于6位或者密码包含特殊字符、中文");
  268. return;
  269. }
  270. if (this.allowOrgList.findIndex((i) => i.area) != -1) {
  271. let _index = this.allowOrgList.findIndex((i) => i.area);
  272. let _list = this.allowOrgList[_index].list;
  273. if (this.OrgOptions.find((i) => i.Uorg == this.org) && !_list.includes(this.OrgOptions.find((i) => i.Uorg == this.org).id)
  274. ) {
  275. return this.$message.error("账号不可登录,请使用您的专属网址");
  276. }
  277. } else {
  278. let mergedList = this.allowOrgList.reduce((acc, curr) => {
  279. return [...acc, ...curr.list];
  280. }, []);
  281. if (
  282. mergedList.includes(
  283. this.OrgOptions.find((i) => i.Uorg == this.org).id
  284. )
  285. ) {
  286. return this.$message.error("账号不可登录,请使用您的专属网址");
  287. }
  288. }
  289. let str = this.account.replace(/(^\s*)|(\s*$)/g, "");
  290. if (!this.org && !regEmail.test(str)) {
  291. // this.$message.error(
  292. // "请在账号后添加组织后缀(账号@组织号.com 如:123456@cocorobo.com)"
  293. // );
  294. this.$message.error(
  295. "该账号须使用“组织号登陆”"
  296. );
  297. this.loginType = 'orgL'
  298. return
  299. }
  300. let orgValue = this.org ? "@" + this.org : "@cocorobo.cc";
  301. let email = "";
  302. // 判断用户输入账户带不带后缀
  303. if (!regEmail.test(str)) {
  304. email = str + orgValue;
  305. } else {
  306. email = str;
  307. }
  308. if (['default','orgL'].includes(this.loginType)) {
  309. let params = {
  310. geetest_challenge: "",
  311. geetest_validate: "",
  312. geetest_seccode: "",
  313. loginUsername: email.trim(),
  314. loginPassword: window.btoa(this.password.trim()),
  315. };
  316. this.loading = true;
  317. axios.defaults.withCredentials = true;
  318. console.log("👇");
  319. axios
  320. .post("https://beta.api.cocorobo.cn/api/user", qs.stringify(params))
  321. .then(async (res) => {
  322. console.log("res", res);
  323. let _data = res.data[0][0];
  324. let userjson = await getUser({ userid: _data.userid });
  325. console.log("userjson", userjson);
  326. if (_data.active === 1) {
  327. window.localStorage["identity"] = JSON.stringify(_data.identity);
  328. this.$message.success("登录成功");
  329. window.topU.U.UF.Cookie.set("cocoroboLoginType=2");
  330. window.topU ? window.topU.US.userInfo = _data : window.top.US.userInfo = _data
  331. await this.login();
  332. this.addOp3('1', "", { type:this.prefixL + "login" }, "success",_data.userid)
  333. if (
  334. userjson.data[0][0].type == 1 &&
  335. userjson.data[0][0].role == 1 &&
  336. userjson.data[0][0].rrole == 1
  337. ) {
  338. this.$router.push({ path: "/kanban" });
  339. } else {
  340. this.$router.push({ path: this.redirect || "/" });
  341. }
  342. } else {
  343. this.$message.error("登录失败");
  344. }
  345. this.loading = false;
  346. })
  347. .catch((e) => {
  348. if (e.response && e.response.data == "Wrong email or password") {
  349. this.$message.error("账号或密码错误");
  350. } else {
  351. this.$message.error("登录失败");
  352. }
  353. this.loading = false;
  354. });
  355. } else if (this.loginType == "bind") {
  356. // this.$message.info("绑定账号");
  357. let data = await this.$ajax.post(API_CONFIG.baseUrl2 + "checkOpenId", [
  358. { email: email },
  359. ]);
  360. if (!data.data[0].length) {
  361. this.$message.error("未查找到对应账号请重新输入");
  362. return;
  363. }
  364. if (data.data[0][0].thirdpartyid) {
  365. this.$message.error("该账号已绑定微信登录请重新输入");
  366. return;
  367. }
  368. let params = {
  369. geetest_challenge: "",
  370. geetest_validate: "",
  371. geetest_seccode: "",
  372. loginUsername: email.trim(),
  373. loginPassword: window.btoa(this.password.trim()),
  374. };
  375. this.loading = true;
  376. axios.defaults.withCredentials = true;
  377. console.log("👇");
  378. axios
  379. .post("https://beta.api.cocorobo.cn/api/user", qs.stringify(params))
  380. .then(async (res) => {
  381. console.log("res", res);
  382. let _data = res.data[0][0];
  383. let userjson = await getUser({ userid: _data.userid });
  384. console.log("userjson", userjson);
  385. if (_data.active === 1) {
  386. await this.$ajax.post(API_CONFIG.baseUrl2 + "UpdateOpenId", [
  387. { userid: _data.userid, openid: this.openid },
  388. ]);
  389. window.localStorage["identity"] = JSON.stringify(_data.identity);
  390. this.$message.success("绑定成功");
  391. await this.login();
  392. if (
  393. userjson.data[0][0].type == 1 &&
  394. userjson.data[0][0].role == 1 &&
  395. userjson.data[0][0].rrole == 1
  396. ) {
  397. this.$router.push({ path: "/kanban" });
  398. } else {
  399. this.$router.push({ path: this.redirect || "/" });
  400. }
  401. } else {
  402. this.$message.error("绑定失败");
  403. }
  404. this.loading = false;
  405. })
  406. .catch((e) => {
  407. if (e.response && e.response.data == "Wrong email or password") {
  408. this.$message.error("账号或密码错误");
  409. } else {
  410. this.$message.error("绑定失败");
  411. }
  412. this.loading = false;
  413. });
  414. }
  415. },
  416. async getLoading() {
  417. // 检查用户是否已登录
  418. const hasToken = this.$store.getters.token;
  419. if (hasToken) {
  420. // 如果已登录,直接重定向
  421. this.$router.push({ path: this.redirect || "/" });
  422. return;
  423. }
  424. const userid = await this.login();
  425. if (userid) {
  426. this.$router.push({ path: this.redirect || "/" });
  427. }
  428. },
  429. // 输入账号获取组织
  430. getOrgData() {
  431. return new Promise((resolve) => {
  432. let params = [
  433. {
  434. functionName: API_CONFIG.ajax_liYuanOrg.functionName,
  435. uname: this.account,
  436. },
  437. ];
  438. this.$ajax
  439. .post(API_CONFIG.baseUrl, params)
  440. .then((res) => {
  441. console.log("res", res);
  442. this.org = "";
  443. this.OrgOptions = [];
  444. let getList = res.data[0];
  445. // if (this.allowOrgList.findIndex((i) => i.area) != -1) {
  446. // let _index = this.allowOrgList.findIndex((i) => i.area);
  447. // let _list = this.allowOrgList[_index].list;
  448. // getList = getList.filter((i) => _list.includes(i.id));
  449. // } else {
  450. // let mergedList = this.allowOrgList.reduce((acc, curr) => {
  451. // return [...acc, ...curr.list];
  452. // }, []);
  453. // getList = getList.filter((i) => !mergedList.includes(i.id));
  454. // }
  455. this.OrgOptions = getList;
  456. if (this.OrgOptions.length == 1) {
  457. this.org = this.OrgOptions[0].Uorg;
  458. } else if (this.OrgOptions.length > 0) {
  459. // liyuan走这里
  460. if(this.allowOrgList.findIndex((i) => i.area) != -1){
  461. console.log('1111');
  462. try {
  463. let _index = this.allowOrgList.findIndex((i) => i.area);
  464. let _list = this.allowOrgList[_index].list;
  465. this.org = this.OrgOptions.filter(i=>_list.includes(i.id))[0].Uorg;
  466. } catch (error) {
  467. console.log(error);
  468. return this.$message.error("账号不可登录,请使用您的专属网址");
  469. }
  470. }else{
  471. // // admin走这里
  472. console.log('2222');
  473. if (this.allowOrgList.findIndex((i) => i.area) != -1) {
  474. this.$message.error("请输入账号后缀");
  475. }else{
  476. this.$message.error("该账号须使用“组织号登陆”");
  477. this.loginType = 'orgL'
  478. }
  479. // let mergedList = this.allowOrgList.reduce((acc, curr) => {
  480. // return [...acc, ...curr.list];
  481. // }, []);
  482. // if(this.OrgOptions.filter(i=>!mergedList.includes(i.id)).length==1){
  483. // this.org = this.OrgOptions.filter(i=>!mergedList.includes(i.id))[0].Uorg;
  484. // }
  485. // }
  486. // if (this.OrgOptions.map((i) => i.Uorg).includes("@cocorobo.cc")) {
  487. // this.org = "@cocorobo.cc";
  488. // } else {
  489. // this.org = this.OrgOptions[0].Uorg;
  490. }
  491. }
  492. resolve();
  493. })
  494. .catch((err) => {
  495. console.log(err);
  496. });
  497. });
  498. },
  499. //获取组织或学校的数据
  500. getOrdOidData() {
  501. let params = [
  502. {
  503. functionName: API_CONFIG.ajax_schoolPermission.functionName, // 调用存储过程的名称
  504. org: this.org2, //组织id
  505. oid: this.oid, //学校id
  506. },
  507. ];
  508. // 发起请求
  509. this.$ajax
  510. .post(API_CONFIG.baseUrl, params)
  511. .then((res) => {
  512. let data = res.data[0];
  513. console.log("data", data);
  514. this.form = JSON.parse(data[0].json);
  515. this.showName = this.form.basics.title || data[0].name;
  516. })
  517. .catch((err) => {
  518. console.error("请求失败,错误信息:", err);
  519. });
  520. },
  521. wechatLogin() {
  522. this.loginType = "weChat";
  523. setTimeout(() => {
  524. const randomState = Math.random().toString(36).substring(2); // 生成随机状态
  525. // eslint-disable-next-line no-undef
  526. new WxLogin({
  527. self_redirect: true,
  528. id: "QRcode",
  529. appid: "wxe9d7fff3c659445f",
  530. scope: "snsapi_login",
  531. redirect_uri: encodeURIComponent("https://cocorobo.cn/weixin.html"), //https://liyuan.cocorobo.cn/#/wxTest
  532. state: randomState,
  533. style: "black",
  534. href: "data:text/css;base64,LmltcG93ZXJCb3gge2Rpc3BsYXk6IGZsZXg7fQouaW1wb3dlckJveCAucXJjb2RlIHt3aWR0aDogMjMycHg7IGhlaWdodDogMjMycHh9Ci5pbXBvd2VyQm94IC50aXRsZSB7ZGlzcGxheTogbm9uZTt9Ci5pbXBvd2VyQm94IC5pbmZvIHtkaXNwbGF5OiBub25lO30KLmxvZ2luUGFuZWx7d2lkdGg6MTAwJTtoZWlnaHQ6MTAwJTtkaXNwbGF5OmZsZXg7ZmxleC1kaXJlY3Rpb246Y29sdW1uO2FsaWduLWl0ZW1zOmNlbnRlcjtqdXN0aWZ5LWNvbnRlbnQ6Y2VudGVyO30KLnN0YXR1c19pY29uIHtkaXNwbGF5OiBub25lfQoud2ViX3FyY29kZV9wYW5lbF9hcmVhe2hlaWdodDoxMDAlO3dpZHRoOjEwMCU7ZGlzcGxheTpmbGV4O2FsaWduLWl0ZW1zOmNlbnRlcjtqdXN0aWZ5LWNvbnRlbnQ6Y2VudGVyO30K",
  535. onReady: function (isReady) {
  536. console.log(isReady);
  537. },
  538. });
  539. setTimeout(() => {
  540. let iframe = this.$refs.QRcode.querySelector("iframe");
  541. iframe.style.width = "100%";
  542. iframe.style.height = "100%";
  543. }, 0);
  544. }, 0);
  545. },
  546. async getOpenId(openid) {
  547. // oiztX1dwR-W2mBJ5HcvaSEB8yKGY
  548. axios.defaults.withCredentials = false;
  549. let params = {
  550. openid: openid,
  551. };
  552. this.openid = openid;
  553. axios.defaults.withCredentials = true;
  554. axios
  555. .post(`https://beta.api.cocorobo.cn/api/user`, qs.stringify(params))
  556. .then(async (res) => {
  557. console.log("res", res);
  558. let _data = res.data[0][0];
  559. // let userData = await this.ajax.get("https://pbl.cocorobo.cn/api/pbl/selectUser/selectUser", { userid: _data.userid });
  560. // let _uorg = userData.data[0][0].org;
  561. this.account = _data.username;
  562. await this.getOrgData();
  563. // if (
  564. // (this.allowOrgList.find((i) => i.id == this.org2) &&
  565. // parent.location.href.includes("lyxx")) ||
  566. // parent.location.href.includes("liyuan")
  567. // ) {
  568. // let _list = this.allowOrgList.find((i) => i.id == this.org2).list;
  569. // let _nowOrgId = this.OrgOptions.find((i) => i.Uorg == this.org).id;
  570. // if (!_list.includes(_nowOrgId)) {
  571. // this.wechatLogin();
  572. // await loginOut();
  573. // await this.logout();
  574. // return this.$message.error("该组织/学校不允许登录");
  575. // }
  576. // window.sessionStorage.setItem("org2", this.org2);
  577. // }
  578. if (this.allowOrgList.findIndex((i) => i.area) != -1) {
  579. let _index = this.allowOrgList.findIndex((i) => i.area);
  580. let _list = this.allowOrgList[_index].list;
  581. if (this.OrgOptions.find((i) => i.Uorg == this.org) &&
  582. !_list.includes(
  583. this.OrgOptions.find((i) => i.Uorg == this.org).id
  584. )
  585. ) {
  586. this.wechatLogin();
  587. await loginOut();
  588. await this.logout();
  589. return this.$message.error("账号不可登陆,请联系管理员。");
  590. }
  591. } else {
  592. let mergedList = this.allowOrgList.reduce((acc, curr) => {
  593. return [...acc, ...curr.list];
  594. }, []);
  595. if (
  596. mergedList.includes(
  597. this.OrgOptions.find((i) => i.Uorg == this.org).id
  598. )
  599. ) {
  600. this.wechatLogin();
  601. await loginOut();
  602. await this.logout();
  603. return this.$message.error("账号不可登陆,请联系管理员。");
  604. }
  605. }
  606. let userjson = await getUser({ userid: _data.userid });
  607. console.log("userjson", userjson);
  608. if (_data.active === 1) {
  609. window.localStorage["identity"] = JSON.stringify(_data.identity);
  610. this.$message.success("登录成功");
  611. window.topU.U.UF.Cookie.set("cocoroboLoginType=2");
  612. window.topU ? window.topU.US.userInfo = _data : window.top.US.userInfo = _data
  613. await this.login();
  614. this.addOp3('1', "", { type:this.prefixL + "login" }, "success",_data.userid)
  615. if (
  616. userjson.data[0][0].type == 1 &&
  617. userjson.data[0][0].role == 1 &&
  618. userjson.data[0][0].rrole == 1
  619. ) {
  620. this.$router.push({ path: "/kanban" });
  621. } else {
  622. this.$router.push({ path: this.redirect || "/" });
  623. }
  624. } else {
  625. this.$message.error("登录失败");
  626. }
  627. this.loading = false;
  628. })
  629. .catch((err) => {
  630. console.log(err.response);
  631. if (err && err.response && err.response.status === 401) {
  632. this.loginType = "bind";
  633. }
  634. });
  635. //
  636. },
  637. },
  638. mounted() {
  639. let _this = this;
  640. window.addEventListener("message", function (e) {
  641. // 监听 message 事件
  642. console.log(e);
  643. if (e.data && e.data.method == "getOpenId") {
  644. console.log(e);
  645. console.log(e.data.code);
  646. console.log(_this.loginType);
  647. if (e.data.code == 200) {
  648. _this.getOpenId(e.data.data.openid);
  649. } else {
  650. _this.$message.error("扫码登录失败请重新扫码");
  651. _this.wechatLogin();
  652. }
  653. }
  654. });
  655. this.getLoading();
  656. this.getOrdOidData();
  657. },
  658. };
  659. </script>
  660. <style scoped>
  661. .loginPage {
  662. width: 100vw;
  663. height: 100vh;
  664. background-color: white;
  665. display: flex;
  666. align-items: center;
  667. justify-content: center;
  668. }
  669. .lp_left {
  670. max-width: 50%;
  671. width: 50%;
  672. max-height: 100%;
  673. height: 100%;
  674. overflow: hidden;
  675. box-sizing: border-box;
  676. }
  677. .lp_left > img {
  678. width: 100%;
  679. height: 100%;
  680. object-fit: contain;
  681. border-radius: 0 150px 0 0;
  682. }
  683. .lp_right {
  684. width: 50%;
  685. min-width: 520px;
  686. height: 100%;
  687. display: flex;
  688. justify-content: center;
  689. align-items: center;
  690. }
  691. .lp_r_box {
  692. width: 500px;
  693. height: auto;
  694. box-sizing: border-box;
  695. padding: 20px;
  696. }
  697. .lp_r_b_logo {
  698. display: flex;
  699. align-items: center;
  700. }
  701. .lp_r_b_logo > span {
  702. margin-left: 15px;
  703. font-weight: bold;
  704. font-size: 18px;
  705. }
  706. .lp_r_box > span {
  707. font-size: 46px;
  708. font-weight: bold;
  709. margin: 40px 0;
  710. display: block;
  711. }
  712. .lp_r_b_formArea {
  713. width: 100%;
  714. height: 250px;
  715. margin-bottom: 40px;
  716. }
  717. .fa_input {
  718. width: 100%;
  719. height: 100%;
  720. display: flex;
  721. flex-direction: column;
  722. /* align-items: center; */
  723. justify-content: center;
  724. }
  725. .fa_i_item {
  726. width: 100%;
  727. height: 70px;
  728. margin-bottom: 30px;
  729. }
  730. .fa_i_item > span {
  731. font-size: 16px;
  732. color: rgba(0, 0, 0, 0.9);
  733. font-weight: 600;
  734. }
  735. .fa_i_item > div {
  736. width: 100%;
  737. height: 40px;
  738. border: solid 1px rgba(213, 213, 213, 1);
  739. margin-top: 5px;
  740. border-radius: 8px;
  741. transition: 0.5s;
  742. }
  743. .fa_i_item > div > input {
  744. width: 100%;
  745. height: 100%;
  746. border: none;
  747. outline: none;
  748. text-indent: 1em;
  749. color: #000;
  750. font-size: 14px;
  751. background: none;
  752. }
  753. .fa_i_item > div >>> .el-select {
  754. width: 100%;
  755. height: 100%;
  756. }
  757. .fa_i_item > div >>> .el-select input {
  758. border: none;
  759. outline: none;
  760. background: none;
  761. text-indent: 1em;
  762. font-size: 14px;
  763. height: 40px;
  764. padding-left: 0;
  765. color: #000;
  766. }
  767. /* .fa_i_item > input {
  768. width: 100%;
  769. height: 45px;
  770. border: solid 1px rgba(213, 213, 213, 1);
  771. outline: none;
  772. border-radius: 8px;
  773. margin-top: 15px;
  774. text-indent: 1em;
  775. transition: 0.5s;
  776. color: #000;
  777. font-size: 16px;
  778. } */
  779. .fa_i_item > div >>> input::placeholder {
  780. color: rgba(142, 142, 147, 1);
  781. }
  782. .fa_i_item > div:focus-within {
  783. border-color: #006afe;
  784. }
  785. .fa_weChat {
  786. width: 300px;
  787. height: 300px;
  788. margin: 0 auto;
  789. display: flex;
  790. align-items: center;
  791. justify-content: center;
  792. }
  793. .fa_weChat > .QRcode {
  794. width: 100%;
  795. height: 100%;
  796. display: flex;
  797. align-items: center;
  798. justify-content: center;
  799. /* background-color: black; */
  800. }
  801. .lp_r_b_btn {
  802. width: 100%;
  803. height: 45px;
  804. background-color: rgba(0, 106, 254, 1);
  805. border-radius: 10px;
  806. display: flex;
  807. justify-content: center;
  808. align-items: center;
  809. color: #fff;
  810. cursor: pointer;
  811. transition: 0.3s;
  812. }
  813. .lp_r_b_btn:hover {
  814. background-color: rgb(3, 87, 206);
  815. }
  816. .backBtn {
  817. background-color: #d9d9d9;
  818. color: #000;
  819. }
  820. .backBtn:hover {
  821. background-color: #adadad;
  822. }
  823. .lp_r_b_line {
  824. width: 100%;
  825. height: 20px;
  826. margin: 40px 0;
  827. display: flex;
  828. justify-content: center;
  829. align-items: center;
  830. }
  831. .lp_r_b_line > div {
  832. width: calc(100% / 2 - 70px);
  833. height: 1px;
  834. background-color: #e7e7e7;
  835. }
  836. .lp_r_b_line > span {
  837. display: flex;
  838. margin: 0 20px;
  839. }
  840. .lp_r_b_iconBtn {
  841. width: 100%;
  842. height: 40px;
  843. display: flex;
  844. justify-content: center;
  845. }
  846. .lp_r_b_iconBtn > div {
  847. width: 32px;
  848. height: 32px;
  849. cursor: pointer;
  850. margin: 0 20px;
  851. }
  852. .lp_r_b_iconBtn > div > img {
  853. width: 100%;
  854. height: 100%;
  855. }
  856. .btn_box {
  857. display: flex;
  858. gap: 10px;
  859. }
  860. .backWin{
  861. /* box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); */
  862. }
  863. </style>