Prechádzať zdrojové kódy

created totas component

warrior 4 mesiacov pred
rodič
commit
61af6edd3d

+ 7 - 0
projects/live-app/src/app/components/totas/totas.component.html

@@ -0,0 +1,7 @@
+<ion-toast
+  [class]="type"
+  [isOpen]="isToastOpen"
+  [message]="message"
+  [duration]="1500"
+  (didDismiss)="closeTotas()"
+></ion-toast>

+ 16 - 0
projects/live-app/src/app/components/totas/totas.component.scss

@@ -0,0 +1,16 @@
+.warning {
+  --background: #ffc409;
+  --color: #fff;
+}
+.success{
+  --background: #2dd55b;
+  --color: #fff;
+}
+.danger{
+  --background: #c5000f;
+  --color: #fff;
+}
+.tertiary{
+  --background: #6030ff;
+  --color: #fff;
+}

+ 28 - 0
projects/live-app/src/app/components/totas/totas.component.spec.ts

@@ -0,0 +1,28 @@
+/* tslint:disable:no-unused-variable */
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { By } from '@angular/platform-browser';
+import { DebugElement } from '@angular/core';
+
+import { TotasComponent } from './totas.component';
+
+describe('TotasComponent', () => {
+  let component: TotasComponent;
+  let fixture: ComponentFixture<TotasComponent>;
+
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [ TotasComponent ]
+    })
+    .compileComponents();
+  }));
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(TotasComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 34 - 0
projects/live-app/src/app/components/totas/totas.component.ts

@@ -0,0 +1,34 @@
+import { Component, Input, OnInit } from '@angular/core';
+import { IonicModule } from '@ionic/angular';
+
+@Component({
+  standalone: true,
+  imports: [IonicModule],
+  selector: 'app-totas',
+  templateUrl: './totas.component.html',
+  styleUrls: ['./totas.component.scss']
+})
+export class TotasComponent implements OnInit {
+  isToastOpen:boolean = false
+
+  @Input('type') type:string = 'undefined' //通知类型
+  @Input('message') message:string = '暂无通知'//通知内容
+  @Input('duration') duration:number = 1500//通知内容
+  
+  openTotas(message:string,type?:string,duration?:number){
+    this.message = message
+    this.type = type || 'undefined'
+    this.duration = duration || 1500
+    this.isToastOpen = false
+    this.isToastOpen = true
+  }
+  closeTotas(){
+    this.isToastOpen = false
+    this.message = ''
+  }
+  constructor() { }
+
+  ngOnInit() {
+  }
+
+}

+ 1 - 0
projects/live-app/src/moduls/login/login.component.html

@@ -1,3 +1,4 @@
+<app-totas></app-totas>
 <!-- 登录 -->
 <ion-content fullscreen scroll-y="false" *ngIf="status == 'login'">
   <div class="container">

+ 154 - 159
projects/live-app/src/moduls/login/login.component.scss

@@ -2,191 +2,186 @@ ion-header {
   background-color: transparent;
 
   ion-toolbar {
-      --border-style: none;
+    --border-style: none;
   }
 }
-.toast-warning{
-    background:#0113C2;
-}
 ion-content {
   // --padding-top: 0;
-  --background: #FFF;
+  --background: #fff;
   font-family: Source Han Sans CN;
-  --keyboard-offset:0vw;
+  --keyboard-offset: 0vw;
   position: relative;
-  .header{
-      position: absolute;
-      top: 0;
-      left: 0;
+  .header {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100%;
+    height: 11.733vw;
+    background: transparent;
+    display: flex;
+    align-items: center;
+    padding-left: 1.333vw;
+    .title {
       width: 100%;
-      height: 11.733vw;
-      background: transparent;
       display: flex;
       align-items: center;
-      padding-left: 1.333vw;
-      .title{
-          width: 100%;
-          display: flex;
-          align-items: center;
-          justify-content: center;
-          font-size: 4.533vw;
-          font-weight: 600;
-          padding-right: 7.733vw;
-      }
+      justify-content: center;
+      font-size: 4.533vw;
+      font-weight: 600;
+      padding-right: 7.733vw;
+    }
   }
   .container {
-      width: 100%;
-      // height: 100%;
-      min-height: 100vh;
-      display: flex;
-      flex-direction: column;
-      align-items: center;
-      // justify-content: center;
-      // background-image: url('../../../../assets/img/miner-filecoin/login_meta.png');
-      background-size: 100% 100%;
-      background-repeat: no-repeat;
-      // background-size: cover;
-
-      .logo {
-          margin: 21.333vw auto 13.333vw auto;
-          text-align: center;
+    width: 100%;
+    // height: 100%;
+    min-height: 100vh;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    // justify-content: center;
+    // background-image: url('../../../../assets/img/miner-filecoin/login_meta.png');
+    background-size: 100% 100%;
+    background-repeat: no-repeat;
+    // background-size: cover;
 
-          img {
-              width: 21.333vw;
-              height: 21.333vw;
-          }
+    .logo {
+      margin: 21.333vw auto 13.333vw auto;
+      text-align: center;
 
+      img {
+        width: 21.333vw;
+        height: 21.333vw;
       }
+    }
 
-      .input {
-          width: 84vw;
-          height: 10.667vw;
-          background: #f2f1f6;
-          opacity: 0.8;
-          border-radius: 3.2vw;
-          border-bottom: 0.133vw solid #eee;
-          margin-bottom: 5.333vw;
-          display: flex;
-          align-items: center;
+    .input {
+      width: 84vw;
+      height: 10.667vw;
+      background: #f2f1f6;
+      opacity: 0.8;
+      border-radius: 3.2vw;
+      border-bottom: 0.133vw solid #eee;
+      margin-bottom: 5.333vw;
+      display: flex;
+      align-items: center;
 
-          .icon {
-              width: 4.8vw;
-              height: 4.8vw;
-              margin: 0 2.667vw;
+      .icon {
+        width: 4.8vw;
+        height: 4.8vw;
+        margin: 0 2.667vw;
 
-              img {
-                  width: 100%;
-                  height: 100%;
-              }
-          }
-          .watch{
-              width: 5.333vw;
-              height: 4vw;
-              margin: 0 2.667vw;
-              img{
-                  width: 100%;
-                  height: 100%;
-              }
-          }
-          .captcha {
-              // width: 18.133vw;
-              height: 6.4vw;
-              border: 0.133vw solid #0113C2;
-              border-radius: 1.067vw;
-              font-size: 3.2vw;
-              font-weight: 400;
-              color: #241AFF;
-              display: flex;
-              align-items: center;
-              justify-content: center;
-              margin-right: 2.667vw;
-          }
+        img {
+          width: 100%;
+          height: 100%;
+        }
       }
-
-      .submit {
-          width: 84vw;
-          height: 10.667vw;
-          background: #0054e9;
-          border-radius: 3.2vw;
-          font-size: 4.8vw;
-          font-weight: bold;
-          color: #FFFFFF;
-          display: flex;
-          align-items: center;
-          justify-content: center;
-          letter-spacing: 1.333vw;
-          margin-top: 10.667vw;
+      .watch {
+        width: 5.333vw;
+        height: 4vw;
+        margin: 0 2.667vw;
+        img {
+          width: 100%;
+          height: 100%;
+        }
+      }
+      .captcha {
+        // width: 18.133vw;
+        height: 6.4vw;
+        border: 0.133vw solid #0113c2;
+        border-radius: 1.067vw;
+        font-size: 3.2vw;
+        font-weight: 400;
+        color: #241aff;
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        margin-right: 2.667vw;
       }
+    }
 
-      .opts {
-          width: 84vw;
-          height: 8vw;
-          display: flex;
-          align-items: center;
-          justify-content: space-between;
-          margin-top: 4vw;
-          .code {
-              font-size: 3.2vw;
-              font-weight: 400;
-              // color: #FFFFFF;
-          }
+    .submit {
+      width: 84vw;
+      height: 10.667vw;
+      background: #0054e9;
+      border-radius: 3.2vw;
+      font-size: 4.8vw;
+      font-weight: bold;
+      color: #ffffff;
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      letter-spacing: 1.333vw;
+      margin-top: 10.667vw;
+    }
 
-          .forget {
-              font-size: 3.2vw;
-              font-weight: 400;
-              // color: #BBBBBB;
-          }
+    .opts {
+      width: 84vw;
+      height: 8vw;
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+      margin-top: 4vw;
+      .code {
+        font-size: 3.2vw;
+        font-weight: 400;
+        // color: #FFFFFF;
       }
 
-      .register {
-          width: 84vw;
-          height: 8vw;
-          display: flex;
-          align-items: center;
-          justify-content: center;
-          font-size: 3.2vw;
-          font-weight: 400;
-          // color: #FFFFFE;
-          margin-top: 8vw;
+      .forget {
+        font-size: 3.2vw;
+        font-weight: 400;
+        // color: #BBBBBB;
+      }
+    }
+
+    .register {
+      width: 84vw;
+      height: 8vw;
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      font-size: 3.2vw;
+      font-weight: 400;
+      // color: #FFFFFE;
+      margin-top: 8vw;
 
-          .icon{
-              width: 32px;
-              height: 32px;
-              transform: scale(.5);
-              margin-left: 1.333vw;
-              img{
-                  width: 100%;
-                  height: 100%;
-              }
-          }
+      .icon {
+        width: 32px;
+        height: 32px;
+        transform: scale(0.5);
+        margin-left: 1.333vw;
+        img {
+          width: 100%;
+          height: 100%;
+        }
+      }
+    }
+    .agreement {
+      width: 84vw;
+      height: 13.333vw;
+      display: flex;
+      align-items: flex-start;
+      justify-content: center;
+      font-size: 4vw;
+      font-weight: 400;
+      color: #9f9f9f;
+      margin-top: 6.667vw;
+      margin-bottom: 6.667vw;
+      span {
+        color: #3f51b5;
       }
-      .agreement{
-          width: 84vw;
-          height: 13.333vw;
-          display: flex;
-          align-items: flex-start;
-          justify-content: center;
-          font-size: 4vw;
-          font-weight: 400;
-          color: #9f9f9f;
-          margin-top: 6.667vw;
-          margin-bottom: 6.667vw;
-          span{
-              color: #3f51b5;
-          }
-          .content{
-              margin-left: 2.667vw;
-              width: 90%;
-          }
-          ion-checkbox{
-              --background:#108ee9;
-              --border-color:#fff;
-              --border-color-checked:#fff;
-              --background-checked:#108ee9;
-          }
+      .content {
+        margin-left: 2.667vw;
+        width: 90%;
       }
+      ion-checkbox {
+        --background: #108ee9;
+        --border-color: #fff;
+        --border-color-checked: #fff;
+        --background-checked: #108ee9;
+      }
+    }
   }
-
 }
 input:-webkit-autofill,
 input:-webkit-autofill:hover,
@@ -194,4 +189,4 @@ input:-webkit-autofill:focus,
 input:-webkit-autofill:active {
   -webkit-transition-delay: 99999s;
   -webkit-transition: color 99999s ease-out, background-color 99999s ease-out;
-}
+}

+ 34 - 73
projects/live-app/src/moduls/login/login.component.ts

@@ -1,4 +1,4 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, OnInit, ViewChild } from '@angular/core';
 import { LoginModule } from './login.module';
 import { AuthService } from "../../services/auth.service";
 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 { catchError } from "rxjs/operators";
 import { AgreementComponent } from "./agreement/agreement.component"
+import { TotasComponent } from '../../app/components/totas/totas.component';
 @Component({
   standalone: true,
-  imports: [LoginModule,AgreementComponent],
+  imports: [LoginModule,AgreementComponent,TotasComponent],
   selector: 'app-login',
   templateUrl: './login.component.html',
   styleUrls: ['./login.component.scss']
 })
 export class LoginComponent implements OnInit {
+  @ViewChild(TotasComponent) totas: TotasComponent | undefined;
   user: { username?: string; password?: string } = {
     username: "",
     password: "",
@@ -29,7 +31,9 @@ export class LoginComponent implements OnInit {
     private modalController: ModalController,
     private alertController: AlertController
   ) {
+    this.company = authServ.company
   }
+  
   company: any;
   appName: any;
   logo: any;
@@ -112,7 +116,6 @@ export class LoginComponent implements OnInit {
 
 
   //   获取验证码
-  // 
   vcode: string = ''
   mobile: string = ''
   loginToken: string = ""
@@ -136,6 +139,23 @@ export class LoginComponent implements OnInit {
       toast.present();
       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
       .post("https://server.fmode.cn/api/apig/message", {
         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() {
     let type = this.type
     if (type == 'password') {
@@ -249,7 +241,6 @@ export class LoginComponent implements OnInit {
     }
   }
   // 忘记密码部分逻辑
-
   back() {
     this.status = 'login'
   }
@@ -298,20 +289,9 @@ export class LoginComponent implements OnInit {
       toast.present();
       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({
-        message: "密码长度不得大于20位",
+        message: "密码长度不得小于6位或大于20位",
         color: "danger",
         duration: 1000,
       });
@@ -327,7 +307,7 @@ export class LoginComponent implements OnInit {
       toast.present();
       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({
         message: "两次输入密码不一致",
         color: "danger",
@@ -340,7 +320,7 @@ export class LoginComponent implements OnInit {
     headers.append("Content-Type", "application/json");
     headers.set('Access-Control-Allow-Origin', '*')
     this.http
-      .post(`https://server.fmode.cn/api/yuanke/reset_password`, {
+      .post(`https://server.fmode.cn/api/reset_password`, {
         company: this.company,
         code: this.reset.code,
         mobile: this.reset.mobile,
@@ -400,20 +380,11 @@ export class LoginComponent implements OnInit {
     return await modal.present();
   }
   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}$/;
-    if (!String(this.registerInfo.mobile).match(a)) {
+    if (this.registerInfo.mobile == undefined || !String(this.registerInfo.mobile).match(a)) {
       const toast = await this.toastController.create({
-        message: "请填写正确手机号",
-        color: "danger",
+        message: "请填写正确的手机号",
+        color: "primary",
         duration: 1000,
       });
       toast.present();
@@ -437,18 +408,9 @@ export class LoginComponent implements OnInit {
       toast.present();
       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({
-        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",
         duration: 1000,
       });
@@ -464,7 +426,7 @@ export class LoginComponent implements OnInit {
       toast.present();
       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({
         message: "两次输入密码不一致",
         color: "danger",
@@ -494,7 +456,6 @@ export class LoginComponent implements OnInit {
           }
         ]
       });
-
       await alert.present();
       return
     }
@@ -513,7 +474,7 @@ export class LoginComponent implements OnInit {
         password: this.registerInfo.password
       }
     this.http
-      .post(`https://server.fmode.cn/api/yuanke/register`, data).pipe(
+      .post(`https://server.fmode.cn/api/register`, data).pipe(
         catchError(async (e) => { // 显示报错
           const toast = await this.toastController.create({
             message: e.message,

+ 4 - 7
projects/live-app/src/services/auth.service.ts

@@ -47,7 +47,7 @@ export class AuthService {
         })
         .catch((err) => {
           console.error(err.message);
-          reject(err);
+          reject(err.message);
         });
     });
   }
@@ -56,13 +56,10 @@ export class AuthService {
     localStorage.clear(); // 清楚过期登录状态,重新登陆
     window.location.search = `c=${cid}`; // TODOLIST 此处需要通过循环清楚CODE,STATE等微信后缀,重新拼接用户的QueryParams
   }
-  logout(type?: string): void {
-    if (type == 'notSession') {
-      this.router.navigate(['nova-yuanke/login']);
-    }
-    this.redirectUrl = 'home';
+  logout(): void {
+    localStorage.clear(); // 清楚过期登录状态,重新登陆
     Parse.User.logOut().then((user) => {
-      this.router.navigate(['nova-yuanke/login']);
+      this.router.navigate(['login']);
     });
   }
 }

+ 0 - 8
projects/live-app/src/styles.scss

@@ -10,12 +10,4 @@ body{
   height: 100%;
   max-height: 100%;
   font-size: 16px;
-}
-:root {
-  --ion-color-secondary: #006600;
-  --ion-color-secondary-rgb: 0, 102, 0;
-  --ion-color-secondary-contrast: #ffffff;
-  --ion-color-secondary-contrast-rgb: 255, 255, 255;
-  --ion-color-secondary-shade: #005a00;
-  --ion-color-secondary-tint: #1a751a;
 }