Explorar o código

Merge branch 'master' of http://git.dayaedu.com/lex/orchestra-app

skyblued %!s(int64=2) %!d(string=hai) anos
pai
achega
4bed3a80fa

+ 3 - 3
src/router/index.ts

@@ -1,5 +1,5 @@
 import { browser } from '@/helpers/utils'
-import { Dialog } from 'vant'
+import { showDialog } from 'vant'
 import { createRouter, createWebHashHistory, createWebHistory, Router } from 'vue-router'
 import { postMessage } from '@/helpers/native-message'
 import routesTeacher from './routes-teacher'
@@ -52,9 +52,9 @@ router.onError((error) => {
     console.log(error)
     if (isChunkLoadFailed && !isOpen) {
       isOpen = true
-      Dialog.alert({
+      showDialog({
         title: '更新提示',
-        message: 'APP有更新请点击确定刷新页面?',
+        message: 'APP有更新请点击确定刷新页面',
         confirmButtonColor: 'var(--van-primary)'
       }).then(() => {
         // on close

+ 24 - 36
src/student/music-group/layout/login.tsx

@@ -42,33 +42,29 @@ export default defineComponent({
     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.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() {
       if (state.user.status === 'login' || state.user.status === 'error') {
         const { returnUrl, isRegister, ...rest } = this.$route.query
@@ -80,15 +76,6 @@ export default defineComponent({
           'jump pre registration'
         )
 
-        // this.goAuth(data)
-        // console.log(returnUrl, isRegister, { ...rest })
-        // this.$router.replace({
-        //   path: returnUrl as any,
-        //   query: {
-        //     ...rest,
-        //     code: this.code
-        //   }
-        // })
         const newUrl =
           window.location.origin +
           window.location.pathname +
@@ -97,9 +84,10 @@ export default defineComponent({
           '?' +
           qs.stringify({
             ...rest
-            // wxAppId: this.wxAppId
           })
-        this.locationReplace(newUrl)
+        // 直接跳转到授权页面
+        this.getAppIdAndCode(newUrl)
+        // this.locationReplace(newUrl)
       }
     },
     locationReplace(url: any) {

+ 41 - 31
src/student/music-group/pre-apply/index.tsx

@@ -107,18 +107,18 @@ export default defineComponent({
         }
 
         // 判断是否有openId 并且 purchase
-        if (!data.openId && !data.purchase) {
-          if (browser().weixin) {
-            // 微信公众号支付
-            //授权
-            const code = getUrlCode()
-            if (!code) {
-              // goAuth(data.wxAppId)
-            } else {
-              state.code = code
-            }
-          }
-        }
+        // if (!data.openId && !data.purchase) {
+        //   if (browser().weixin) {
+        //     // 微信公众号支付
+        //     //授权
+        //     const code = getUrlCode()
+        //     if (!code) {
+        //       goAuth(data.wxAppId)
+        //     } else {
+        //       state.code = code
+        //     }
+        //   }
+        // }
       } catch {
         //
       }
@@ -159,25 +159,35 @@ export default defineComponent({
       }
     }
 
-    // 先请求接口
-    getRegisterStatus()
-
-    onMounted(() => {
-      // state.code = route.query.code || ''
-      // const { height } = useRect(bannerRef.value)
-      // state.heightV = height
-      // 判断是否是微信,只能微信中打开
-      // if (browser().weixin) {
-      //   // 微信公众号支付
-      //   //授权
-      //   const code = getUrlCode()
-      //   if (!code || !state.code) {
-      //     getAppIdAndCode()
-      //   } else {
-      //     state.code = code
-      //   }
-      // }
-    })
+    // 先请求接口 判断是否有code
+    if (browser().weixin) {
+      // 微信公众号支付
+      //授权
+      const code = getUrlCode()
+      if (!code) {
+        getAppIdAndCode()
+      } else {
+        state.code = code
+        getRegisterStatus()
+      }
+    }
+
+    // onMounted(() => {
+    // state.code = route.query.code || ''
+    // const { height } = useRect(bannerRef.value)
+    // state.heightV = height
+    // 判断是否是微信,只能微信中打开
+    // if (browser().weixin) {
+    //   // 微信公众号支付
+    //   //授权
+    //   const code = getUrlCode()
+    //   if (!code || !state.code) {
+    //     getAppIdAndCode()
+    //   } else {
+    //     state.code = code
+    //   }
+    // }
+    // })
     return () => (
       <div class={styles.preApply}>
         <div class={styles.banner} ref={bannerRef}>

+ 4 - 2
src/student/music-group/pre-apply/order-detail.tsx

@@ -118,8 +118,10 @@ export default defineComponent({
         //     userId: config.userId
         //   }
         // })
-        window.location.href = window.location.origin
-        '/orchestra-student/#/payResult?' +
+
+        window.location.href =
+          window.location.origin +
+          '/orchestra-student/#/payResult?' +
           qs.stringify({
             pay_channel: val.pay_channel,
             wxAppId: config.wxAppId,