Login.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. <template>
  2. <div>
  3. <div class="login" v-if="!bindingqywx">
  4. <div class="login-par">
  5. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-position="left" label-width="0px" class="demo-ruleForm login-container">
  6. <div class="login-logo">
  7. <img src="../assets/image/login_logo.png" style="width:80px;height:80px;"/>
  8. </div>
  9. <h3 class="title">{{ $t('workingHoursHousekeeper') }}</h3>
  10. <el-form-item class="login-input" prop="username">
  11. <el-input type="text" v-model="ruleForm.username" autocomplete="off" :placeholder="$t('zhang-hao-shou-ji-hao')" clearable prefix-icon="el-icon-user-solid"></el-input>
  12. </el-form-item>
  13. <el-form-item class="login-input" prop="password">
  14. <el-input type="password" v-model="ruleForm.password" @keyup.enter.native="handleSubmit" autocomplete="off" :placeholder="$t('mi-ma')" show-password prefix-icon="el-icon-lock"></el-input>
  15. </el-form-item>
  16. <el-form-item class="login-button" style="width:100%;">
  17. <el-button type="primary" style="width:100%;" @click.native.prevent="handleSubmit" :loading="logining">{{ $t('login') }}</el-button>
  18. </el-form-item>
  19. <div class="additional" v-if="wxHrefFlg">
  20. <el-divider content-position="center">或</el-divider>
  21. </div>
  22. <div class="externalLanding" v-if="wxHrefFlg">
  23. <div class="externalLanding_img" @click="wxworkCli()">
  24. <img src="../assets/image/qiyeweix.png" alt="">
  25. </div>
  26. </div>
  27. <div class="toRegister">
  28. <el-link type="primary" class="btn" style="float:left;" :underline="false">{{ $t('lian-xi-ke-fu') }}
  29. <div class="service">
  30. <p style="color: #333">{{ $t('sao-ma-jia-ke-fu-wei-xin') }}</p>
  31. <img src="../assets/image/code.jpg">
  32. <p><span style="color: #333">QQ:</span><span id="QQ">3052894409</span></p>
  33. </div>
  34. </el-link>
  35. <el-link type="primary" style="margin-right:5px;" @click="dialogVisible=true" :underline="false">
  36. {{ $t('shi-yong-shuo-ming') }} </el-link>
  37. <el-link type="primary" v-if="!isCorpWX" @click="jumpTo" :underline="false">{{ $t('qi-ye-zhu-ce') }}</el-link>
  38. </div>
  39. </el-form>
  40. </div>
  41. <el-dialog :title="$t('shi-yong-shuo-ming')" :visible.sync="dialogVisible" width="500px">
  42. <p><a style="color:#409EFF;text-decoration:none" href="upload/工时管家使用说明_基础版.docx" download="工时管家使用说明_基础版.docx"
  43. target="_blank">工时管家使用说明_基础版.docx</a></p>
  44. <p><a style="color:#409EFF;text-decoration:none" href="upload/工时管家使用说明_项目管理专业版.docx" download="工时管家使用说明_项目管理专业版.docx"
  45. target="_blank">工时管家使用说明_项目管理专业版.docx</a></p>
  46. <p><a style="color:#409EFF;text-decoration:none" href="upload/工时管家使用说明_建筑工程专业版.docx" download="工时管家使用说明_建筑工程专业版.docx"
  47. target="_blank">工时管家使用说明_建筑工程专业版.docx</a></p>
  48. <!-- <p><a style="color:#409EFF;text-decoration:none" href="upload/工时管家使用说明_项目经理.docx" download="工时管家使用说明_项目经理.docx"
  49. target="_blank">工时管家使用说明_项目经理.docx</a></p>
  50. <p><a style="color:#409EFF;text-decoration:none" href="upload/工时管家使用说明_普通员工.docx" download="工时管家使用说明_普通员工.docx"
  51. target="_blank">工时管家使用说明_普通员工.docx</a></p> -->
  52. </el-dialog>
  53. <el-dialog title="企业微信扫码登陆" :visible.sync="wxworkFlg" width="500px">
  54. <div>
  55. <div id="wxcode"></div>
  56. </div>
  57. </el-dialog>
  58. </div>
  59. <!-- 绑定企业微信的话显示这个 -->
  60. <div class="qiweix" v-if="bindingqywx">
  61. 正在进入系统...
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. import * as dd from 'dingtalk-jsapi';
  67. import "../permissions.js"
  68. import WxLogin from "../assets/js/wwLogin.js"
  69. export default {
  70. inject:['reloads'],
  71. data() {
  72. return {
  73. isCorpWX: false,
  74. dialogVisible: false,
  75. logining: false,
  76. // 登录信息
  77. ruleForm: {
  78. username: '',
  79. password: ''
  80. },
  81. rules: {
  82. username: [{ required: true, message: this.$t('peaseenterthe'), trigger: 'blur' },],
  83. password: [{ required: true, message: this.$t('peaseenterthe'), trigger: 'blur' },]
  84. },
  85. wxworkFlg: false,
  86. bindingqywx: false,
  87. wxHrefFlg: false
  88. };
  89. },
  90. watch: {
  91. $route(to) {
  92. if (to.query.code) {
  93. this.getStaffInfo(to.query.code)
  94. }
  95. }
  96. },
  97. created() {
  98. // this.langChange()
  99. if (localStorage.userInfo != null) {
  100. var user = JSON.parse(localStorage.userInfo);
  101. if(user.moduleList.length > 0) {
  102. this.$router.push({ path: user.moduleList[0].path })
  103. }
  104. }
  105. let windowHerf = window.location.href
  106. if(windowHerf.indexOf('?jobNumber') != '-1') {
  107. let jobNumber = windowHerf.split('jobNumber=')[1].split('&token=')[0]
  108. let token = windowHerf.split('&token=')[1]
  109. this.automaticLogin(jobNumber, token)
  110. }
  111. // 用户绑定了企业微信 和 飞书
  112. if(windowHerf.indexOf('userId') != '-1' || windowHerf.indexOf('appId') != '-1') {
  113. this.bindingqywx = true
  114. }
  115. },
  116. mounted() {
  117. // this.wxworkCli()
  118. var ua = navigator.userAgent.toLowerCase();
  119. console.log(ua, '打印出来')
  120. if (ua.indexOf("wxwork") > 0) {
  121. this.isCorpWX = true;
  122. }
  123. let href = window.location.href;
  124. this.wxHrefFlg = href.indexOf('//worktime.ttkuaiban.com') != '-1'
  125. if (this.isCorpWX) {
  126. //企业微信环境下,尝试自动登录
  127. //判断企业微信,是否存在授权
  128. //尝试自动登录
  129. if (href.indexOf('hasTriedAutoLogin') == -1) {
  130. this.tryAutoLogin();
  131. } else if (href.indexOf("userId") > 0) {
  132. //后台经过验证后,重定向过来带上了userId
  133. var loginUserId = href.substring(href.indexOf("userId=")+"userId=".length);
  134. if (loginUserId.includes('#/')) {
  135. loginUserId = loginUserId.substring(0, loginUserId.indexOf('#/'));
  136. }
  137. if (loginUserId.includes('&')) {
  138. loginUserId = loginUserId.substring(0, loginUserId.indexOf('&'));
  139. }
  140. var path = null;
  141. if (href.indexOf('path') > 0) {
  142. path = href.split('path=')[1].split('&')[0];
  143. }
  144. this.loginByUserId(loginUserId, path);
  145. } else {
  146. if (localStorage.userInfo != null) {
  147. var user = JSON.parse(localStorage.userInfo);
  148. if (user.company.packageSimple == 1) {
  149. //简易模式,直接进入工时统计表
  150. this.$router.push({ path: '/simple' });
  151. } else {
  152. if(user.moduleList.length > 0) {
  153. this.$router.push({ path: user.moduleList[0].path })
  154. } else {
  155. //没有授权任何模块,需要提示用户
  156. alert('无权访问,请联系管理员为您分配权限');
  157. }
  158. }
  159. } else if (href.indexOf('errorMsg=') > 0) {
  160. var errorMsg = href.split('errorMsg=')[1].split('#')[0];
  161. errorMsg = decodeURI(errorMsg);
  162. this.$message({
  163. message: errorMsg,
  164. type: 'error'
  165. });
  166. }
  167. }
  168. } else {
  169. //浏览器上使用扫码登录
  170. if (href.indexOf("userId") > 0) {
  171. //后台经过验证后,重定向过来带上了userId
  172. var loginUserId = href.substring(href.indexOf("userId=")+"userId=".length);
  173. if (loginUserId.includes('#/')) {
  174. loginUserId = loginUserId.substring(0, loginUserId.indexOf('#/'));
  175. }
  176. if (loginUserId.includes('&')) {
  177. loginUserId = loginUserId.substring(0, loginUserId.indexOf('&'));
  178. }
  179. var path = null;
  180. if (href.indexOf('path') > 0) {
  181. path = href.split('path=')[1].split('&')[0];
  182. }
  183. this.loginByUserId(loginUserId, path);
  184. } else if (localStorage.userInfo != null) {
  185. var user = JSON.parse(localStorage.userInfo);
  186. if (user.company.packageSimple == 1) {
  187. //简易模式,直接进入工时统计表
  188. this.$router.push({ path: '/simple' });
  189. } else {
  190. if(user.moduleList.length > 0) {
  191. this.$router.push({ path: user.moduleList[0].path })
  192. } else {
  193. //没有授权任何模块,需要提示用户
  194. alert('无权访问,请联系管理员为您分配权限');
  195. }
  196. }
  197. } else {
  198. if(href.indexOf("corpid") > 0) {
  199. if(!(window.location.href.indexOf("ddLoginUnique") > 0)) {
  200. this.tryDingDingUrlRedirect()
  201. return
  202. }
  203. // 钉钉登陆
  204. //检查环境,如果是钉钉有$CORPID$
  205. var key = '?corpid=';
  206. var jumpkey = '&jumpto=';
  207. var url = location.href;
  208. console.log('jumpto',location);
  209. // var url = "https://worktime.ttkuaiban.com/?corpid=$CORPID$&jumpto=/info/21#/index"
  210. var that = this;
  211. if (url.indexOf(key) > 0) {
  212. var corpId = ''
  213. var jumpurl = ''
  214. if(url.indexOf(jumpkey) > 0){
  215. corpId = url.substring(url.indexOf(key)+key.length,url.indexOf(jumpkey));
  216. jumpurl = url.substring(url.indexOf(jumpkey)+jumpkey.length,url.indexOf('#'));
  217. }else{
  218. corpId = url.substring(url.indexOf(key)+key.length,url.indexOf('#'));
  219. }
  220. dd.ready(function() {
  221. that.isDingchg()
  222. dd.runtime.permission.requestAuthCode({
  223. corpId: corpId, // 企业id
  224. onSuccess: function (info) {
  225. var code = info.code // 通过该免登授权码可以获取用户身份
  226. that.loginByCode(code, corpId, jumpurl);
  227. }});
  228. });
  229. }
  230. } else {
  231. // 飞书登陆
  232. if(href.indexOf("appId") > 0) {
  233. console.log('执行到这里---飞书')
  234. let arr = href.split('appId=')[1]
  235. let str = arr.split('#')[0]
  236. console.log(str, window)
  237. window.h5sdk.ready(() => { // ready方法不需要每次都调用
  238. tt.requestAuthCode({
  239. appId: str,
  240. success: (info) => {
  241. console.info(info.code, '飞书 code')
  242. this.flyingBook(str, info.code)
  243. },
  244. fail: (error) => {
  245. console.error(error)
  246. }
  247. });
  248. });
  249. }
  250. }
  251. }
  252. }
  253. let urls = window.location.href
  254. console.log(urls, '连接')
  255. if(urls.indexOf('english=1') != '-1' && localStorage.getItem('lang') != 'en') {
  256. this.setlangChange()
  257. location.reload()
  258. }
  259. if(urls.indexOf('english=1') == '-1' && localStorage.getItem('lang') != 'zh') {
  260. localStorage.setItem("lang", 'zh')
  261. location.reload()
  262. }
  263. },
  264. methods: {
  265. wxworkCli() {
  266. // this.wxworkFlg = true
  267. // this.$nextTick(()=>{
  268. // var obj = new WxLogin({
  269. // id: 'wxcode', // 登录页面显示二维码的容器id
  270. // appid: 'wwf11426cf618e1703', // 企业微信的CorpID,在企业微信管理端查看
  271. // redirect_uri: encodeURIComponent('http://localhost:10086/#/login'), // 重定向的地址,需要进行encode
  272. // usertype: 'member'
  273. // })
  274. // })
  275. var appId = "wwf11426cf618e1703";//企业微信第三方的SUIT ID
  276. var url = "https://worktime.ttkuaiban.com/api/corpWXScanningAuth";//授权回调页面
  277. var weixinUrl=`https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect?appid=${appId}&redirect_uri=${url}&state=0&usertype=member`;
  278. window.location.href = weixinUrl;
  279. },
  280. getStaffInfo() {
  281. console.log('执行了没')
  282. },
  283. setlangChange() {
  284. localStorage.setItem("lang", 'en')
  285. },
  286. langChange() {
  287. let jsSrc =(navigator.language || navigator.browserLanguage).toLowerCase();
  288. let str = localStorage.getItem("lang")
  289. if(jsSrc.indexOf('zh')!=-1){
  290. // 浏览器语言是中文
  291. localStorage.setItem("lang", 'zh')
  292. // localStorage.setItem("lang", 'en')
  293. } else {
  294. // 浏览器语言是英文
  295. localStorage.setItem("lang", 'en')
  296. // localStorage.setItem("lang", 'zh')
  297. }
  298. if(str != localStorage.getItem("lang")) {
  299. // this.reloads()
  300. location.reload()
  301. }
  302. console.log(str, localStorage.getItem("lang"))
  303. },
  304. isDingchg() {
  305. this.$store.commit('isDingFun')
  306. },
  307. bindIfNessary() {
  308. let href = window.location.href;
  309. if (this.isCorpWX) {
  310. // localStorage.openId = 'o1L3L5lOrOl3_UEJjONaoT2Rne1I';
  311. //会自动跳转到首页
  312. // let href = 'http://hq.tangusoft.com/?code=011Ptjgc2rx1eI09Irgc2Rvsgc2PtjgF&state=1#/index';
  313. if (href.includes("com/?code")) { //url包括 com/?code 证明为从微信跳转回来的
  314. var url = href; //vue自动在末尾加了 #/ 符号,截取去掉
  315. var jingPosit = url.indexOf("com/") + 4; //获取域名结束的位置
  316. // var urlLeft = url.substring(0, jingPosit);//url左侧部分
  317. var urlRight = url.substring(jingPosit, url.length); //url右侧部分
  318. console.log('urlRight=' + urlRight);
  319. urlRight = urlRight.substring(0, urlRight.indexOf('#/'));
  320. // window.location = urlLeft + "#/home" + urlRight;//拼接跳转
  321. //获取code
  322. var code = urlRight.substring('?code='.length,urlRight.indexOf('&state='));
  323. var passUserId = urlRight.substring(urlRight.indexOf('&state=')+'&state='.length);
  324. if (passUserId == '1') {
  325. //自动登录的回调
  326. this.$axios.get('/wxcorp/corpWeiXinLogin', {params:{code:code}})
  327. .then(res => {
  328. if (res == null) {
  329. } else if(res.errcode != null) {
  330. //报错了
  331. console.log(res.errmsg);
  332. } else {
  333. //获取openId
  334. if (res.data != null && ((this.isWX && res.data.wxOpenid != undefined)
  335. || (this.isCorpWX && res.data.corpwxUserid != undefined))) {
  336. localStorage.userInfo = JSON.stringify(res.data);
  337. console.log('登录成功');
  338. this.user = res.data;
  339. this.permissionsList(res.data)
  340. window.location.href = '/#/index';
  341. }
  342. }
  343. }).catch(err=> {
  344. alert('err=' + err);
  345. });
  346. } else {
  347. }
  348. }
  349. }
  350. },
  351. tryAutoLogin() {
  352. var appId = "ww4e237fd6abb635af";//企业微信第三方的SUIT ID
  353. var url = "https://worktime.ttkuaiban.com/api/corpWXAuth";//授权回调页面
  354. var weixinUrl="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+encodeURI(url)+"&response_type=code&scope=snsapi_base&state=1#wechat_redirect";
  355. window.location.href = weixinUrl;
  356. },
  357. tryDingDingUrlRedirect() {
  358. let currentAddress = window.location.href+'?ddLoginUnique=true';
  359. let ddFixedPrefix = 'http://auth.dingtalk.com/login?redirectUri='
  360. let ddFixedUrl = 'https://login.dingtalk.com/oauth2/auth?response_type=code&client_id=dingwa4tibze6jwz7mgv&scope=openid&state=dddd&redirect_uri=' + encodeURIComponent(`${ddFixedPrefix}${currentAddress}`)
  361. window.location.href = ddFixedUrl;
  362. // window.location.href = window.location.href+'?ddLoginUnique=true';
  363. },
  364. loginByUserId(userId, path) {
  365. this.http.post("/user/loginByUserId", {userId:userId} , res => {
  366. if (res.code == "ok") {
  367. var user = res.data;
  368. localStorage.user = JSON.stringify(res.data);
  369. sessionStorage.setItem('user', JSON.stringify(res.data));
  370. this.permissionsList(res.data)
  371. if(user.moduleList.length > 0) {
  372. if (path) {
  373. var action = '';
  374. //url上传来的格式
  375. if (path.includes('projectInside')) {
  376. //跳转进入项目的任务看板
  377. path = decodeURIComponent(path);
  378. console.log('pppp='+path);
  379. if (path.includes('@adjustBudget-')) {
  380. //需要打开分组预估工时设置
  381. action = path.split('@')[1];
  382. path = path.split('@')[0];
  383. }
  384. }
  385. console.log('action==='+action);
  386. sessionStorage.action = action
  387. this.$router.push({ path: path})
  388. } else {
  389. this.$router.push({ path: user.moduleList[0].path })
  390. }
  391. if (!path) {
  392. path = user.moduleList[0].path;
  393. }
  394. //去掉链接上存在的参数
  395. if (location.href.indexOf("?")>0) {
  396. var newHref = location.href.split("?")[0] + '#' + (path.indexOf('/')>-1?path:('/'+path));
  397. location.href = newHref;
  398. }
  399. } else {
  400. //没有授权任何模块,需要提示用户
  401. alert('无权访问,请联系管理员为您分配权限');
  402. }
  403. } else {
  404. this.$message({
  405. message: res.msg,
  406. type: 'error'
  407. });
  408. }
  409. }, error => {
  410. this.$message({
  411. message: error,
  412. type: 'error'
  413. });
  414. })
  415. },
  416. loginByCode(code, corpId, jumpurl) {
  417. this.http.post("/dingding/getUserByCode", {code:code, corpid:corpId} , res => {
  418. if (res.code == "ok") {
  419. var user = res.data;
  420. localStorage.user = JSON.stringify(res.data);
  421. sessionStorage.setItem('user', JSON.stringify(res.data));
  422. this.permissionsList(res.data)
  423. if(jumpurl){
  424. this.$router.push({ path: jumpurl })
  425. }else if(user.moduleList.length > 0) {
  426. this.$router.push({ path: user.moduleList[0].path })
  427. }else {
  428. //没有授权任何模块,需要提示用户
  429. alert('无权访问,请联系管理员为您分配权限');
  430. }
  431. } else {
  432. this.$message({
  433. message: res.msg,
  434. type: 'error'
  435. });
  436. }
  437. }, error => {
  438. this.$message({
  439. message: error,
  440. type: 'error'
  441. });
  442. })
  443. },
  444. handleReset2() {
  445. this.$refs.ruleForm.resetFields();
  446. },
  447. jumpTo() {
  448. this.$router.push({ path: '/register' });
  449. },
  450. handleSubmit(ev) {
  451. this.$refs.ruleForm.validate((valid) => {
  452. if (valid) {
  453. var _this = this;
  454. this.logining = true;
  455. setTimeout(function () {
  456. _this.logining = false;
  457. // console.log('执行')
  458. }, 15000);
  459. this.http.post(this.port.manage.login, this.ruleForm , res => {
  460. this.logining = false;
  461. if (res.code == "ok") {
  462. if(res.data.moduleList.length == 0){
  463. this.$message({
  464. message: this.$t('qing-lian-xi-guan-li-yuan-wei')+'\u3000' + res.data.roleName + '\u3000'+this.$t('assignpermissions'),
  465. type: 'error'
  466. })
  467. return
  468. }
  469. var user = res.data;
  470. sessionStorage.setItem('user', JSON.stringify(res.data));
  471. this.permissionsList(res.data)
  472. if (user.company.packageSimple == 1) {
  473. //简易模式,直接进入工时统计表
  474. this.$router.push({ path: '/simple' });
  475. sessionStorage.setItem('autoRoute','/simple')
  476. } else {
  477. if(user.moduleList.length > 0) {
  478. this.$router.push({ path: user.moduleList[0].path })
  479. sessionStorage.setItem('autoRoute',user.moduleList[0].path)
  480. }
  481. }
  482. } else {
  483. this.logining = false;
  484. // if(res.msg.indexOf('到期') != -1){
  485. // this.$router.push({ path: '/expire', query:{datetext:'2022.11.24',ddd: '111'}})
  486. // console.log('到期skip');
  487. // return
  488. // }
  489. this.$message({
  490. message: res.msg,
  491. type: 'error'
  492. });
  493. }
  494. }, error => {
  495. console.log('执行1')
  496. this.logining = false;
  497. this.$message({
  498. message: error,
  499. type: 'error'
  500. });
  501. })
  502. }
  503. });
  504. },
  505. // 米莱得用工号登录
  506. automaticLogin(jobNumber, token) {
  507. this.http.post('/user/loginAdminByThirdParty', {
  508. jobNumber: jobNumber,
  509. token: token
  510. } , res => {
  511. if (res.code == "ok") {
  512. if(res.data.moduleList.length == 0){
  513. this.$message({
  514. message: this.$t('qing-lian-xi-guan-li-yuan-wei')+'\u3000' + res.data.roleName + '\u3000'+this.$t('assignpermissions'),
  515. type: 'error'
  516. })
  517. return
  518. }
  519. var user = res.data;
  520. sessionStorage.setItem('user', JSON.stringify(res.data));
  521. this.permissionsList(res.data)
  522. if (user.company.packageSimple == 1) {
  523. //简易模式,直接进入工时统计表
  524. this.$router.push({ path: '/simple' });
  525. sessionStorage.setItem('autoRoute','/simple')
  526. } else {
  527. if(user.moduleList.length > 0) {
  528. this.$router.push({ path: user.moduleList[0].path })
  529. sessionStorage.setItem('autoRoute',user.moduleList[0].path)
  530. } else {
  531. //没有授权任何模块,需要提示用户
  532. alert('无权访问,请联系管理员为您分配权限');
  533. }
  534. }
  535. } else {
  536. this.$message({
  537. message: res.msg,
  538. type: 'error'
  539. });
  540. }
  541. }, error => {
  542. this.$message({
  543. message: error,
  544. type: 'error'
  545. });
  546. })
  547. },
  548. // 飞书登陆
  549. flyingBook(appid, code) {
  550. this.http.post('/feishu-info/loginByFeishu', {
  551. appId: appid,
  552. code: code
  553. } , res => {
  554. console.log(res, '接口返回')
  555. if (res.code == "ok") {
  556. var user = res.data;
  557. localStorage.user = JSON.stringify(res.data);
  558. sessionStorage.setItem('user', JSON.stringify(res.data));
  559. this.permissionsList(res.data)
  560. if(user.moduleList.length > 0) {
  561. this.$router.push({ path: user.moduleList[0].path })
  562. } else {
  563. //没有授权任何模块,需要提示用户
  564. alert('无权访问,请联系管理员为您分配权限');
  565. }
  566. } else {
  567. this.$message({
  568. message: res.msg,
  569. type: 'error'
  570. });
  571. }
  572. }, error => {
  573. console.log(error, '抛出异常')
  574. this.$message({
  575. message: error,
  576. type: 'error'
  577. });
  578. })
  579. },
  580. // 权限控制
  581. permissionsList(item) {
  582. var arr = []
  583. var ss = item.functionList
  584. for(var i in ss) {
  585. arr.push(ss[i].name)
  586. }
  587. var ssAkl = this.StringUtil.permissions(arr)
  588. sessionStorage.setItem('permissions', JSON.stringify(ssAkl));
  589. // console.log(ssAkl, '返回过来的数据原--------')
  590. },
  591. },
  592. }
  593. </script>
  594. <style lang="scss" scoped>
  595. .qiweix {
  596. width: 100%;
  597. display: flex;
  598. justify-content: center;
  599. padding: 50px 0;
  600. font-size: 40px;
  601. color: #505458;
  602. }
  603. .additional {
  604. width: 100%;
  605. text-align: center;
  606. padding: 20px 0;
  607. color: #505458;
  608. }
  609. .externalLanding {
  610. width: 100%;
  611. display: flex;
  612. justify-content: center;
  613. .externalLanding_img {
  614. width: 30px;
  615. height: 30px;
  616. border: 1px solid #409EFF;
  617. border-radius: 50%;
  618. position: relative;
  619. overflow: hidden;
  620. cursor: pointer;
  621. display: flex;
  622. justify-content: center;
  623. align-items: center;
  624. img {
  625. width: 80%;
  626. height: 80%;
  627. }
  628. }
  629. }
  630. .login {
  631. height: 100%;
  632. .login-par {
  633. width: 100%;
  634. // min-height: 100%;
  635. height: 100vh;
  636. background: #f0f2f5 url('../assets/image/background.png') no-repeat 50%;
  637. background-size: 100%;
  638. padding: 110px 0 144px;
  639. position: relative;
  640. box-sizing: border-box;
  641. .login-logo {
  642. text-align: center;
  643. margin: 0 0 20px 0;
  644. }
  645. .login-container {
  646. -webkit-border-radius: 5px;
  647. border-radius: 5px;
  648. -moz-border-radius: 5px;
  649. background-clip: padding-box;
  650. width: 315px;
  651. // height: 380px;
  652. padding: 25px 35px 25px 35px;
  653. background: #fff;
  654. border: 1px solid #eaeaea;
  655. box-shadow: 0 0 5px #cac6c6;
  656. border-top: 10px solid #20a0ff;
  657. margin:auto;
  658. .title {
  659. font-size: 20px;
  660. margin: 0px auto 40px auto;
  661. text-align: center;
  662. color: #505458;
  663. }
  664. .remember {
  665. margin: 0px 0px 35px 0px;
  666. }
  667. .login-input {
  668. margin: 30px 0 0 0;
  669. }
  670. .login-button {
  671. margin: 30px 0 0 0;
  672. }
  673. .login-button .el-button {
  674. padding: 14px;
  675. }
  676. }
  677. }
  678. }
  679. .toRegister {
  680. margin: 15px 0;
  681. text-align: right;
  682. position: relative;
  683. .service {
  684. display: none;
  685. width: 120px;
  686. position: absolute;
  687. background: #fff;
  688. text-align: center;
  689. padding: 10px;
  690. left: -30px;
  691. top: -210px;
  692. border-radius: 5px;
  693. box-shadow: 3px 3px 10px #dfdfdf;
  694. img {
  695. width: 80px;
  696. }
  697. }
  698. }
  699. .btn:hover .service {
  700. display: block;
  701. }
  702. </style>