| | |
| | | |
| | | <script> |
| | | import { mapMutations } from 'vuex' |
| | | import { getCaptcha, loginByPassword } from '@/api/system/common' |
| | | |
| | | import { getCaptcha, loginByPassword, loginByDingTalk } from '@/api/system/common' |
| | | import * as dd from 'dingtalk-jsapi'; |
| | | export default { |
| | | name: 'Login', |
| | | data () { |
| | |
| | | loading: false, |
| | | username: '', |
| | | password: '', |
| | | unionId: '', |
| | | // 验证码 |
| | | captcha: { |
| | | loading: false, |
| | |
| | | username: this.username.trim(), |
| | | password: this.password, |
| | | code: this.captcha.value.trim(), |
| | | uuid: this.captcha.uuid |
| | | uuid: this.captcha.uuid, |
| | | unionId: this.unionId |
| | | },true) |
| | | .then(() => { |
| | | window.location.href = process.env.VUE_APP_CONTEXT_PATH |
| | |
| | | }, |
| | | created () { |
| | | this.refreshCaptcha() |
| | | var that = this |
| | | let href = window.location.href; |
| | | let corpId = '' |
| | | if (dd.env.platform !== 'notInDingTalk') { |
| | | // 先判断地址上有没有corpId |
| | | if (href.indexOf('?corpid=') !== -1) { |
| | | // alert('从地址拿corpid') |
| | | corpId = href.substring(href.lastIndexOf('?corpid=') + 8, href.lastIndexOf('#')) |
| | | window.localStorage.setItem('corpId', corpId) |
| | | // 判断浏览器缓存是否有corpId |
| | | } else if (window.localStorage.getItem('corpId')) { |
| | | corpId = window.localStorage.getItem('corpId') |
| | | // alert('从缓存拿corpid') |
| | | } |
| | | // dingulzemj5bynjciapg |
| | | dd.requestAuthCode({ |
| | | corpId: corpId, |
| | | clientId: 'dingy7xdyzffnegiaszo', |
| | | onSuccess: function(result) { |
| | | loginByDingTalk({ |
| | | code: result.code, |
| | | corpId: corpId |
| | | }).then(res => { |
| | | if (res.loginStatus) { |
| | | window.location.href = process.env.VUE_APP_CONTEXT_PATH |
| | | return |
| | | } |
| | | that.unionId = res.unionId |
| | | }) |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | </script> |