|
@@ -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()}});
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|