Browse Source

Merge branch 'master' of http://git.fmode.cn:3000/bin/edu-textbook

MetaPunkGames 8 months ago
parent
commit
2e01d37bed
22 changed files with 692 additions and 318 deletions
  1. 67 67
      projects/textbook/src/app/comp-manage/comp-manage.component.ts
  2. 4 4
      projects/textbook/src/app/comp-nav/comp-nav.component.html
  3. 1 1
      projects/textbook/src/app/comp-table/comp-table-list/comp-table-list.component.html
  4. 13 4
      projects/textbook/src/app/comp-table/comp-table-list/comp-table-list.component.ts
  5. 11 0
      projects/textbook/src/app/comp-upload/comp-upload.component.html
  6. 0 0
      projects/textbook/src/app/comp-upload/comp-upload.component.scss
  7. 24 0
      projects/textbook/src/app/comp-upload/comp-upload.component.spec.ts
  8. 48 0
      projects/textbook/src/app/comp-upload/comp-upload.component.ts
  9. 4 13
      projects/textbook/src/modules/login/account-info/account-info.component.html
  10. 76 72
      projects/textbook/src/modules/login/account-info/account-info.component.ts
  11. 4 2
      projects/textbook/src/modules/login/login/login.component.ts
  12. 1 0
      projects/textbook/src/modules/login/login/parse-authing.ts
  13. 3 2
      projects/textbook/src/modules/login/register/register.component.ts
  14. 1 1
      projects/textbook/src/modules/nav-admin/modules.routes.ts
  15. 1 1
      projects/textbook/src/modules/nav-admin/page-role/page-role.component.html
  16. 5 3
      projects/textbook/src/modules/nav-admin/page-role/page-role.component.ts
  17. 2 2
      projects/textbook/src/modules/nav-admin/page-user/page-user.component.html
  18. 109 25
      projects/textbook/src/modules/nav-admin/user-edit/user-edit.component.html
  19. 50 13
      projects/textbook/src/modules/nav-admin/user-edit/user-edit.component.ts
  20. 30 0
      projects/textbook/src/schemas/Department.ts
  21. 176 72
      projects/textbook/src/schemas/Profile-list.ts
  22. 62 36
      projects/textbook/src/services/auth.service.ts

+ 67 - 67
projects/textbook/src/app/comp-manage/comp-manage.component.ts

