Selaa lähdekoodia

app是否开启微信登录配置

pengjing 5 kuukautta sitten
vanhempi
commit
f292b7277b
1 muutettua tiedostoa jossa 22 lisäystä ja 24 poistoa
  1. 22 24
      parth5/parth5/src/app/views/index/index.page.ts

+ 22 - 24
parth5/parth5/src/app/views/index/index.page.ts

@@ -17,40 +17,38 @@ export class IndexPage implements OnInit {
 
   constructor(private router: Router, private route: ActivatedRoute, private wxcpService: WxcpService, private userService: UserService,
               private configService: ConfigService, private accountService: AccountService, private routeInfo: ActivatedRoute) {
+
   }
 
   ngOnInit() {
   }
 
   ionViewWillEnter() {
-
     this.configService.GetConfig().subscribe((config) => {
       this.isWxLogin = config.isWxLogin;
-    });
-
-    const urlParams = getUrlParams() as any;
-    if (this.wxcpService.isWechat() && this.isWxLogin) {
-      let routePath = urlParams["routePath"] || '/tapp/tabs/tabMain'; //登录成功后跳转地址
-      routePath = decodeURIComponent(routePath);
 
-      const wxUserId = urlParams["wxUserId"] || this.userService.getWxUserID();
-      if (wxUserId) {
-        //根据微信用户id登录系统
-        this.accountService.loginByWxUserId(wxUserId, routePath);
+      const urlParams = getUrlParams() as any;
+      if (this.wxcpService.isWechat() && this.isWxLogin) {
+        let routePath = urlParams["routePath"] || '/tapp/tabs/tabMain'; //登录成功后跳转地址
+        routePath = decodeURIComponent(routePath);
+
+        const wxUserId = urlParams["wxUserId"] || this.userService.getWxUserID();
+        if (wxUserId) {
+          //根据微信用户id登录系统
+          this.accountService.loginByWxUserId(wxUserId, routePath);
+        } else {
+          this.wxcpService.wxAuth(routePath).then(res => {
+            if (res === false) {
+              this.router.navigate(['/login'], {
+                relativeTo: this.routeInfo,
+                queryParams: {random: Math.random()}
+              });
+            }
+          });
+        }
       } else {
-        this.wxcpService.wxAuth(routePath).then(res => {
-          if (res === false) {
-            this.router.navigate(['/login'], {
-              relativeTo: this.routeInfo,
-              queryParams: {random: Math.random()}
-            });
-          }
-        });
+        this.router.navigate(['/login'], {queryParams: {random: Math.random()}});
       }
-    } else {
-      this.router.navigate(['/login'], {queryParams: {random: Math.random()}});
-    }
+    });
   }
-
-
 }