|
@@ -30,6 +30,7 @@ import dayjs from 'dayjs'
|
|
|
import { browser, getUrlCode } from '@/helpers/utils'
|
|
|
import OUpload from '@/components/o-upload'
|
|
|
import qs from 'query-string'
|
|
|
+import { goWechatAuth } from '@/state'
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'companion-teacher-register',
|
|
@@ -130,28 +131,28 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
// 判断是否是微信,只能微信中打开
|
|
|
- // if (!browser().weixin) {
|
|
|
- // state.showPopup = true
|
|
|
- // return
|
|
|
- // } else {
|
|
|
- // //授权
|
|
|
- // const code = getUrlCode()
|
|
|
- // if (!code) {
|
|
|
- // const newUrl =
|
|
|
- // window.location.origin +
|
|
|
- // window.location.pathname +
|
|
|
- // '#' +
|
|
|
- // route.path +
|
|
|
- // '?' +
|
|
|
- // qs.stringify({
|
|
|
- // ...route.query
|
|
|
- // })
|
|
|
- // getAppIdAndCode(newUrl)
|
|
|
- // return
|
|
|
- // } else {
|
|
|
- // state.code = code
|
|
|
- // }
|
|
|
- // }
|
|
|
+ if (!browser().weixin) {
|
|
|
+ state.showPopup = true
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ //授权
|
|
|
+ const code = getUrlCode()
|
|
|
+ if (!code) {
|
|
|
+ const newUrl =
|
|
|
+ window.location.origin +
|
|
|
+ window.location.pathname +
|
|
|
+ '#' +
|
|
|
+ route.path +
|
|
|
+ '?' +
|
|
|
+ qs.stringify({
|
|
|
+ ...route.query
|
|
|
+ })
|
|
|
+ getAppIdAndCode(newUrl)
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ state.code = code
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// t: route.query.t, // 过期时间
|
|
|
try {
|
|
@@ -234,22 +235,23 @@ export default defineComponent({
|
|
|
// 判断是否有微信appId
|
|
|
if (data) {
|
|
|
closeToast()
|
|
|
- goAuth(data, url)
|
|
|
+ // goAuth(data, url)
|
|
|
+ goWechatAuth(data, url)
|
|
|
}
|
|
|
} catch {
|
|
|
//
|
|
|
}
|
|
|
}
|
|
|
- const 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)
|
|
|
- }
|
|
|
+ // const 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)
|
|
|
+ // }
|
|
|
|
|
|
const onPreview = (type: string) => {
|
|
|
if (type === 'REGISTER') {
|