@@ -25,22 +25,22 @@ export class CompManageComponent implements OnInit {
   `
   optionsMap: any = {
     "国家级管理员":[
-      {
-        name:'教材管理',
-        id:'1',
-        child:[
-          {
-            name:'报送合集',
-            path:"/nav-admin/manage/collection",
-            id:'1-1',
-          },
-          {
-            name:'全部教材',
-            path:'/nav-admin/manage/allcollection',
-            id:'1-2',
-          },
-        ]
-      },
+      // {
+      //   name:'教材管理',
+      //   id:'1',
+      //   child:[
+      //     {
+      //       name:'报送合集',
+      //       path:"/nav-admin/manage/collection",
+      //       id:'1-1',
+      //     },
+      //     {
+      //       name:'全部教材',
+      //       path:'/nav-admin/manage/allcollection',
+      //       id:'1-2',
+      //     },
+      //   ]
+      // },
       {
         name:'用户管理',
         id:'2',
@@ -76,61 +76,61 @@ export class CompManageComponent implements OnInit {
       //   id:'4',
       // },
     ],
-    "省级教育行政部门":[
+    "报送联系人":[
       {
         name:'省内合集',
         id:'1',
       },
     ],
-    "合集管理员":[
-      {
-        name:'报送流程',
-        id:'1',
-      },
-      {
-        name:'用户管理',
-        id:'2',
-        child:[
-          {
-            name:'用户列表',
-            id:'2-1',
-          },
-          {
-            name:'用户组管理',
-            id:'2-2',
-          },
-          {
-            name:'邀请注册',
-            id:'2-3',
-          },
-        ]
-      }
-    ],
-    "省属高校联系人":[
-      {
-        name:'校内空间',
-        id:'1',
-      },
-      {
-        name:'用户管理',
-        id:'2',
-        child:[
-          {
-            name:'邀请注册',
-            id:'2-1',
-          },
-          {
-            name:'用户列表',
-            id:'2-2',
-          },
-        ]
-      },
-      {
-        name:'个人信息',
-        id:'3',
-      },
-    ],
-    "教材评审组成员":[
+    // "合集管理员":[
+    //   {
+    //     name:'报送流程',
+    //     id:'1',
+    //   },
+    //   {
+    //     name:'用户管理',
+    //     id:'2',
+    //     child:[
+    //       {
+    //         name:'用户列表',
+    //         id:'2-1',
+    //       },
+    //       {
+    //         name:'用户组管理',
+    //         id:'2-2',
+    //       },
+    //       {
+    //         name:'邀请注册',
+    //         id:'2-3',
+    //       },
+    //     ]
+    //   }
+    // ],
+    // "省属高校联系人":[
+    //   {
+    //     name:'校内空间',
+    //     id:'1',
+    //   },
+    //   {
+    //     name:'用户管理',
+    //     id:'2',
+    //     child:[
+    //       {
+    //         name:'邀请注册',
+    //         id:'2-1',
+    //       },
+    //       {
+    //         name:'用户列表',
+    //         id:'2-2',
+    //       },
+    //     ]
+    //   },
+    //   {
+    //     name:'个人信息',
+    //     id:'3',
+    //   },
+    // ],
+    "评审专家":[
       {
         name:'报送流程',
         id:'1',
@@ -142,7 +142,7 @@ export class CompManageComponent implements OnInit {
         path: '/nav-review/profile',
       },
     ],
-    "作者/教师/主编":[
+    "个人":[
       {
         name: '个人空间',
         id: '1',

+ 4 - 4
projects/textbook/src/app/comp-nav/comp-nav.component.html

@@ -6,8 +6,8 @@
   ></nz-avatar>
   @if(!viewCollapsed){
   <div class="user">
-    <div class="name">{{ tbookSer.profile?.name || "未认证用户" }}</div>
-    <div class="email">{{ tbookSer.profile?.email || "test@edu.com" }}</div>
+    <div class="name">{{ tbookSer.profile?.user?.name || "未认证用户" }}</div>
+    <div class="email">{{ tbookSer.profile?.user?.email || "test@edu.com" }}</div>
   </div>
   <div class="more">
     <button
@@ -24,13 +24,13 @@
     </button>
     <ng-template #contentTemplate>
       <div style="display: flex; flex-direction: column">
-        <a
+        <!-- <a
           nz-button
           nzType="link"
           (click)="clickMe()"
           style="margin-bottom: 6px;color:#3e49b3;"
           >我的</a
-        >
+        > -->
         <a nz-button nzType="link" style="color:#3e49b3" (click)="authServr.logout()">退出登录</a>
       </div>
     </ng-template>

+ 1 - 1
projects/textbook/src/app/comp-table/comp-table-list/comp-table-list.component.html

@@ -43,7 +43,7 @@
             <td > 
               <ng-contianer [ngSwitch]="field?.type">
                 <ng-container *ngSwitchCase="'Pointer'">
-                  {{ pointerShowMap?.[object?.get(field.key)?.objectId||object?.get(field.key)?.id] || "-" }}
+                  {{ pointerShowMap?.[(object?.get(field.key)?.objectId||object?.get(field.key)?.id)+field?.showName] || "-" }}
                   <!-- 设备: cluster 单元切换 -->
                   <!-- <comp-select-cluster *ngIf="field?.className=='MinerCluster' && object?.className!='MinerCluster'" [device]="object" [unit]="object?.get(field.key)"></comp-select-cluster> -->
                 </ng-container>

+ 13 - 4
projects/textbook/src/app/comp-table/comp-table-list/comp-table-list.component.ts

@@ -1,4 +1,4 @@
-import { Component, Input,Output,EventEmitter } from '@angular/core';
+import { Component, Input,Output,EventEmitter, ChangeDetectorRef } from '@angular/core';
 import { MatDialog } from '@angular/material/dialog';
 import Parse from "parse";
 // import { ClusterService } from '../cluster.service';
@@ -22,11 +22,13 @@ import { NzPageHeaderModule } from 'ng-zorro-antd/page-header';
 import { NzBreadCrumbModule } from 'ng-zorro-antd/breadcrumb';
 import { NzTagModule } from 'ng-zorro-antd/tag';
 import { Router } from '@angular/router';
+import { ChangeDetectionStrategy } from '@angular/compiler';
 
 interface SchemaFiled{
   key:string,
   name:string,
   type:string,
+  showName?:string,
   require?:boolean, // 是否必填
   isHeader?:boolean, // 是否表头显示 
 }
@@ -70,7 +72,8 @@ export class CompTableListComponent {
     private dialog:MatDialog,
     private router:Router,
     // public translate:TranslateService
-    private modal: NzModalService
+    private modal: NzModalService,
+    private cdRef:ChangeDetectorRef
   ){
     this.currentLang = "cn"// this.translate.getDefaultLang();
   }
@@ -156,8 +159,14 @@ export class CompTableListComponent {
     await this.parseData.cachePointerList(Object.values(this.pointerMap))
     Object.keys(this.pointerMap).forEach(async id=>{
       let obj = this.parseData.ParseObjectCacheMap[id]
-      let field = this.fieldsArray?.find(item=>item?.targetClass==obj?.className)
-      this.pointerShowMap[id] = await this.parseData.showNameByObj(obj,field?.showName)
+      let fieldList = this.fieldsArray?.filter(item=>item?.targetClass==obj?.className)
+      fieldList?.forEach(async field=>{
+        this.pointerShowMap[id+field?.showName] = await this.parseData.showNameByObj(obj,field?.showName)
+        // console.log(id+field?.showName)
+        // console.log(this.pointerShowMap[id+field?.showName] )
+        // console.log(this.pointerShowMap )
+        // this.cdRef.detectChanges()
+      })
     })
   }
   pointerMap:any = {}

+ 11 - 0
projects/textbook/src/app/comp-upload/comp-upload.component.html

@@ -0,0 +1,11 @@
+<nz-upload
+  nzAction="https://www.mocky.io/v2/5cc8019d300000980a055e76"
+  [nzHeaders]="{ authorization: 'authorization-text' }"
+  (nzChange)="handleChange($event)"
+  [nzFileList]="fileList"
+  [nzAccept]="'file'"
+>
+  <div style="color: #3e49b3;cursor: pointer;">
+    <span nz-icon nzType="upload"></span>{{title}}
+  </div>
+</nz-upload>

+ 0 - 0
projects/textbook/src/app/comp-upload/comp-upload.component.scss


+ 24 - 0
projects/textbook/src/app/comp-upload/comp-upload.component.spec.ts

@@ -0,0 +1,24 @@
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
+import { IonicModule } from '@ionic/angular';
+
+import { CompUploadComponent } from './comp-upload.component';
+
+describe('CompUploadComponent', () => {
+  let component: CompUploadComponent;
+  let fixture: ComponentFixture<CompUploadComponent>;
+
+  beforeEach(waitForAsync(() => {
+    TestBed.configureTestingModule({
+      declarations: [ CompUploadComponent ],
+      imports: [IonicModule.forRoot()]
+    }).compileComponents();
+
+    fixture = TestBed.createComponent(CompUploadComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  }));
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 48 - 0
projects/textbook/src/app/comp-upload/comp-upload.component.ts

@@ -0,0 +1,48 @@
+import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
+import { NzUploadModule } from 'ng-zorro-antd/upload';
+import { CommonCompModule } from '../../services/common.modules';
+import { NzMessageService } from 'ng-zorro-antd/message';
+import { NzUploadChangeParam, NzUploadFile } from 'ng-zorro-antd/upload';
+@Component({
+  selector: 'app-comp-upload',
+  standalone: true,
+  imports: [NzUploadModule, CommonCompModule],
+  templateUrl: './comp-upload.component.html',
+  styleUrls: ['./comp-upload.component.scss'],
+})
+export class CompUploadComponent implements OnInit {
+  @Input('title') title:string = '上传文件'
+  @Input('files') files:Array<any> = []
+  @Output() change: EventEmitter<any> = new EventEmitter<any>();
+
+  fileList:any = [
+    // {
+    //   uid: '1',
+    //   name: 'xxx.png',
+    //   status: 'done',
+    //   response: 'Server Error 500', 
+    //   url: 'http://www.baidu.com/xxx.png'
+    // },
+  ];
+  constructor(private msg: NzMessageService) {}
+
+  ngOnInit() {
+    this.fileList = this.files.map((item:any)=> {
+      return {
+        url: item
+      }
+    })
+  }
+  handleChange(info: NzUploadChangeParam): void {
+    console.log(info);
+    if (info.file.status !== 'uploading') {
+      console.log(info.file, info.fileList);
+    }
+    if (info.file.status === 'done') {
+      this.msg.success(`${info.file.name} file uploaded successfully`);
+    } else if (info.file.status === 'error') {
+      this.msg.error(`${info.file.name} file upload failed.`);
+    }
+    this.change.emit(info.fileList)
+  }
+}

+ 4 - 13
projects/textbook/src/modules/login/account-info/account-info.component.html

@@ -59,8 +59,9 @@
             nz-input
             type="text"
             formControlName="phone"
-            [disabled]="user?.get('phone')"
+            [disabled]="true"
             placeholder="请填写手机号"
+            maxlength="11"
           />
         </nz-input-group> </nz-form-item
       ><nz-form-item>
@@ -117,7 +118,6 @@
             nzAllowClear
             nzPlaceHolder="请选择单位类型"
             formControlName="companyType"
-            (ngModelChange)="provinceChange()"
           >
             @for(item of unitTypes; track item;let index = $index){
             <nz-option nzCustomContent [nzValue]="item" [nzLabel]="item">{{
@@ -138,7 +138,7 @@
             nzAllowClear
             nzPlaceHolder="请选择单位名称"
             formControlName="companyName"
-            (ngModelChange)="provinceChange()"
+            (nzOnSearch)="provinceChange($event)"
           >
             @for(item of companys; track item;let index = $index){
             <nz-option nzCustomContent [nzValue]="item" [nzLabel]="item">{{
@@ -188,16 +188,7 @@
           >单位联系人认证文件</nz-form-label
         >
         <nz-input-group>
-          <nz-upload
-            formControlName="file"
-            nzAction="https://www.mocky.io/v2/5cc8019d300000980a055e76"
-            [nzHeaders]="{ authorization: 'authorization-text' }"
-            (nzChange)="handleChange($event)"
-          >
-            <div style="color: #3e49b3">
-              <span nz-icon nzType="upload"></span>上传认证文件
-            </div>
-          </nz-upload>
+          <app-comp-upload (change)="upload($event)" title="上传认证文件"></app-comp-upload>
           <div class="text" style="margin: 10px 0; color: #231c1f99">
             请下载单位联系人认证<a href="">文件模板</a
             >,填写盖章后上传。支持上传 PDF、JPG、JPEG、PNG

+ 76 - 72
projects/textbook/src/modules/login/account-info/account-info.component.ts

@@ -3,7 +3,6 @@ import { ReactiveFormsModule } from '@angular/forms';
 import { HttpClient } from '@angular/common/http';
 import { Router } from '@angular/router';
 import { catchError } from 'rxjs/operators';
-import { NzUploadChangeParam } from 'ng-zorro-antd/upload';
 import { NzUploadModule } from 'ng-zorro-antd/upload';
 import { NzModalModule } from 'ng-zorro-antd/modal';
 import { NzModalService } from 'ng-zorro-antd/modal';
@@ -19,6 +18,7 @@ import { AuthServr } from '../../../services/auth.service';
 import { CaptchaComponent } from '../../../app/captcha/captcha.component';
 import { NzMessageService } from 'ng-zorro-antd/message';
 import { provinces } from '../../../services/provinces';
+import { CompUploadComponent } from '../../../app/comp-upload/comp-upload.component';
 import Parse from 'parse';
 @Component({
   selector: 'app-account-info',
@@ -27,13 +27,15 @@ import Parse from 'parse';
     ReactiveFormsModule,
     CommonCompModule,
     CaptchaComponent,
-    NzUploadModule,NzModalModule
+    NzUploadModule,
+    NzModalModule,
+    CompUploadComponent,
   ],
   templateUrl: './account-info.component.html',
   styleUrls: ['./account-info.component.scss'],
 })
 export class AccountInfoComponent implements OnInit {
-  user: Parse.Object|undefined
+  user: Parse.Object | undefined;
   validateForm: FormGroup<{
     name: FormControl<string>; //姓名
     phone: FormControl<string>; //手机号
@@ -43,8 +45,8 @@ export class AccountInfoComponent implements OnInit {
     companyType: FormControl<string>; //单位类型
     companyName: FormControl<string>; //单位名称
     // idcard: FormControl<string>; //身份证号
-    departmentName:FormControl<string>; //所在部门
-    postName:FormControl<string>; //职务
+    departmentName: FormControl<string>; //所在部门
+    postName: FormControl<string>; //职务
     identityFile: FormControl<string>; //单位联系人认证文件
   }> = this.fb.group({
     name: ['', [Validators.required]],
@@ -64,13 +66,12 @@ export class AccountInfoComponent implements OnInit {
   };
 
   //省份
-  provinces: Array<string> = provinces.options
+  provinces: Array<string> = provinces.options;
   unitTypes: Array<string> = [
+    '全国出版单位',
     '教育部直属高校',
-    '中央有关部门(单位)',
-    '教育司(局)',
+    '中央有关部门教育司',
     '省级教育行政部门',
-    '出版单位',
   ];
   companys: Array<string> = [];
   constructor(
@@ -83,54 +84,61 @@ export class AccountInfoComponent implements OnInit {
     private http: HttpClient
   ) {}
 
-  ngOnInit() {
-    let user = Parse.User.current()
+  async ngOnInit() {
+    let user = Parse.User.current();
     if(!user?.id) history.back()
-    this.user = user
-    this.validateForm.value.phone = user?.get('phone')
-    this.validateForm.value.email = user?.get('email')
-    if(user?.get('accountState') == '已认证'){
-      this.message.success('账号已认证,无需重复认证')
-      this.authServr.profileVerify()
-      return
-    }else if(user?.get('accountState') == '已禁用'){
-      this.message.success('账号已禁用')
-      this.router.navigate(['/user/register'],{ replaceUrl: true })
-      return
+    this.user = user;
+    if (user?.get('accountState') == '已认证') {
+      this.message.success('账号已认证,无需重复认证');
+      this.authServr.profileVerify(this.modal);
+      return;
+    } else if (user?.get('accountState') == '已禁用') {
+      this.message.success('账号已禁用');
+      this.router.navigate(['/user/register'], { replaceUrl: true });
+      return;
     }
+    let queryProfile = new Parse.Query('Profile')
+    queryProfile.equalTo('user',user?.id)
+    let profile = await queryProfile.first()
+    this.validateForm = this.fb.group({
+      name: [user?.get('name') || '', [Validators.required]],
+      phone: [user?.get('phone') || ''],
+      email: [user?.get('email') || '', [Validators.required]],
+      telephone: [profile?.get('telephone') || ''],
+      province: [user?.get('province') || ''],
+      companyType: [profile?.get('companyType') || '', [Validators.required]],
+      companyName: [user?.get('companyName') || '', [Validators.required]],
+      departmentName: [user?.get('departmentName') || ''],
+      postName: [profile?.get('postName') || ''],
+      identityFile: [profile?.get('identityFile') || ''],
+    });
   }
   //根据所选单位类型获取对应单位
-  async provinceChange(val?:string){
-    this.companys = []
+  async provinceChange(val?: string) {
     console.log(this.validateForm.value.companyType);
-    let query = new Parse.Query('Department')
-    query.equalTo('branch',this.validateForm.value.companyType)
-    val && query.contains('name',val)
-    let r = await query.find()
-    if(r.length > 0){
-      this.companys = r.map((item:Parse.Object)=> item.get('name'))
+    console.log(val);
+    this.companys = [];
+    let query = new Parse.Query('Department');
+    query.equalTo('branch', this.validateForm.value.companyType);
+    query.select('name','branch');
+    query.limit(1000);
+    val && query.contains('name', val);
+    let r = await query.find();
+    if (r.length > 0) {
+      this.companys = r.map((item: Parse.Object) => item.get('name'));
     }
   }
   submitForm(): void {
     console.log(this.validateForm.value);
     if (this.validateForm.valid) {
-      // let {
-      //   idcard,
-      // } = this.validateForm.value;
-      // let a =
-      //   /^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/;
-      // if (!String(idcard).match(a)) {
-      //   this.message.error('身份证格式错误');
-      //   return;
-      // }
-      let a = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
-       if (!String(this.validateForm.value.email).match(a)) {
+      let a =
+        /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+      if (!String(this.validateForm.value.email).match(a)) {
         this.message.error('邮箱格式不正确');
         return;
       }
-      let params = this.validateForm.value
+      let params = this.validateForm.value;
       this.profileSave(params);
-      
     } else {
       this.message.warning('请填写完整的信息');
       Object.values(this.validateForm.controls).forEach((control) => {
@@ -145,11 +153,12 @@ export class AccountInfoComponent implements OnInit {
   async profileSave(params: any) {
     this.user?.set('name', params.name);
     this.user?.set('email', params.email);
-    this.user?.set('phone', params.email);
+    this.user?.set('phone', params.phone);
     this.user?.set('province', params.province);
     this.user?.set('companyName', params.companyName);
+    !this.user?.get('accountState') && this.user?.set('accountState', '待认证');
     this.user?.set('departmentName', params.departmentName);
-    await this.user?.save()
+    await this.user?.save();
 
     console.log(params);
     let query = new Parse.Query('Profile');
@@ -176,38 +185,33 @@ export class AccountInfoComponent implements OnInit {
     this.modal.success({
       nzTitle: '提交成功',
       nzContent: '',
-      nzOnOk: () => this.router.navigate(['/user/register'],{replaceUrl:true}),
+      nzOnOk: () =>
+        this.router.navigate(['/user/login'], { replaceUrl: true }),
     });
   }
+  upload(e:any){
+    console.log(e);
+    let file = e[0]
+    this.validateForm.value.identityFile = file
+  }
   //验证手机号或邮箱是否注册
-  async authUser():Promise<boolean>{
-    let query = new Parse.Query('_User')
-    if(this.validateForm.value.phone){
-      query.equalTo('phone',this.validateForm.value.phone)
-      let r = await query.first()
-      if(r?.id){
-        this.message.warning('手机号已被注册')
-        return false
+  async authUser(): Promise<boolean> {
+    let query = new Parse.Query('_User');
+    if (this.validateForm.value.phone) {
+      query.equalTo('phone', this.validateForm.value.phone);
+      let r = await query.first();
+      if (r?.id) {
+        this.message.warning('手机号已被注册');
+        return false;
       }
-    }else if(this.validateForm.value.email){
-      query.equalTo('email',this.validateForm.value.email)
-      let r = await query.first()
-      if(r?.id){
-        this.message.warning('邮箱已被注册')
-        return false
+    } else if (this.validateForm.value.email) {
+      query.equalTo('email', this.validateForm.value.email);
+      let r = await query.first();
+      if (r?.id) {
+        this.message.warning('邮箱已被注册');
+        return false;
       }
     }
-    return true
-  }
-
-  handleChange(info: NzUploadChangeParam): void {
-    if (info.file.status !== 'uploading') {
-      console.log(info.file, info.fileList);
-    }
-    if (info.file.status === 'done') {
-      this.message.success(`${info.file.name} file uploaded successfully`);
-    } else if (info.file.status === 'error') {
-      this.message.error(`${info.file.name} file upload failed.`);
-    }
+    return true;
   }
 }

+ 4 - 2
projects/textbook/src/modules/login/login/login.component.ts

@@ -18,6 +18,7 @@ import { CaptchaComponent } from '../../../app/captcha/captcha.component';
 import Parse from "parse";
 import { NzMessageService } from 'ng-zorro-antd/message';
 import { ParseAuthing } from './parse-authing';
+import { NzModalService } from 'ng-zorro-antd/modal';
 
 @Component({
   selector: 'app-login',
@@ -34,8 +35,8 @@ export class LoginComponent implements OnInit{
     let parseAuthing = new ParseAuthing({
       // 监听事件:登陆成功后,返回用户信息
       login:(user,authClient)=>{
-        console.log(user,authClient)
-        this.authServr.profileVerify()
+        console.log(user,Parse.User.current())
+        this.authServr.profileVerify(this.modal)
       }
     });
     parseAuthing.initLoginModal();
@@ -82,6 +83,7 @@ export class LoginComponent implements OnInit{
     private authServr: AuthServr,
     private message: NzMessageService,
     private http: HttpClient,
+    private modal: NzModalService,
   ) {
     Parse?.User?.logOut()
   }

+ 1 - 0
projects/textbook/src/modules/login/login/parse-authing.ts

@@ -38,6 +38,7 @@ export class ParseAuthing{
             appId: '6682ab96b7bd5db59d6785a0',
             redirectUri:location.origin
         })
+        // this.authingGurad.changeView("register:username-password")
         // 使用 start 方法挂载 Guard 组件到你指定的 DOM 节点,登录成功后返回 userInfo
         this.authingGurad.start('#authing-guard-container').then((userInfo:any) => {
             // console.log('userInfo in start: ', userInfo)

+ 3 - 2
projects/textbook/src/modules/login/register/register.component.ts

@@ -18,6 +18,7 @@ import { CaptchaComponent } from '../../../app/captcha/captcha.component';
 import Parse from "parse";
 import { NzMessageService } from 'ng-zorro-antd/message';
 import { ParseAuthing } from './parse-authing';
+import { NzModalService } from 'ng-zorro-antd/modal';
 @Component({
   selector: 'app-register',
   standalone: true,
@@ -34,8 +35,7 @@ export class RegisterComponent implements OnInit{
       // 监听事件:登陆成功后,返回用户信息
       login:(user,authClient)=>{
         console.log(user,authClient)
-        // this.authServr.profileVerify()
-        this.router.navigate(['/user/account_info'])
+        this.authServr.profileVerify(this.modal)
       }
     });
     parseAuthing.initLoginModal();
@@ -82,6 +82,7 @@ export class RegisterComponent implements OnInit{
     private authServr: AuthServr,
     private message: NzMessageService,
     private http: HttpClient,
+    private modal: NzModalService,
   ) {
     Parse?.User?.logOut()
   }

+ 1 - 1
projects/textbook/src/modules/nav-admin/modules.routes.ts

@@ -11,7 +11,7 @@ import { UserEditComponent } from './user-edit/user-edit.component';
 const routes: Routes = [
   {
     path: '',
-    redirectTo:'manage/collection',
+    redirectTo:'manage/user',
     pathMatch: "full",
   },
   {

+ 1 - 1
projects/textbook/src/modules/nav-admin/page-role/page-role.component.html

@@ -1,6 +1,6 @@
 <comp-table-list
   #list
-  [schema]="_Role"
+  [schema]="Department"
   *ngIf="className && fieldsArray"
   [className]="className"
   [fieldsArray]="fieldsArray"

+ 5 - 3
projects/textbook/src/modules/nav-admin/page-role/page-role.component.ts

@@ -5,6 +5,7 @@ import _Role from '../../../schemas/_Role';
 // import { TranslateService } from '@ngx-translate/core';
 import * as Parse from "parse";
 import { CommonModule } from '@angular/common';
+import { Department } from '../../../schemas/Department';
 
 
 @Component({
@@ -17,7 +18,8 @@ import { CommonModule } from '@angular/common';
 export class PageRoleComponent  implements OnInit {
   @ViewChild(CompTableListComponent) list:CompTableListComponent|undefined
 
-  _Role = _Role
+  // _Role = _Role
+  Department = Department
   user:Parse.User|undefined
   className:string|undefined
   queryParams:any|undefined
@@ -29,8 +31,8 @@ export class PageRoleComponent  implements OnInit {
     // private translate:TranslateService,
   ) {
     this.user = Parse.User.current();
-    this.className = this._Role.className
-    this.fieldsArray = this._Role.fieldsArray
+    this.className = this.Department.className
+    this.fieldsArray = this.Department.fieldsArray
     this.queryParams = {where:{
       // user:this.user?.toPointer(),
       isDeleted:{$ne:true},

+ 2 - 2
projects/textbook/src/modules/nav-admin/page-user/page-user.component.html

@@ -8,7 +8,7 @@
   </nz-page-header-title>
   <nz-page-header-extra>
     <nz-space>
-      <button
+      <!-- <button
         style="background: #3e49b3; border: 1px #3e49b3"
         *nzSpaceItem
         nz-button
@@ -16,7 +16,7 @@
         (click)="createUser()"
       >
       创建用户
-      </button>
+      </button> -->
     </nz-space>
   </nz-page-header-extra>
 </nz-page-header>

+ 109 - 25
projects/textbook/src/modules/nav-admin/user-edit/user-edit.component.html

@@ -14,11 +14,21 @@
         ></nz-avatar>
         <div class="name-data">
           <div style="display: flex; align-items: center">
-            <div class="name">{{ user?.get("mobile") }}</div>
+            <div class="name">{{ user?.get("name") }}</div>
             <div class="status">
+              @switch (user?.get("accountState")) { @case ('待认证') {
               <nz-tag [nzBordered]="false" [nzColor]="'geekblue'"
                 >待认证</nz-tag
               >
+              } @case ('已认证') {
+              <nz-tag [nzBordered]="false" [nzColor]="'green'"
+                >已认证</nz-tag
+              >
+              } @case ('已禁用') {
+              <nz-tag [nzBordered]="false" [nzColor]="'red'"
+                >已禁用</nz-tag
+              >
+              } }
             </div>
           </div>
           <div class="id">ID:{{ user?.id }}</div>
@@ -38,7 +48,13 @@
           <nz-dropdown-menu #menu="nzDropdownMenu">
             <ul nz-menu>
               <li nz-menu-item>
-                <button nz-button nzType="link" style="color: #231c1f">
+                @if (user.get('accountState') == '待认证') {
+                <button
+                  nz-button
+                  nzType="link"
+                  style="color: #231c1f"
+                  (click)="updateUser('已认证')"
+                >
                   <span
                     nz-icon
                     nzType="safety-certificate"
@@ -46,14 +62,26 @@
                   ></span
                   >通过认证
                 </button>
+                }
               </li>
               <li nz-menu-item>
                 <button nz-button nzType="link" style="color: #231c1f">
-                  <span nz-icon nzType="stop" nzTheme="outline"></span>禁用账号
+                  <span
+                    nz-icon
+                    nzType="stop"
+                    nzTheme="outline"
+                    (click)="updateUser('已禁用')"
+                  ></span
+                  >禁用账号
                 </button>
               </li>
               <li nz-menu-item>
-                <button nz-button nzType="link" style="color: #231c1f">
+                <button
+                  (click)="updateUser('删除')"
+                  nz-button
+                  nzType="link"
+                  style="color: #231c1f"
+                >
                   <span nz-icon nzType="delete" nzTheme="outline"></span
                   >删除账号
                 </button>
@@ -65,6 +93,7 @@
           style="background: #3e49b3; border: 1px #3e49b3"
           nz-button
           nzType="primary"
+          (click)="isVisible = !isVisible"
         >
           修改密码
         </button>
@@ -81,35 +110,39 @@
           <div nz-col nzSpan="8">
             <div class="lable">创建时间</div>
             <div class="value">
-              {{ user.createdAt | date : "yyyy-MM-dd HH:MM:ss" }}
+              {{ user?.createdAt | date : "yyyy-MM-dd HH:MM:ss" }}
             </div>
           </div>
           <div nz-col nzSpan="8">
             <div class="lable">最后登录时间</div>
             <div class="value">
-              {{ user.updatedAt | date : "yyyy-MM-dd HH:MM:ss" }}
+              {{ user?.get("lastLogin") | date : "yyyy-MM-dd HH:MM:ss" }}
             </div>
           </div>
           <div nz-col nzSpan="8">
             <div class="lable">最后登录IP</div>
-            <div class="value">119.119.01.02</div>
+            <div class="value">{{ user?.get("lastIP") }}</div>
           </div>
         </div>
         <div nz-row>
           <div nz-col nzSpan="8">
             <div class="lable">登录次数</div>
-            <div class="value">123</div>
+            <div class="value">{{ user?.get("loginsCount") }}</div>
           </div>
           <div nz-col nzSpan="8">
-            <div class="lable">用户来源</div>
-            <div class="value">注册</div>
+            <div class="lable">用户类型</div>
+            <div class="value">{{ profile?.get("identity") || "未填写" }}</div>
           </div>
           <div nz-col nzSpan="8">
-            <div class="lable">用户类型</div>
-            <div class="value">单位联系人/作者/主编</div>
+            <div class="lable">认证文件</div>
+            <div class="value">
+              @if (profile?.get('identityFile')) {
+              <a [href]="profile?.get('identityFile')">查看文件</a>
+              }@else { 未上传 }
+            </div>
           </div>
         </div>
-        <div nz-row>
+        <!-- <div nz-row>
           <div nz-col nzSpan="8">
             <div class="lable">注册浏览器</div>
             <div class="value">360</div>
@@ -119,12 +152,10 @@
             <div class="value">Mozilla/5.0 (Windows NT 10.0; Win64; x64)</div>
           </div>
           <div nz-col nzSpan="8">
-            <div class="lable">认证文件</div>
-            <div class="value">
-              <a href="">查看文件</a>
-            </div>
+            <div class="lable">用户来源</div>
+            <div class="value">注册</div>
           </div>
-        </div>
+        </div> -->
       </div>
       <div class="title">手机号</div>
       <div class="fill-template">
@@ -132,18 +163,18 @@
           <div nz-col nzSpan="8">
             <div class="lable">创建时间</div>
             <div class="value">
-              {{ user?.get("mobile") }}
+              {{ user?.get("phone") || "未填写" }}
             </div>
           </div>
           <div nz-col nzSpan="8">
             <div class="lable">邮箱</div>
             <div class="value">
-              {{ user?.get("email") || "暂无" }}
+              {{ user?.get("email") || "未填写" }}
             </div>
           </div>
           <div nz-col nzSpan="8">
             <div class="lable">姓名</div>
-            <div class="value">cb</div>
+            <div class="value">{{ user?.get("name") || "未填写" }}</div>
           </div>
         </div>
       </div>
@@ -151,8 +182,30 @@
       <div class="fill-template">
         <div nz-row>
           <div nz-col nzSpan="8">
-            <div class="lable">学校</div>
-            <div class="value">美国加里敦大学</div>
+            <div class="lable">办公电话</div>
+            <div class="value">{{ profile?.get("telephone") || "未填写" }}</div>
+          </div>
+          <div nz-col nzSpan="8">
+            <div class="lable">单位类型</div>
+            <div class="value">
+              {{ profile?.get("companyType") || "未填写" }}
+            </div>
+          </div>
+          <div nz-col nzSpan="8">
+            <div class="lable">省份</div>
+            <div class="value">{{ profile?.get("province") || "未填写" }}</div>
+          </div>
+        </div>
+        <div nz-row>
+          <div nz-col nzSpan="8">
+            <div class="lable">所在部门</div>
+            <div class="value">
+              {{ user?.get("departmentName") || "未填写" }}
+            </div>
+          </div>
+          <div nz-col nzSpan="8">
+            <div class="lable">职务</div>
+            <div class="value">{{ profile?.get("postName") || "未填写" }}</div>
           </div>
         </div>
       </div>
@@ -169,8 +222,39 @@
           </div>
         </div>
       </div>
-      <div class="title">所属组织</div>
-      <div class="fill-template"></div>
+      <div class="title">所属组织部门</div>
+      <div class="fill-template">
+        <nz-tag [nzBordered]="false" style="color: black" [nzColor]="'#efefef'"
+          >“十四五”高等教育国家规划教材申报系统</nz-tag
+        >
+        /
+        <nz-tag
+          [nzBordered]="false"
+          style="color: black"
+          [nzColor]="'#efefef'"
+          >{{ profile.get("companyType") }}</nz-tag
+        >
+        /
+        <nz-tag [nzBordered]="false" [nzColor]="'geekblue'">{{
+          user.get("companyName")
+        }}</nz-tag>
+      </div>
     </nz-tab>
   </nz-tabset>
 </div>
+
+<nz-modal
+  [(nzVisible)]="isVisible"
+  nzTitle="请输入新的密码"
+  (nzOnCancel)="isVisible = false"
+  (nzOnOk)="handleOk()"
+>
+  <ng-container *nzModalContent>
+    <input
+      nz-input
+      placeholder="请输入新的密码"
+      [(ngModel)]="password"
+      type="text"
+    />
+  </ng-container>
+</nz-modal>

+ 50 - 13
projects/textbook/src/modules/nav-admin/user-edit/user-edit.component.ts

@@ -11,6 +11,8 @@ import { NzAvatarModule } from 'ng-zorro-antd/avatar';
 import { NzDropDownModule } from 'ng-zorro-antd/dropdown';
 import { NzPopoverModule } from 'ng-zorro-antd/popover';
 import { NzTagModule } from 'ng-zorro-antd/tag';
+import { NzModalModule } from 'ng-zorro-antd/modal';
+import { NzMessageService } from 'ng-zorro-antd/message';
 @Component({
   selector: 'app-user-edit',
   templateUrl: './user-edit.component.html',
@@ -25,31 +27,66 @@ import { NzTagModule } from 'ng-zorro-antd/tag';
     NzAvatarModule,
     NzDropDownModule,
     NzPopoverModule,
-    NzTagModule
+    NzTagModule,
+    NzModalModule,
   ],
   standalone: true,
 })
-export class UserEditComponent  implements OnInit {
-  visible: boolean = false;
-  inputValue:string = ''
-  
-  user:Parse.Object |any
-  profile:Parse.Object |any
+export class UserEditComponent implements OnInit {
+  inputValue: string = '';
+  isVisible: boolean = false;
+  user: Parse.Object | any;
+  profile: Parse.Object | any;
+  password: string = '';
 
   constructor(
-    private activeRoute:ActivatedRoute,
+    private activeRoute: ActivatedRoute,
     private router: Router,
-  ) { }
+    private message: NzMessageService
+  ) {}
 
   ngOnInit() {
     this.activeRoute.paramMap.subscribe(async (params) => {
       let id = params.get('id');
       console.log(id);
       if (id) {
-        let query = new Parse.Query("_User")
-        this.user = await query.get(id)
+        let query = new Parse.Query('_User');
+        this.user = await query.get(id);
+        let queryProfile = new Parse.Query('Profile');
+        queryProfile.equalTo('user', id);
+        this.profile = await queryProfile.first();
       }
-    })
+    });
+  }
+  async updateUser(type: string) {
+    console.log(type);
+    switch (type) {
+      case '已认证':
+        this.user.set('accountState', '已认证');
+        break;
+      case '已禁用':
+        this.user.set('accountState', '已禁用');
+        break;
+      case '删除':
+        this.user.set('isDeleted', true);
+        break;
+    }
+    await this.user.save();
+    this.ngOnInit();
+  }
+  async handleOk() {
+    this.password = this.password.trim()
+    if(!this.password){
+      this.message.warning('密码格式错误');
+      return
+    }
+    try {
+      this.user.set('password', this.password);
+      await this.user.save();
+      this.ngOnInit();
+    } catch (err) {
+      this.message.warning('保存出错,请注意密码格式');
+    }
+    this.isVisible = false;
   }
-
 }

+ 30 - 0
projects/textbook/src/schemas/Department.ts

@@ -0,0 +1,30 @@
+import { MatDialog } from "@angular/material/dialog";
+import { Router } from "@angular/router";
+import Parse from "parse";
+import { ParseSchema } from "./func-parse";
+
+export const Department:ParseSchema = {
+    title:"组织",
+    className:"Department",
+    emptyImg:"/img/webhook-empty.png",
+    include:["user"],
+    buttons:[
+        {
+            name:"编辑",
+            place:"item",
+            show:(options:{object:Parse.Object})=>{
+                if(location?.pathname=='/nav-admin/manage/role'){
+                    return true
+                }
+                return false
+            },
+            handle:(options:{dialog:MatDialog,object:Parse.Object,router?:Router})=>{
+                
+            }
+        }
+    ],
+    fieldsArray:[
+        {key:"name",name:"名称",type:"String",isHeader:true},
+        {key:"branch",name:"所属类型",type:"String",isHeader:true},
+    ]
+}

+ 176 - 72
projects/textbook/src/schemas/Profile-list.ts

@@ -1,75 +1,179 @@
-import { MatDialog } from "@angular/material/dialog";
-import { Router } from "@angular/router";
-import Parse from "parse";
-import { ParseSchema } from "./func-parse";
+import { MatDialog } from '@angular/material/dialog';
+import { Router } from '@angular/router';
+import Parse from 'parse';
+import { ParseSchema } from './func-parse';
 
-export const Profile:ParseSchema = {
-    title:"报送人",
-    className:"Profile",
-    emptyImg:"/img/webhook-empty.png",
-    include:["user"],
-    buttons:[
-        {
-            name:"编辑",
-            place:"item",
-            show:(options:{object:Parse.Object})=>{
-                if(location?.pathname=='/nav-admin/manage/user'){
-                    return true
-                }
-                return false
-            },
-            handle:(options:{dialog:MatDialog,object:Parse.Object,router?:Router})=>{
-                options.router?.navigate(['/nav-admin/manage/user/edit',{id:options.object?.get('user').id}])
-            }
-        },
-        {
-            name:"通过账号",
-            place:"item",
-            show:(options:{object:Parse.Object})=>{
-                if(location?.pathname=='/nav-admin/manage/user'){
-                    return true
-                }
-                return false
-            },
-            handle:(options:{dialog:MatDialog,object:Parse.Object,router?:Router})=>{
-               
-            }
-        },
-        {
-            name:"禁用账号",
-            place:"item",
-            show:(options:{object:Parse.Object})=>{
-                if(location?.pathname=='/nav-admin/manage/user'){
-                    return true
-                }
-                return false
-            },
-            handle:(options:{dialog:MatDialog,object:Parse.Object,router?:Router})=>{
-                
-            }
-        },
-        {
-            name:"删除账号",
-            place:"item",
-            show:(options:{object:Parse.Object})=>{
-                if(location?.pathname=='/nav-admin/manage/user'){
-                    return true
-                }
-                return false
+export const Profile: ParseSchema = {
+  title: '报送人',
+  className: 'Profile',
+  emptyImg: '/img/webhook-empty.png',
+  include: ['user'],
+  buttons: [
+    {
+      name: '编辑',
+      place: 'item',
+      show: (options: { object: Parse.Object }) => {
+        if (location?.pathname == '/nav-admin/manage/user') {
+          return true;
+        }
+        return false;
+      },
+      handle: (options: {
+        dialog: MatDialog;
+        object: Parse.Object;
+        router?: Router;
+      }) => {
+        options.router?.navigate([
+          '/nav-admin/manage/user/edit',
+          { id: options.object?.get('user').id },
+        ]);
+      },
+    },
+    {
+      name: '通过账号',
+      place: 'item',
+      show: (options: { object: Parse.Object }) => {
+        if (
+          location?.pathname == '/nav-admin/manage/user' &&
+          options.object?.get('user')?.get('accountState') == '待认证'
+        ) {
+          return true;
+        }
+        return false;
+      },
+      handle: (options: {
+        dialog: MatDialog;
+        object: Parse.Object;
+        router?: Router;
+        modal: any;
+      }) => {
+        options.modal?.confirm({
+          nzTitle: '确定通过认证吗?',
+          nzContent: '',
+          nzOkText: '确认',
+          nzOkType: 'primary',
+          nzOkDanger: true,
+          nzOnOk: async () => {
+            let query = new Parse.Query('_User');
+            query.equalTo('objectId', options.object.get('user')?.id);
+            let user = await query.first();
+            user?.set('accountState', '已认证');
+            await user?.save();
+            history.go(0);
+          },
+          nzCancelText: '取消',
+          nzOnCancel: () => console.log('Cancel'),
+        });
+      },
+    },
+    {
+      name: '禁用账号',
+      place: 'item',
+      show: (options: { object: Parse.Object }) => {
+        if (location?.pathname == '/nav-admin/manage/user') {
+          return true;
+        }
+        return false;
+      },
+      handle: (options: {
+        dialog: MatDialog;
+        object: Parse.Object;
+        router?: Router;
+        modal: any;
+      }) => {
+        options.modal?.confirm({
+            nzTitle: '确定禁用账号吗?',
+            nzContent: '禁用后用户将不能登录',
+            nzOkText: '确认',
+            nzOkType: 'primary',
+            nzOkDanger: true,
+            nzOnOk: async () => {
+              let query = new Parse.Query('_User');
+              query.equalTo('objectId', options.object.get('user')?.id);
+              let user = await query.first();
+              console.log(user);
+              user?.set('accountState', '已禁用');
+
+              await user?.save();
+              history.go(0);
             },
-            handle:(options:{dialog:MatDialog,object:Parse.Object,router?:Router})=>{
-                
-            }
+            nzCancelText: '取消',
+            nzOnCancel: () => console.log('Cancel'),
+          });
+      },
+    },
+    {
+      name: '删除账号',
+      place: 'item',
+      show: (options: { object: Parse.Object }) => {
+        if (location?.pathname == '/nav-admin/manage/user') {
+          return true;
         }
-    ],
-    fieldsArray:[
-        {key:"user",name:"用户",type:"Pointer",targetClass:"_User",isHeader:true,showName:"${mobile}"},
-        {key:"user",name:"姓名",type:"Pointer",targetClass:"_User",isHeader:true,showName:"${name}"},
-        {key:"user",name:"手机号",type:"Pointer",targetClass:"_User",isHeader:true,showName:"${phone}"},
-        {key:"user",name:"邮箱",type:"Pointer",targetClass:"_User",isHeader:true,showName:"${email}"},
-        // {key:"name",name:"姓名",type:"String",isHeader:true},
-        // {key:"mobile",name:"手机号",type:"String",isHeader:true},
-        // {key:"emal",name:"邮箱",type:"String",isHeader:true},
-        {key:"createdAt",name:"创建时间",type:"Date",isHeader:true,},
-    ]
-}
+        return false;
+      },
+      handle: (options: {
+        dialog: MatDialog;
+        object: Parse.Object;
+        router?: Router;
+        modal:any
+      }) => {
+        options.modal?.confirm({
+            nzTitle: '确定删除账号吗?',
+            nzContent: '删除后不可恢复',
+            nzOkText: '确认',
+            nzOkType: 'primary',
+            nzOkDanger: true,
+            nzOnOk: async () => {
+              let query = new Parse.Query('_User');
+              query.equalTo('objectId', options.object.get('user')?.id);
+              let user = await query.first();
+              user?.set('isDeleted', true);
+              await user?.save();
+              history.go(0);
+            },
+            nzCancelText: '取消',
+            nzOnCancel: () => console.log('Cancel'),
+          });
+      },
+    },
+  ],
+  fieldsArray: [
+    {
+      key: 'user',
+      name: '用户',
+      type: 'Pointer',
+      targetClass: '_User',
+      isHeader: true,
+      showName: '${name}',
+    },
+    {
+      key: 'user',
+      name: '手机号',
+      type: 'Pointer',
+      targetClass: '_User',
+      isHeader: true,
+      showName: '${phone}',
+    },
+    {
+      key: 'user',
+      name: '邮箱',
+      type: 'Pointer',
+      targetClass: '_User',
+      isHeader: true,
+      showName: '${email}',
+    },
+    { key: 'identity', name: '人员类型', type: 'String', isHeader: true },
+    {
+      key: 'user',
+      name: '认证状态',
+      type: 'Pointer',
+      targetClass: '_User',
+      isHeader: true,
+      showName: '${accountState}',
+    },
+    { key: 'companyType', name: '单位类型', type: 'String', isHeader: true },
+    // {key:"mobile",name:"手机号",type:"String",isHeader:true},
+    // {key:"emal",name:"邮箱",type:"String",isHeader:true},
+    // {key:"createdAt",name:"创建时间",type:"Date",isHeader:true,},
+  ],
+};

+ 62 - 36
projects/textbook/src/services/auth.service.ts

@@ -5,7 +5,7 @@ import { textbookServer } from './textbook';
 import { catchError } from 'rxjs/operators';
 import { HttpClient } from '@angular/common/http';
 import { NzMessageService } from 'ng-zorro-antd/message';
-
+import { NzModalService } from 'ng-zorro-antd/modal';
 @Injectable({
   providedIn: 'root',
 })
@@ -16,28 +16,29 @@ export class AuthServr {
   resetcountdown: number = 60; //重置密码验证码倒计时
   redirectUrl: string = '';
   roterPath: any = {
-    "国家级管理员":'/nav-admin',
-    "省级教育行政部门":"/nav-province-submit",
-    "流程管理员登录":"/nav-province-contact",
-    "省属高校联系人":"/nav-province-school-contact",
-    "教材评审组成员":"/nav-review",
-    "作者/教师/主编":"/nav-author/manage/space",
-  }
+    国家级管理员: '/nav-admin',
+    报送联系人: '/nav-province-submit',
+    // "流程管理员登录": '/nav-province-contact',
+    // "省属高校联系人": '/nav-province-school-contact',
+    教材评审组成员: '/nav-review',
+    // '作者/教师/主编': '/nav-author/manage/space',
+    个人: '/nav-author/manage/space',
+  };
   constructor(
     public router: Router,
     private textbook: textbookServer,
     private http: HttpClient,
-    private message: NzMessageService,
+    private message: NzMessageService
   ) {}
   //登录
-  login(id:string) {
+  login(id: string) {
     return new Promise((resolve, reject) => {
       let host =
         (Parse as any).serverURL?.split('parse')?.[0] ||
         'https://server.fmode.cn/';
       this.http
         .post(host + 'api/textbook/login', {
-          id:id
+          id: id,
         })
         .pipe(
           catchError(async (e) => {
@@ -51,8 +52,8 @@ export class AuthServr {
             Parse.User.become(token)
               .then(async (data: any) => {
                 console.log(data);
-                await this.profileVerify()
-                resolve(data)
+                await this.profileVerify();
+                resolve(data);
               })
               .catch((err: any) => {
                 console.log(err.message);
@@ -105,7 +106,7 @@ export class AuthServr {
         .post(host + 'api/textbook/register', {
           company: company,
           mobile: mobile,
-          code:code
+          code: code,
         })
         .pipe(
           catchError(async (e) => {
@@ -119,8 +120,8 @@ export class AuthServr {
             Parse.User.become(token)
               .then(async (data: any) => {
                 console.log(data);
-                await this.profileVerify()
-                resolve(data)
+                await this.profileVerify();
+                resolve(data);
               })
               .catch((err: any) => {
                 console.log(err.message);
@@ -135,28 +136,54 @@ export class AuthServr {
     });
   }
   //验证用户类型
-  async profileVerify(){
-    let query = new Parse.Query('Profile')
-    query.equalTo('user',Parse.User.current()?.id)
-    query.notEqualTo('isDeleted',true)
-    let r = await query.first()
-    if(r?.id){
-      let user = Parse.User.current()
-      if(user?.get('accountState') == '已认证'){
-        if(r.get('identity')){
-          this.router.navigate([this.roterPath[r.get('identity')]])
-          let profile = r.toJSON()
-          localStorage.setItem(
-            'profile',
-            JSON.stringify(profile)
-          );
-          this.textbook.profile = profile;
-        }
-        this.message.warning('已认证暂无身份')
+  async profileVerify(modal?: NzModalService) {
+    let query = new Parse.Query('Profile');
+    query.equalTo('user', Parse.User.current()?.id);
+    query.notEqualTo('isDeleted', true);
+    let r = await query.first();
+    if (r?.id) {
+      let user = Parse.User.current();
+      if (user?.get('isDeleted')) {
+        !modal && this.message.error('该账号已被封禁');
+        modal?.error({
+          nzTitle: '该账号已被封禁',
+          nzContent: '',
+        });
         return
       }
-      this.message.error('账号未认证完成或已禁用')
+      switch (user?.get('accountState')) {
+        case '已认证':
+          if (r.get('identity')) {
+            this.router.navigate([this.roterPath[r.get('identity')]]);
+            let profile = r.toJSON();
+            console.log(profile);
+            localStorage.setItem('profile', JSON.stringify(profile));
+            this.textbook.profile = profile;
+            return
+          }
+          this.message.warning('已认证暂无身份');
+          break;
+        case '待认证':
+          !modal && this.message.warning('账号待认证,请等待审核完成');
+          modal?.warning({
+            nzTitle: '账号待认证,请等待审核完成',
+            nzContent: '',
+          });
+          break;
+        case '已禁用':
+          !modal && this.message.error('账号已禁用');
+          modal?.error({
+            nzTitle: '账号已禁用',
+            nzContent: '',
+          });
+          break;
+      }
+      if (!user?.get('accountState')) {
+        this.router.navigate(['/user/account_info']);
+      }
+      return;
     }
+    this.router.navigate(['/user/account_info']);
   }
 
   logout(): void {
@@ -166,5 +193,4 @@ export class AuthServr {
       this.router.navigate(['/user/login']);
     });
   }
-
 }