Browse Source

通知詳情頁面

pengjing 10 months ago
parent
commit
81f696467c
2 changed files with 18 additions and 9 deletions
  1. 14 7
      h5app/src/utils/wechat.ts
  2. 4 2
      h5app/src/views/index.vue

+ 14 - 7
h5app/src/utils/wechat.ts

@@ -18,21 +18,28 @@ export const wxAuth = async <Object>(redirectUrl: string): Promise<string> => {
             })
             const urlParams = getUrlParams() as any;
             const code = urlParams["code"];
-            const loading = await loadingController.create({
-                cssClass: 'my-custom-class',
-                message: '微信授权中,请稍后...',
-                duration: 2000,
-            });
-            await loading.present();
+
             if (!code) {
+                const loading = await loadingController.create({
+                    cssClass: 'my-custom-class',
+                    message: '微信授权中,请稍等...',
+                    duration: 2000,
+                });
+                await loading.present();
                 getOAuthUrl(encodeURIComponent(redirectUrl)).then((res: any) => {
                     if (res) {
-                        window.location.href = res;
+                        window.location.replace(res);
                     } else {
                         presentAlert("微信授权失败!");
                     }
                 });
             } else {
+                const loading = await loadingController.create({
+                    cssClass: 'my-custom-class',
+                    message: '微信授权成功,请稍等...',
+                    duration: 2000,
+                });
+                await loading.present();
                 await getWxOpenId(code).then((res: any) => {
                     userStore.setOpenId(res);
                 });

+ 4 - 2
h5app/src/views/index.vue

@@ -1,5 +1,7 @@
 <template>
-  <div></div>
+  <div>
+    系统加载中,请稍等...
+  </div>
 </template>
 <script>
 import {defineComponent, ref} from "vue";
@@ -25,7 +27,7 @@ export default defineComponent({
       await wxAuth(redirectUrl);
     };
 
-    if (isWechat()) {
+    if (isWechat() && redirectUrl.indexOf("wxMessage") < 0) {
       wxLogin().then(res => {
         router.push(redirectUrl);
       });