Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

lizeyu 7 месяцев назад
Родитель
Сommit
25938b1289

+ 1 - 0
parth5/parth5/src/app/service/config.service.ts

@@ -21,6 +21,7 @@ export interface Config {
   siteUrl: string;
   isWxPay: boolean;
   isDev?: boolean;
+  isWxLogin?: boolean;
 }
 
 export interface RequsetData {

+ 29 - 23
parth5/parth5/src/app/views/index/index.page.ts

@@ -4,6 +4,7 @@ import {WxcpService} from "../../service/wxcp.service";
 import {ActivatedRoute, Router} from "@angular/router";
 import {UserService} from "../../service/user.service";
 import {AccountService} from "../../service/account.service";
+import {ConfigService} from "../../service/config.service";
 
 @Component({
   selector: 'app-index',
@@ -12,37 +13,42 @@ import {AccountService} from "../../service/account.service";
 })
 export class IndexPage implements OnInit {
 
+  isWxLogin: boolean = false;
+
   constructor(private router: Router, private route: ActivatedRoute, private wxcpService: WxcpService, private userService: UserService,
-              private accountService: AccountService, private routeInfo: ActivatedRoute) {
+              private configService: ConfigService, private accountService: AccountService, private routeInfo: ActivatedRoute) {
+
   }
 
   ngOnInit() {
   }
 
   ionViewWillEnter() {
-    const urlParams = getUrlParams() as any;
-    if (this.wxcpService.isWechat()) {
-      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);
+    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);
+        } 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()}});
-    }
+    });
   }
-
-
 }

+ 2 - 1
parth5/parth5/src/assets/appconfig.json

@@ -3,5 +3,6 @@
   "webServerHost": "http://localhost:8062",
   "siteUrl": "http://localhost:8062/mobile",
   "isWxPay": true,
-  "isDev": true
+  "isDev": true,
+  "isWxLogin": false
 }