|
@@ -23,6 +23,7 @@ export default defineComponent({
|
|
|
// countDownRef: null as any, // 倒计时实例
|
|
|
imgCodeStatus: false,
|
|
|
showPopup: false,
|
|
|
+ wxAppId: '', //
|
|
|
code: '' // 授权code码
|
|
|
}
|
|
|
},
|
|
@@ -38,40 +39,36 @@ export default defineComponent({
|
|
|
this.directNext()
|
|
|
|
|
|
// 判断是否是微信,只能微信中打开
|
|
|
- if (browser().weixin) {
|
|
|
- // 微信公众号支付
|
|
|
- //授权
|
|
|
- const code = getUrlCode()
|
|
|
- console.log('login mounted code: ' + code)
|
|
|
- if (!code) {
|
|
|
- this.getAppIdAndCode()
|
|
|
- } else {
|
|
|
- this.code = code
|
|
|
- }
|
|
|
- } else {
|
|
|
+ if (!browser().weixin) {
|
|
|
this.showPopup = true
|
|
|
}
|
|
|
+ // if (browser().weixin) {
|
|
|
+ // 微信公众号支付
|
|
|
+ //授权
|
|
|
+ // const code = getUrlCode()
|
|
|
+ // console.log('login mounted code: ' + code)
|
|
|
+ // if (!code) {
|
|
|
+ // this.getAppIdAndCode()
|
|
|
+ // } else {
|
|
|
+ // this.code = code
|
|
|
+ // }
|
|
|
+ // this.getAppIdAndCode()
|
|
|
+ // } else {
|
|
|
+ // this.showPopup = true
|
|
|
+ // }
|
|
|
},
|
|
|
methods: {
|
|
|
- async getAppIdAndCode() {
|
|
|
- try {
|
|
|
- const { data } = await request.get('/api-student/open/paramConfig/wechatAppId')
|
|
|
- // 判断是否有微信appId
|
|
|
- if (data) {
|
|
|
- this.goAuth(data)
|
|
|
- }
|
|
|
- } catch {
|
|
|
- //
|
|
|
- }
|
|
|
- },
|
|
|
- goAuth(wxAppId: string) {
|
|
|
- // 用户授权
|
|
|
- const urlNow = encodeURIComponent(window.location.href)
|
|
|
- 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)
|
|
|
- },
|
|
|
+ // async getAppIdAndCode() {
|
|
|
+ // try {
|
|
|
+ // const { data } = await request.get('/api-student/open/paramConfig/wechatAppId')
|
|
|
+ // // 判断是否有微信appId
|
|
|
+ // if (data) {
|
|
|
+ // this.wxAppId = data
|
|
|
+ // }
|
|
|
+ // } catch {
|
|
|
+ // //
|
|
|
+ // }
|
|
|
+ // },
|
|
|
directNext() {
|
|
|
if (state.user.status === 'login' || state.user.status === 'error') {
|
|
|
const { returnUrl, isRegister, ...rest } = this.$route.query
|
|
@@ -82,6 +79,8 @@ export default defineComponent({
|
|
|
},
|
|
|
'jump pre registration'
|
|
|
)
|
|
|
+
|
|
|
+ // this.goAuth(data)
|
|
|
// console.log(returnUrl, isRegister, { ...rest })
|
|
|
// this.$router.replace({
|
|
|
// path: returnUrl as any,
|
|
@@ -97,15 +96,15 @@ export default defineComponent({
|
|
|
returnUrl +
|
|
|
'?' +
|
|
|
qs.stringify({
|
|
|
- ...rest,
|
|
|
- code: this.code
|
|
|
+ ...rest
|
|
|
+ // wxAppId: this.wxAppId
|
|
|
})
|
|
|
this.locationReplace(newUrl)
|
|
|
}
|
|
|
},
|
|
|
locationReplace(url: any) {
|
|
|
// 只允许同域名
|
|
|
- console.log(history.replaceState, 'window.history.replaceState')
|
|
|
+ console.log(history.replaceState, 'window.history.replaceState', url)
|
|
|
if (history.replaceState) {
|
|
|
history.replaceState(null, document.title, url)
|
|
|
history.go(0)
|