Login.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  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">{{ $t('huo') }}</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="$t('qiYeWeiXinSaoMaDengLu')" :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. {{ $t('zhengZaiJinRuXiTong') }}
  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' || windowHerf.indexOf('corpid') != '-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(this.$t('wuQuanFangWenQingLianXiGuanLiYuanWeiNinFenPeiQuanXian'));
  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(this.$t('wuQuanFangWenQingLianXiGuanLiYuanWeiNinFenPeiQuanXian'));
  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. let href = window.location.href;
  353. var appId = "ww4e237fd6abb635af";//企业微信第三方的SUIT ID
  354. var url = "https://worktime.ttkuaiban.com/api/corpWXAuth";//授权回调页面
  355. 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";
  356. window.location.href = weixinUrl;
  357. },
  358. tryDingDingUrlRedirect() {
  359. let currentAddress = window.location.href+'?ddLoginUnique=true';
  360. let ddFixedPrefix = 'http://auth.dingtalk.com/login?redirectUri='
  361. let ddFixedUrl = 'https://login.dingtalk.com/oauth2/auth?response_type=code&client_id=dingwa4tibze6jwz7mgv&scope=openid&state=dddd&redirect_uri=' + encodeURIComponent(`${ddFixedPrefix}${currentAddress}`)
  362. window.location.href = ddFixedUrl;
  363. // window.location.href = window.location.href+'?ddLoginUnique=true';
  364. },
  365. loginByUserId(userId, path) {
  366. this.http.post("/user/loginByUserId", {userId:userId} , res => {
  367. if (res.code == "ok") {
  368. var user = res.data;
  369. localStorage.user = JSON.stringify(res.data);
  370. sessionStorage.setItem('user', JSON.stringify(res.data));
  371. this.permissionsList(res.data)
  372. if(user.moduleList.length > 0) {
  373. if (path) {
  374. var action = '';
  375. //url上传来的格式
  376. if (path.includes('projectInside')) {
  377. //跳转进入项目的任务看板
  378. path = decodeURIComponent(path);
  379. console.log('pppp='+path);
  380. if (path.includes('@adjustBudget-')) {
  381. //需要打开分组预估工时设置
  382. action = path.split('@')[1];
  383. path = path.split('@')[0];
  384. }
  385. }
  386. console.log('action==='+action);
  387. sessionStorage.action = action
  388. this.$router.push({ path: path})
  389. } else {
  390. this.$router.push({ path: user.moduleList[0].path })
  391. }
  392. if (!path) {
  393. path = user.moduleList[0].path;
  394. }
  395. //去掉链接上存在的参数
  396. if (location.href.indexOf("?")>0) {
  397. var newHref = location.href.split("?")[0] + '#' + (path.indexOf('/')>-1?path:('/'+path));
  398. location.href = newHref;
  399. }
  400. } else {
  401. //没有授权任何模块,需要提示用户
  402. alert(this.$t('wuQuanFangWenQingLianXiGuanLiYuanWeiNinFenPeiQuanXian'));
  403. }
  404. } else {
  405. this.$message({
  406. message: res.msg,
  407. type: 'error'
  408. });
  409. }
  410. }, error => {
  411. this.$message({
  412. message: error,
  413. type: 'error'
  414. });
  415. })
  416. },
  417. loginByCode(code, corpId, jumpurl) {
  418. this.http.post("/dingding/getUserByCode", {code:code, corpid:corpId} , res => {
  419. if (res.code == "ok") {
  420. var user = res.data;
  421. localStorage.user = JSON.stringify(res.data);
  422. sessionStorage.setItem('user', JSON.stringify(res.data));
  423. this.permissionsList(res.data)
  424. if(jumpurl){
  425. this.$router.push({ path: jumpurl })
  426. }else if(user.moduleList.length > 0) {
  427. this.$router.push({ path: user.moduleList[0].path })
  428. }else {
  429. //没有授权任何模块,需要提示用户
  430. alert(this.$t('wuQuanFangWenQingLianXiGuanLiYuanWeiNinFenPeiQuanXian'));
  431. }
  432. } else {
  433. this.$message({
  434. message: res.msg,
  435. type: 'error'
  436. });
  437. }
  438. }, error => {
  439. this.$message({
  440. message: error,
  441. type: 'error'
  442. });
  443. })
  444. },
  445. handleReset2() {
  446. this.$refs.ruleForm.resetFields();
  447. },
  448. jumpTo() {
  449. this.$router.push({ path: '/register' });
  450. },
  451. handleSubmit(ev) {
  452. this.$refs.ruleForm.validate((valid) => {
  453. if (valid) {
  454. var _this = this;
  455. this.logining = true;
  456. setTimeout(function () {
  457. _this.logining = false;
  458. // console.log('执行')
  459. }, 15000);
  460. this.http.post(this.port.manage.login, this.ruleForm , res => {
  461. this.logining = false;
  462. if (res.code == "ok") {
  463. if(res.data.moduleList.length == 0){
  464. this.$message({
  465. message: this.$t('qing-lian-xi-guan-li-yuan-wei')+'\u3000' + res.data.roleName + '\u3000'+this.$t('assignpermissions'),
  466. type: 'error'
  467. })
  468. return
  469. }
  470. var user = res.data;
  471. sessionStorage.setItem('user', JSON.stringify(res.data));
  472. this.permissionsList(res.data)
  473. if (user.company.packageSimple == 1) {
  474. //简易模式,直接进入工时统计表
  475. this.$router.push({ path: '/simple' });
  476. sessionStorage.setItem('autoRoute','/simple')
  477. } else {
  478. if(user.moduleList.length > 0) {
  479. this.$router.push({ path: user.moduleList[0].path })
  480. sessionStorage.setItem('autoRoute',user.moduleList[0].path)
  481. }
  482. }
  483. } else {
  484. this.logining = false;
  485. // if(res.msg.indexOf('到期') != -1){
  486. // this.$router.push({ path: '/expire', query:{datetext:'2022.11.24',ddd: '111'}})
  487. // console.log('到期skip');
  488. // return
  489. // }
  490. this.$message({
  491. message: res.msg,
  492. type: 'error'
  493. });
  494. }
  495. }, error => {
  496. console.log('执行1')
  497. this.logining = false;
  498. this.$message({
  499. message: error,
  500. type: 'error'
  501. });
  502. })
  503. }
  504. });
  505. },
  506. // 米莱得用工号登录
  507. automaticLogin(jobNumber, token) {
  508. this.http.post('/user/loginAdminByThirdParty', {
  509. jobNumber: jobNumber,
  510. token: token
  511. } , res => {
  512. if (res.code == "ok") {
  513. if(res.data.moduleList.length == 0){
  514. this.$message({
  515. message: this.$t('qing-lian-xi-guan-li-yuan-wei')+'\u3000' + res.data.roleName + '\u3000'+this.$t('assignpermissions'),
  516. type: 'error'
  517. })
  518. return
  519. }
  520. var user = res.data;
  521. sessionStorage.setItem('user', JSON.stringify(res.data));
  522. this.permissionsList(res.data)
  523. if (user.company.packageSimple == 1) {
  524. //简易模式,直接进入工时统计表
  525. this.$router.push({ path: '/simple' });
  526. sessionStorage.setItem('autoRoute','/simple')
  527. } else {
  528. if(user.moduleList.length > 0) {
  529. this.$router.push({ path: user.moduleList[0].path })
  530. sessionStorage.setItem('autoRoute',user.moduleList[0].path)
  531. } else {
  532. //没有授权任何模块,需要提示用户
  533. alert(this.$t('wuQuanFangWenQingLianXiGuanLiYuanWeiNinFenPeiQuanXian'));
  534. }
  535. }
  536. } else {
  537. this.$message({
  538. message: res.msg,
  539. type: 'error'
  540. });
  541. }
  542. }, error => {
  543. this.$message({
  544. message: error,
  545. type: 'error'
  546. });
  547. })
  548. },
  549. // 飞书登陆
  550. flyingBook(appid, code) {
  551. this.http.post('/feishu-info/loginByFeishu', {
  552. appId: appid,
  553. code: code
  554. } , res => {
  555. console.log(res, '接口返回')
  556. if (res.code == "ok") {
  557. var user = res.data;
  558. localStorage.user = JSON.stringify(res.data);
  559. sessionStorage.setItem('user', JSON.stringify(res.data));
  560. this.permissionsList(res.data)
  561. if(user.moduleList.length > 0) {
  562. this.$router.push({ path: user.moduleList[0].path })
  563. } else {
  564. //没有授权任何模块,需要提示用户
  565. alert(this.$t('wuQuanFangWenQingLianXiGuanLiYuanWeiNinFenPeiQuanXian'));
  566. }
  567. } else {
  568. this.$message({
  569. message: res.msg,
  570. type: 'error'
  571. });
  572. }
  573. }, error => {
  574. console.log(error, '抛出异常')
  575. this.$message({
  576. message: error,
  577. type: 'error'
  578. });
  579. })
  580. },
  581. // 权限控制
  582. permissionsList(item) {
  583. var arr = []
  584. var ss = item.functionList
  585. for(var i in ss) {
  586. arr.push(ss[i].name)
  587. }
  588. var ssAkl = this.StringUtil.permissions(arr)
  589. sessionStorage.setItem('permissions', JSON.stringify(ssAkl));
  590. // console.log(ssAkl, '返回过来的数据原--------')
  591. },
  592. },
  593. }
  594. </script>
  595. <style lang="scss" scoped>
  596. .qiweix {
  597. width: 100%;
  598. display: flex;
  599. justify-content: center;
  600. padding: 50px 0;
  601. font-size: 40px;
  602. color: #505458;
  603. }
  604. .additional {
  605. width: 100%;
  606. text-align: center;
  607. padding: 20px 0;
  608. color: #505458;
  609. }
  610. .externalLanding {
  611. width: 100%;
  612. display: flex;
  613. justify-content: center;
  614. .externalLanding_img {
  615. width: 30px;
  616. height: 30px;
  617. border: 1px solid #409EFF;
  618. border-radius: 50%;
  619. position: relative;
  620. overflow: hidden;
  621. cursor: pointer;
  622. display: flex;
  623. justify-content: center;
  624. align-items: center;
  625. img {
  626. width: 80%;
  627. height: 80%;
  628. }
  629. }
  630. }
  631. .login {
  632. height: 100%;
  633. .login-par {
  634. width: 100%;
  635. // min-height: 100%;
  636. height: 100vh;
  637. background: #f0f2f5 url('../assets/image/background.png') no-repeat 50%;
  638. background-size: 100%;
  639. padding: 110px 0 144px;
  640. position: relative;
  641. box-sizing: border-box;
  642. .login-logo {
  643. text-align: center;
  644. margin: 0 0 20px 0;
  645. }
  646. .login-container {
  647. -webkit-border-radius: 5px;
  648. border-radius: 5px;
  649. -moz-border-radius: 5px;
  650. background-clip: padding-box;
  651. width: 315px;
  652. // height: 380px;
  653. padding: 25px 35px 25px 35px;
  654. background: #fff;
  655. border: 1px solid #eaeaea;
  656. box-shadow: 0 0 5px #cac6c6;
  657. border-top: 10px solid #20a0ff;
  658. margin:auto;
  659. .title {
  660. font-size: 20px;
  661. margin: 0px auto 40px auto;
  662. text-align: center;
  663. color: #505458;
  664. }
  665. .remember {
  666. margin: 0px 0px 35px 0px;
  667. }
  668. .login-input {
  669. margin: 30px 0 0 0;
  670. }
  671. .login-button {
  672. margin: 30px 0 0 0;
  673. }
  674. .login-button .el-button {
  675. padding: 14px;
  676. }
  677. }
  678. }
  679. }
  680. .toRegister {
  681. margin: 15px 0;
  682. text-align: right;
  683. position: relative;
  684. .service {
  685. display: none;
  686. width: 120px;
  687. position: absolute;
  688. background: #fff;
  689. text-align: center;
  690. padding: 10px;
  691. left: -30px;
  692. top: -210px;
  693. border-radius: 5px;
  694. box-shadow: 3px 3px 10px #dfdfdf;
  695. img {
  696. width: 80px;
  697. }
  698. }
  699. }
  700. .btn:hover .service {
  701. display: block;
  702. }
  703. </style>