|
@@ -58,17 +58,27 @@ export default defineComponent({
|
|
// }
|
|
// }
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- // async getAppIdAndCode() {
|
|
|
|
- // try {
|
|
|
|
- // const { data } = await request.get('/api-student/open/paramConfig/wechatAppId')
|
|
|
|
- // // 判断是否有微信appId
|
|
|
|
- // if (data) {
|
|
|
|
- // this.wxAppId = data
|
|
|
|
- // }
|
|
|
|
- // } catch {
|
|
|
|
- // //
|
|
|
|
- // }
|
|
|
|
- // },
|
|
|
|
|
|
+ async getAppIdAndCode(url?: string) {
|
|
|
|
+ try {
|
|
|
|
+ const { data } = await request.get('/api-student/open/paramConfig/wechatAppId')
|
|
|
|
+ // 判断是否有微信appId
|
|
|
|
+ if (data) {
|
|
|
|
+ this.goAuth(data, url)
|
|
|
|
+ }
|
|
|
|
+ } catch {
|
|
|
|
+ //
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ goAuth(wxAppId: string, urlString?: string) {
|
|
|
|
+ // 用户授权
|
|
|
|
+ console.log(urlString || window.location.href, 'urlString || window.location.href')
|
|
|
|
+ const urlNow = encodeURIComponent(urlString || window.location.href)
|
|
|
|
+ console.log(urlNow, 'urlNow')
|
|
|
|
+ const scope = 'snsapi_base' //snsapi_userinfo //静默授权 用户无感知
|
|
|
|
+ const appid = wxAppId || 'wx8654c671631cfade'
|
|
|
|
+ const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${urlNow}&response_type=code&scope=${scope}&state=STATE&connect_redirect=1#wechat_redirect`
|
|
|
|
+ window.location.replace(url)
|
|
|
|
+ },
|
|
directNext() {
|
|
directNext() {
|
|
if (state.user.status === 'login' || state.user.status === 'error') {
|
|
if (state.user.status === 'login' || state.user.status === 'error') {
|
|
const { returnUrl, isRegister, ...rest } = this.$route.query
|
|
const { returnUrl, isRegister, ...rest } = this.$route.query
|
|
@@ -97,9 +107,9 @@ export default defineComponent({
|
|
'?' +
|
|
'?' +
|
|
qs.stringify({
|
|
qs.stringify({
|
|
...rest
|
|
...rest
|
|
- // wxAppId: this.wxAppId
|
|
|
|
})
|
|
})
|
|
- this.locationReplace(newUrl)
|
|
|
|
|
|
+ this.getAppIdAndCode(newUrl)
|
|
|
|
+ // this.locationReplace(newUrl)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
locationReplace(url: any) {
|
|
locationReplace(url: any) {
|