|
@@ -1,4 +1,4 @@
|
|
-import { Component, OnInit } from '@angular/core';
|
|
|
|
|
|
+import { Component, OnInit, ViewChild } from '@angular/core';
|
|
import { LoginModule } from './login.module';
|
|
import { LoginModule } from './login.module';
|
|
import { AuthService } from "../../services/auth.service";
|
|
import { AuthService } from "../../services/auth.service";
|
|
import { AlertController, ModalController, ToastController } from "@ionic/angular";
|
|
import { AlertController, ModalController, ToastController } from "@ionic/angular";
|
|
@@ -7,14 +7,16 @@ import { Router, ActivatedRoute } from "@angular/router";
|
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
import { catchError } from "rxjs/operators";
|
|
import { catchError } from "rxjs/operators";
|
|
import { AgreementComponent } from "./agreement/agreement.component"
|
|
import { AgreementComponent } from "./agreement/agreement.component"
|
|
|
|
+import { TotasComponent } from '../../app/components/totas/totas.component';
|
|
@Component({
|
|
@Component({
|
|
standalone: true,
|
|
standalone: true,
|
|
- imports: [LoginModule,AgreementComponent],
|
|
|
|
|
|
+ imports: [LoginModule,AgreementComponent,TotasComponent],
|
|
selector: 'app-login',
|
|
selector: 'app-login',
|
|
templateUrl: './login.component.html',
|
|
templateUrl: './login.component.html',
|
|
styleUrls: ['./login.component.scss']
|
|
styleUrls: ['./login.component.scss']
|
|
})
|
|
})
|
|
export class LoginComponent implements OnInit {
|
|
export class LoginComponent implements OnInit {
|
|
|
|
+ @ViewChild(TotasComponent) totas: TotasComponent | undefined;
|
|
user: { username?: string; password?: string } = {
|
|
user: { username?: string; password?: string } = {
|
|
username: "",
|
|
username: "",
|
|
password: "",
|
|
password: "",
|
|
@@ -29,7 +31,9 @@ export class LoginComponent implements OnInit {
|
|
private modalController: ModalController,
|
|
private modalController: ModalController,
|
|
private alertController: AlertController
|
|
private alertController: AlertController
|
|
) {
|
|
) {
|
|
|
|
+ this.company = authServ.company
|
|
}
|
|
}
|
|
|
|
+
|
|
company: any;
|
|
company: any;
|
|
appName: any;
|
|
appName: any;
|
|
logo: any;
|
|
logo: any;
|
|
@@ -112,7 +116,6 @@ export class LoginComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
// 获取验证码
|
|
// 获取验证码
|
|
- //
|
|
|
|
vcode: string = ''
|
|
vcode: string = ''
|
|
mobile: string = ''
|
|
mobile: string = ''
|
|
loginToken: string = ""
|
|
loginToken: string = ""
|
|
@@ -136,6 +139,23 @@ export class LoginComponent implements OnInit {
|
|
toast.present();
|
|
toast.present();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ if(this.status == 'login'){
|
|
|
|
+ let query = new Parse.Query('_User')
|
|
|
|
+ query.equalTo('company',this.company)
|
|
|
|
+ query.equalTo('mobile',mobile)
|
|
|
|
+ query.select('objectId')
|
|
|
|
+ let r = await query.first()
|
|
|
|
+ if(!r?.id){
|
|
|
|
+ this.totas?.openTotas('用户手机号不存在,请先注册','warning')
|
|
|
|
+ // const toast = await this.toastController.create({
|
|
|
|
+ // message: "用户手机号不存在,请先注册",
|
|
|
|
+ // color: "danger",
|
|
|
|
+ // duration: 1000,
|
|
|
|
+ // });
|
|
|
|
+ // toast.present();
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
this.http
|
|
this.http
|
|
.post("https://server.fmode.cn/api/apig/message", {
|
|
.post("https://server.fmode.cn/api/apig/message", {
|
|
company: this.company,
|
|
company: this.company,
|
|
@@ -148,34 +168,6 @@ export class LoginComponent implements OnInit {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- code: any
|
|
|
|
- async Codelogin() {
|
|
|
|
- // console.log(this.company, this.mobile,this.code)
|
|
|
|
- if (!this.loginInfo.code) {
|
|
|
|
- const toast = await this.toastController.create({
|
|
|
|
- message: "请填写有效验证码",
|
|
|
|
- color: "danger",
|
|
|
|
- duration: 1000,
|
|
|
|
- });
|
|
|
|
- toast.present();
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this.http
|
|
|
|
- .get(`https://server.fmode.cn/api/auth/mobile?company=${this.company}&mobile=${this.loginInfo.mobile}&code=${this.loginInfo.code}`, {
|
|
|
|
- }).subscribe((res: any) => {
|
|
|
|
- console.log(res)
|
|
|
|
- if (res.code == 200) {
|
|
|
|
- Parse.User.become(res.data.token).then(async data => {
|
|
|
|
- console.log(data)
|
|
|
|
- if (data.id) {
|
|
|
|
- let url = 'home'
|
|
|
|
- this.router.navigate([url]).catch((err) => console.log(err));
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
changeType() {
|
|
changeType() {
|
|
let type = this.type
|
|
let type = this.type
|
|
if (type == 'password') {
|
|
if (type == 'password') {
|
|
@@ -249,7 +241,6 @@ export class LoginComponent implements OnInit {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 忘记密码部分逻辑
|
|
// 忘记密码部分逻辑
|
|
-
|
|
|
|
back() {
|
|
back() {
|
|
this.status = 'login'
|
|
this.status = 'login'
|
|
}
|
|
}
|
|
@@ -298,20 +289,9 @@ export class LoginComponent implements OnInit {
|
|
toast.present();
|
|
toast.present();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- console.log(666);
|
|
|
|
-
|
|
|
|
- if (this.reset.password.length < 6) {
|
|
|
|
- const toast = await this.toastController.create({
|
|
|
|
- message: "密码长度不得小于6位",
|
|
|
|
- color: "danger",
|
|
|
|
- duration: 1000,
|
|
|
|
- });
|
|
|
|
- toast.present();
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if (this.reset.password.length.length > 20) {
|
|
|
|
|
|
+ if (this.reset.password.length < 6 || this.reset.password.length.length > 20) {
|
|
const toast = await this.toastController.create({
|
|
const toast = await this.toastController.create({
|
|
- message: "密码长度不得大于20位",
|
|
|
|
|
|
+ message: "密码长度不得小于6位或大于20位",
|
|
color: "danger",
|
|
color: "danger",
|
|
duration: 1000,
|
|
duration: 1000,
|
|
});
|
|
});
|
|
@@ -327,7 +307,7 @@ export class LoginComponent implements OnInit {
|
|
toast.present();
|
|
toast.present();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (this.reset.confirmPassword < 6 || this.reset.password.trim() != this.reset.confirmPassword.trim()) {
|
|
|
|
|
|
+ if (this.reset.password.trim() != this.reset.confirmPassword.trim()) {
|
|
const toast = await this.toastController.create({
|
|
const toast = await this.toastController.create({
|
|
message: "两次输入密码不一致",
|
|
message: "两次输入密码不一致",
|
|
color: "danger",
|
|
color: "danger",
|
|
@@ -340,7 +320,7 @@ export class LoginComponent implements OnInit {
|
|
headers.append("Content-Type", "application/json");
|
|
headers.append("Content-Type", "application/json");
|
|
headers.set('Access-Control-Allow-Origin', '*')
|
|
headers.set('Access-Control-Allow-Origin', '*')
|
|
this.http
|
|
this.http
|
|
- .post(`https://server.fmode.cn/api/yuanke/reset_password`, {
|
|
|
|
|
|
+ .post(`https://server.fmode.cn/api/reset_password`, {
|
|
company: this.company,
|
|
company: this.company,
|
|
code: this.reset.code,
|
|
code: this.reset.code,
|
|
mobile: this.reset.mobile,
|
|
mobile: this.reset.mobile,
|
|
@@ -400,20 +380,11 @@ export class LoginComponent implements OnInit {
|
|
return await modal.present();
|
|
return await modal.present();
|
|
}
|
|
}
|
|
async registerUser() {
|
|
async registerUser() {
|
|
- if (this.registerInfo.mobile == undefined) {
|
|
|
|
- const toast = await this.toastController.create({
|
|
|
|
- message: "请输入手机号",
|
|
|
|
- color: "primary",
|
|
|
|
- duration: 1000,
|
|
|
|
- });
|
|
|
|
- toast.present();
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
let a = /^1[3456789]\d{9}$/;
|
|
let a = /^1[3456789]\d{9}$/;
|
|
- if (!String(this.registerInfo.mobile).match(a)) {
|
|
|
|
|
|
+ if (this.registerInfo.mobile == undefined || !String(this.registerInfo.mobile).match(a)) {
|
|
const toast = await this.toastController.create({
|
|
const toast = await this.toastController.create({
|
|
- message: "请填写正确手机号",
|
|
|
|
- color: "danger",
|
|
|
|
|
|
+ message: "请填写正确的手机号",
|
|
|
|
+ color: "primary",
|
|
duration: 1000,
|
|
duration: 1000,
|
|
});
|
|
});
|
|
toast.present();
|
|
toast.present();
|
|
@@ -437,18 +408,9 @@ export class LoginComponent implements OnInit {
|
|
toast.present();
|
|
toast.present();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (this.registerInfo.password.length < 6) {
|
|
|
|
|
|
+ if (this.registerInfo.password.length < 6 || this.registerInfo.password.length.length > 20) {
|
|
const toast = await this.toastController.create({
|
|
const toast = await this.toastController.create({
|
|
- message: "密码长度不得小于6位",
|
|
|
|
- color: "danger",
|
|
|
|
- duration: 1000,
|
|
|
|
- });
|
|
|
|
- toast.present();
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if (this.registerInfo.password.length.length > 18) {
|
|
|
|
- const toast = await this.toastController.create({
|
|
|
|
- message: "密码长度不得大于20位",
|
|
|
|
|
|
+ message: "密码长度不得小于6位或大于20位",
|
|
color: "danger",
|
|
color: "danger",
|
|
duration: 1000,
|
|
duration: 1000,
|
|
});
|
|
});
|
|
@@ -464,7 +426,7 @@ export class LoginComponent implements OnInit {
|
|
toast.present();
|
|
toast.present();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (this.registerInfo.confirmPassword < 6 || this.registerInfo.password.trim() != this.registerInfo.confirmPassword.trim()) {
|
|
|
|
|
|
+ if (this.registerInfo.password.trim() != this.registerInfo.confirmPassword.trim()) {
|
|
const toast = await this.toastController.create({
|
|
const toast = await this.toastController.create({
|
|
message: "两次输入密码不一致",
|
|
message: "两次输入密码不一致",
|
|
color: "danger",
|
|
color: "danger",
|
|
@@ -494,7 +456,6 @@ export class LoginComponent implements OnInit {
|
|
}
|
|
}
|
|
]
|
|
]
|
|
});
|
|
});
|
|
-
|
|
|
|
await alert.present();
|
|
await alert.present();
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -513,7 +474,7 @@ export class LoginComponent implements OnInit {
|
|
password: this.registerInfo.password
|
|
password: this.registerInfo.password
|
|
}
|
|
}
|
|
this.http
|
|
this.http
|
|
- .post(`https://server.fmode.cn/api/yuanke/register`, data).pipe(
|
|
|
|
|
|
+ .post(`https://server.fmode.cn/api/register`, data).pipe(
|
|
catchError(async (e) => { // 显示报错
|
|
catchError(async (e) => { // 显示报错
|
|
const toast = await this.toastController.create({
|
|
const toast = await this.toastController.create({
|
|
message: e.message,
|
|
message: e.message,
|