|
|
@@ -383,7 +383,7 @@
|
|
|
}
|
|
|
this.validUserName()
|
|
|
if (this.$route.query.code) {
|
|
|
- this.bindOrEnterprise()
|
|
|
+ this.wxEnterprise()
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
@@ -441,17 +441,16 @@
|
|
|
},
|
|
|
// 获取url参数
|
|
|
getUrl () {
|
|
|
- console.log(this.$route, '111')
|
|
|
- let wxUrl = ''
|
|
|
+ let wUrl = ''
|
|
|
if (this.$route.query) {
|
|
|
for (var key in this.$route.query) {
|
|
|
if (key !== 'code' && key !== 'state') {
|
|
|
- wxUrl += `${key}=${this.$route.query[key]}&`
|
|
|
+ wUrl += `${key}=${encodeURIComponent(this.$route.query[key])}&`
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (this.$route.query === '') {
|
|
|
- this.wxUrl = `${window.location.origin}?${wxUrl.substr(0, wxUrl.length - 1)}`
|
|
|
+ if (this.$route.query) {
|
|
|
+ this.wxUrl = `${window.location.origin}?${wUrl.substr(0, wUrl.length - 1)}`
|
|
|
} else {
|
|
|
this.wxUrl = `${window.location.origin}`
|
|
|
}
|
|
|
@@ -760,84 +759,8 @@
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- // 微信判断企业账套
|
|
|
+ // 微信判断绑定和账套选择
|
|
|
wxEnterprise () {
|
|
|
- let param = new FormData()
|
|
|
- param.append('code', this.$route.query.code ? this.$route.query.code : '')
|
|
|
- param.append('state', this.$route.query.state ? this.$route.query.state : '')
|
|
|
- param.append('appId', this.$route.query.appId ? this.$route.query.appId : '')
|
|
|
- param.append('returnUrl', this.$route.query.returnURL ? this.$route.query.returnURL : '')
|
|
|
- param.append('baseUrl', this.$route.query.baseUrl ? this.$route.query.baseUrl : '')
|
|
|
- param.append('spaceUU', this.login.spaceUU ? this.login.spaceUU : '')
|
|
|
- let config = {
|
|
|
- headers: {'Content-Type': 'multipart/form-data'}
|
|
|
- }
|
|
|
- this.$http.post('/sso/login/wxqrLogin', param, config)
|
|
|
- .then(response => {
|
|
|
- this.isShowLoading = false
|
|
|
- if (response.data.success) {
|
|
|
- if (response.data.content.spaces) {
|
|
|
-// 弹框让用户选择企业
|
|
|
- this.$store.commit('login/chooseRegisterEnterprise/GET_ENTERPRISE_SUCCESS', response.data.content.spaces)
|
|
|
- this.dialogVisible = true
|
|
|
- } else if (response.data.content.loginUrls) {
|
|
|
-// 遍历登录url循环让各应用登录(需要跨域)
|
|
|
- let param = response.data.content.data
|
|
|
- let a = ''
|
|
|
- for (let n in param) {
|
|
|
- a += (n + '=' + encodeURIComponent(param[n]) + '&')
|
|
|
- }
|
|
|
- let params = a.substr(0, a.length - 1)
|
|
|
- this.isShowLoading = true
|
|
|
- if (response.data.content.currentUrl) {
|
|
|
- this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
|
|
|
- name: 'successCallback',
|
|
|
- timeout: 3000
|
|
|
- }, (err, data) => {
|
|
|
- if (err) {
|
|
|
- this.$message.error('登录超时,请重试')
|
|
|
- this.isShowLoading = false
|
|
|
- throw err
|
|
|
- } else {
|
|
|
- this.loginOther(response, params)
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.loginOther(response, params, 3000)
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.$message.error(response.data)
|
|
|
- return Promise.reject(response.data)
|
|
|
- }
|
|
|
- }).catch(err => {
|
|
|
- this.isShowLoading = false
|
|
|
- let _this = this
|
|
|
- setTimeout(function () {
|
|
|
- _this.getCode()
|
|
|
- }, 100)
|
|
|
- this.$message.error(err.errMsg)
|
|
|
- })
|
|
|
- },
|
|
|
- // 微信扫码登录
|
|
|
- getScan () {
|
|
|
- // this.loginWay = 1
|
|
|
- this.isShowLoading = true
|
|
|
- this.$http.get('/weChat/getQrUrl', {params: {appId: this.$route.query.appId, url: this.wxUrl}})
|
|
|
- .then(response => {
|
|
|
- this.isShowLoading = false
|
|
|
- if (response.data.success) {
|
|
|
- window.location.href = response.data.content
|
|
|
- } else {
|
|
|
- return Promise.reject(response.data)
|
|
|
- }
|
|
|
- }).catch(err => {
|
|
|
- this.isShowLoading = false
|
|
|
- this.$message.error(err.errMsg)
|
|
|
- })
|
|
|
- },
|
|
|
- // 判断是否绑定企业
|
|
|
- bindOrEnterprise () {
|
|
|
this.isShowLoading = true
|
|
|
if (this.$route.query.code) {
|
|
|
let param = new FormData()
|
|
|
@@ -862,25 +785,73 @@
|
|
|
if (response.data.success) {
|
|
|
this.wxImg = response.data.content.headimgurl
|
|
|
this.wxName = response.data.content.nickname
|
|
|
- console.log(response.data, '333')
|
|
|
} else {
|
|
|
return Promise.reject(response.data)
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
this.$message.error(err.errMsg)
|
|
|
})
|
|
|
- } else {
|
|
|
- this.wxEnterprise()
|
|
|
+ } else if (response.data.content.spaces) {
|
|
|
+// 弹框让用户选择企业
|
|
|
+ this.$store.commit('login/chooseRegisterEnterprise/GET_ENTERPRISE_SUCCESS', response.data.content.spaces)
|
|
|
+ this.dialogVisible = true
|
|
|
+ } else if (response.data.content.loginUrls) {
|
|
|
+// 遍历登录url循环让各应用登录(需要跨域)
|
|
|
+ let param = response.data.content.data
|
|
|
+ let a = ''
|
|
|
+ for (let n in param) {
|
|
|
+ a += (n + '=' + encodeURIComponent(param[n]) + '&')
|
|
|
+ }
|
|
|
+ let params = a.substr(0, a.length - 1)
|
|
|
+ this.isShowLoading = true
|
|
|
+ if (response.data.content.currentUrl) {
|
|
|
+ this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
|
|
|
+ name: 'successCallback',
|
|
|
+ timeout: 3000
|
|
|
+ }, (err, data) => {
|
|
|
+ if (err) {
|
|
|
+ this.$message.error('登录超时,请重试')
|
|
|
+ this.isShowLoading = false
|
|
|
+ throw err
|
|
|
+ } else {
|
|
|
+ this.loginOther(response, params)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.loginOther(response, params, 3000)
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
+ this.$message.error(response.data)
|
|
|
return Promise.reject(response.data)
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
this.isShowLoading = false
|
|
|
+ let _this = this
|
|
|
+ setTimeout(function () {
|
|
|
+ _this.getCode()
|
|
|
+ }, 100)
|
|
|
this.$message.error(err.errMsg)
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
+ // 微信扫码登录
|
|
|
+ getScan () {
|
|
|
+ // this.loginWay = 1
|
|
|
+ this.isShowLoading = true
|
|
|
+ this.$http.get('/weChat/getQrUrl', {params: {appId: this.$route.query.appId, url: this.wxUrl}})
|
|
|
+ .then(response => {
|
|
|
+ this.isShowLoading = false
|
|
|
+ if (response.data.success) {
|
|
|
+ window.location.href = response.data.content
|
|
|
+ } else {
|
|
|
+ return Promise.reject(response.data)
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.isShowLoading = false
|
|
|
+ this.$message.error(err.errMsg)
|
|
|
+ })
|
|
|
+ },
|
|
|
// 绑定企业
|
|
|
wxBind () {
|
|
|
this.isShowLoading = true
|