|
@@ -40,7 +40,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { validUsername } from '@/utils/validate'
|
|
|
-
|
|
|
+import { getJson } from '@/api/common'
|
|
|
export default {
|
|
|
name: 'Login',
|
|
|
data() {
|
|
@@ -88,14 +88,15 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- var that = this
|
|
|
- document.onkeydown = function(e) {
|
|
|
- e = window.event || e
|
|
|
- // eslint-disable-next-line eqeqeq
|
|
|
- if (that.$route.path == '/login' && (e.code == 'Enter' || e.code == 'Num Enter')) { // 验证在登录界面和按得键是回车键enter
|
|
|
- that.handleLogin('ruleForm2') // 登录函数 (handleSubmit2('ruleForm2')-登录按钮的点击事件)
|
|
|
- }
|
|
|
- }
|
|
|
+ // var that = this
|
|
|
+ // document.onkeydown = function(e) {
|
|
|
+ // e = window.event || e
|
|
|
+ // // eslint-disable-next-line eqeqeq
|
|
|
+ // if (that.$route.path == '/login' && (e.code == 'Enter' || e.code == 'Num Enter')) { // 验证在登录界面和按得键是回车键enter
|
|
|
+ // that.handleLogin('ruleForm2') // 登录函数 (handleSubmit2('ruleForm2')-登录按钮的点击事件)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ this.getcodeList()
|
|
|
},
|
|
|
methods: {
|
|
|
showPwd() {
|
|
@@ -108,25 +109,45 @@ export default {
|
|
|
this.$refs.password.focus()
|
|
|
})
|
|
|
},
|
|
|
- handleLogin() {
|
|
|
- this.$refs.loginForm.validate(valid => {
|
|
|
- if (valid) {
|
|
|
- this.$store.dispatch('user/login', this.loginForm) .then(() => {
|
|
|
- // const re = new RegExp(`^(?=.*[a-z])(?=.*\\d)(?=.*\\W)[^]{8,32}$`)
|
|
|
- // if (!re.test(this.loginForm.password)) {
|
|
|
- // this.$router.push('/console/Changpwd')
|
|
|
- // console.log('密码不符合要求')
|
|
|
- // }
|
|
|
- this.$router.push({ path: this.redirect || '/' })
|
|
|
- this.loading = false
|
|
|
- }).catch(() => {
|
|
|
- this.loading = false
|
|
|
- })
|
|
|
- } else {
|
|
|
- console.log('error submit!!')
|
|
|
- return false
|
|
|
- }
|
|
|
- })
|
|
|
+ // handleLogin() {
|
|
|
+ // this.$refs.loginForm.validate(valid => {
|
|
|
+ // if (valid) {
|
|
|
+ // this.$store.dispatch('user/login', this.loginForm) .then(() => {
|
|
|
+ // // const re = new RegExp(`^(?=.*[a-z])(?=.*\\d)(?=.*\\W)[^]{8,32}$`)
|
|
|
+ // // if (!re.test(this.loginForm.password)) {
|
|
|
+ // // this.$router.push('/console/Changpwd')
|
|
|
+ // // console.log('密码不符合要求')
|
|
|
+ // // }
|
|
|
+ // this.$router.push({ path: this.redirect || '/' })
|
|
|
+ // this.loading = false
|
|
|
+ // }).catch(() => {
|
|
|
+ // this.loading = false
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // console.log('error submit!!')
|
|
|
+ // return false
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ getcodeList(){
|
|
|
+ // 获取完整的URL
|
|
|
+ const fullURL = window.location.href;
|
|
|
+ // 使用正则表达式提取code参数的值
|
|
|
+ const codeMatch = fullURL.match(/[\?&]code=([^&]+)/);
|
|
|
+ if (codeMatch) {
|
|
|
+ // 如果匹配成功,将code的值存储在组件的data中
|
|
|
+ this.code = codeMatch[1];
|
|
|
+ let url = 'http://tmrwatch.cn:8082/api/v1/oauth2/token'
|
|
|
+ let data = '?code='+this.code
|
|
|
+ console.log('logincode====>',this.code)
|
|
|
+ getJson(url,data).then(response => {
|
|
|
+ console.log(response)
|
|
|
+ //TODO 保存token
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|