warrior преди 7 месеца
родител
ревизия
ea01251558

BIN
projects/textbook/public/img/newbanner.png


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

@@ -23,10 +23,8 @@ export class CompUploadComponent implements OnInit {
 
   fileList: any = [
     // {
-    //   uid: '1',
     //   name: 'xxx.png',
     //   status: 'done',
-    //   response: 'Server Error 500',
     //   url: 'http://www.baidu.com/xxx.png'
     // },
   ];

+ 2 - 2
projects/textbook/src/app/comp-user/comp-user.component.scss

@@ -7,8 +7,8 @@
   height         : 100%;
   z-index        : 100;
   overflow       : auto;
-  background     : url('../../../public//img/banner.png') no-repeat;
-  background-size: 100% 100%;
+  background     : url('../../../public//img/newbanner.png') no-repeat;
+  background-size: cover;
 }
 
 //logo标识样式

+ 2 - 2
projects/textbook/src/modules/common/textbook-details/textbook-details.component.html

@@ -50,11 +50,11 @@
           </div>
           <div class="row">
             <div class="label">其他主编姓名</div>
-            <div class="value">{{ textBook?.authors }}</div>
+            <div class="value">{{ textBook?.authors || '-'}}</div>
           </div>
           <div class="row">
             <div class="label">其他编者姓名</div>
-            <div class="value">{{ textBook?.editor }}</div>
+            <div class="value">{{ textBook?.editor || '-'}}</div>
           </div>
           <div class="row">
             <div class="label">是否为重点立项教材</div>

+ 46 - 8
projects/textbook/src/modules/login/account-info/account-info.component.html

@@ -41,6 +41,43 @@
         class="account-form"
         (ngSubmit)="submitForm()"
       >
+      <nz-form-item nz-row nzJustify="space-between">
+        <nz-form-label
+          nz-col
+          nzSpan="6"
+          class="label"
+          [nzNoColon]="true"
+          nzRequired
+          >用户名</nz-form-label
+        >
+        <nz-input-group nz-col nzSpan="16">
+          <input
+            nz-input
+            type="text"
+            formControlName="username"
+            placeholder="请输入用户名"
+          />
+        </nz-input-group>
+      </nz-form-item>
+      <nz-form-item nz-row nzJustify="space-between">
+        <nz-form-label
+          nz-col
+          nzSpan="6"
+          class="label"
+          [nzNoColon]="true"
+          nzRequired
+          >密码</nz-form-label
+        >
+        <nz-input-group nz-col nzSpan="16">
+          <input
+            nz-input
+            type="password"
+            formControlName="password"
+            placeholder="请输入密码"
+          />
+        </nz-input-group>
+      </nz-form-item>
+
         <nz-form-item nz-row nzJustify="space-between">
           <nz-form-label
             nz-col
@@ -59,9 +96,8 @@
             />
           </nz-input-group>
         </nz-form-item>
-        @if (validateForm.value.identity!='工作联系人') {
         <nz-form-item nz-row nzJustify="space-between">
-          <nz-form-label nz-col nzSpan="6" class="label" [nzNoColon]="true"
+          <nz-form-label nz-col nzSpan="6" class="label" [nzNoColon]="true" nzRequired
             >手机号</nz-form-label
           >
           <nz-input-group nz-col nzSpan="16">
@@ -75,7 +111,6 @@
             />
           </nz-input-group>
         </nz-form-item>
-        }
 
         <nz-form-item nz-row nzJustify="space-between">
           <nz-form-label
@@ -123,7 +158,6 @@
           </nz-input-group>
         </nz-form-item>
         <!-- validateForm.value.identity=='工作联系人' -->
-        @if (validateForm.value.identity == '工作联系人') {
         <!-- <nz-form-item nz-row nzJustify="space-between">
         <nz-form-label nz-col nzSpan="6" class="label" [nzNoColon]="true">办公电话</nz-form-label>
         <nz-input-group nz-col nzSpan="16">
@@ -241,7 +275,6 @@
             <div
               style="
                 background: var(--palette-grey---semi-grey-1, #eae6e6);
-                width: 120px;
                 padding: 5px 10px;
                 border-radius: 5px;
               "
@@ -253,14 +286,15 @@
               ></app-comp-upload>
             </div>
             <div class="text" style="margin: 10px 0; color: #231c1f99">
-              请 <a href="/file/模板.doc" download='模板'>下载单位联系人认证文件模板</a>,填写盖章后上传 PDF
-              格式,单个文件大小不超过 2M
+              请
+              <a href="/file/模板.doc" download="模板"
+                >下载单位联系人认证文件模板</a
+              >,填写盖章后上传 PDF 格式,单个文件大小不超过 2M
               <!-- 请<a href="">下载单位联系人认证文件模板</a>,填写盖章后上传。支持上传 PDF、JPG、JPEG、PNG
             格式,单个文件大小不超过 2M -->
             </div>
           </nz-input-group>
         </nz-form-item>
-        }
       </form>
 
       <button
@@ -268,6 +302,7 @@
         class="form-button"
         type="button"
         mat-button
+        [disabled]="loading"
         (click)="submitForm()"
       >
         提交
@@ -291,3 +326,6 @@
     </div>
   </div>
 </div>
+<div class="loading" [hidden]="!loading">
+  <nz-spin nzSimple [nzSize]="'large'"></nz-spin>
+</div>

+ 20 - 15
projects/textbook/src/modules/login/account-info/account-info.component.scss

@@ -71,21 +71,14 @@
   text-align: left;
 
 }
-// input {
-//   text-align: left;
-//   border: none;
-//   width: 100%;
-//   padding: 4px 6px;
-//   background: #f9f9f9;
-//   border-radius: 4px;
-//   font-family: PingFang SC;
-//   font-size: 14px;
-//   font-weight: 400;
-//   line-height: 22px;
-// }
-// input {
-//   outline: none;
-// }
+input:-webkit-autofill,
+input:-webkit-autofill:hover,
+input:-webkit-autofill:focus,
+input:-webkit-autofill:active {
+  -webkit-transition-delay: 99999s;
+  -webkit-transition: color 99999s ease-out, background-color 99999s ease-out;
+}
+
 .form-button {
   width: 100%;
   height: 46px;
@@ -94,6 +87,18 @@
   color: white !important;
   border-radius: 4px;
 }
+.loading{
+  position: absolute;
+  top: 0;
+  left: 0;
+  width: 100vw;
+  text-align: center;
+  height: 100vh;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  background: rgb(0 0 0 / 30%);
+}
 ::ng-deep .ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn {
   color: #c6233f;
 }

+ 125 - 85
projects/textbook/src/modules/login/account-info/account-info.component.ts

@@ -4,7 +4,7 @@ import { HttpClient } from '@angular/common/http';
 import { Router } from '@angular/router';
 import { catchError } from 'rxjs/operators';
 import { NzUploadModule } from 'ng-zorro-antd/upload';
-import { NzModalModule,NzModalService } from 'ng-zorro-antd/modal';
+import { NzModalModule, NzModalService } from 'ng-zorro-antd/modal';
 import {
   FormControl,
   FormGroup,
@@ -20,7 +20,7 @@ import { provinces } from '../../../services/provinces';
 import { CompUploadComponent } from '../../../app/comp-upload/comp-upload.component';
 import Parse from 'parse';
 import { NzGridModule } from 'ng-zorro-antd/grid';
-
+import { NzSpinModule } from 'ng-zorro-antd/spin';
 @Component({
   selector: 'app-account-info',
   standalone: true,
@@ -31,31 +31,36 @@ import { NzGridModule } from 'ng-zorro-antd/grid';
     NzUploadModule,
     NzModalModule,
     CompUploadComponent,
-    NzGridModule
+    NzGridModule,
+    NzSpinModule
   ],
   templateUrl: './account-info.component.html',
   styleUrls: ['./account-info.component.scss'],
 })
 export class AccountInfoComponent implements OnInit {
-  url:string = `"http://hep-textbook.oss-cn-beijing.aliyuncs.com/6687b9417f823ff53c74cfd6/2024-7-15/1721044465100-%E2%80%9C%E5%8D%81%E5%9B%9B%E4%BA%94%E2%80%9D%E6%99%AE%E9%80%9A%E9%AB%98%E7%AD%89%E6%95%99%E8%82%B2%E6%9C%AC%E7%A7%91%E5%9B%BD%E5%AE%B6%E7%BA%A7%E8%A7%84%E5%88%92%E6%95%99%E6%9D%90%E6%8E%A8%E8%8D%90%E9%81%B4%E9%80%89%E5%B7%A5%E4%BD%9C%E8%81%94%E7%B3%BB%E4%BA%BA%E4%BF%A1%E6%81%AF%E8%A1%A8.doc"`
+  url: string = `"http://hep-textbook.oss-cn-beijing.aliyuncs.com/6687b9417f823ff53c74cfd6/2024-7-15/1721044465100-%E2%80%9C%E5%8D%81%E5%9B%9B%E4%BA%94%E2%80%9D%E6%99%AE%E9%80%9A%E9%AB%98%E7%AD%89%E6%95%99%E8%82%B2%E6%9C%AC%E7%A7%91%E5%9B%BD%E5%AE%B6%E7%BA%A7%E8%A7%84%E5%88%92%E6%95%99%E6%9D%90%E6%8E%A8%E8%8D%90%E9%81%B4%E9%80%89%E5%B7%A5%E4%BD%9C%E8%81%94%E7%B3%BB%E4%BA%BA%E4%BF%A1%E6%81%AF%E8%A1%A8.doc"`;
   user: Parse.Object | undefined;
   validateForm: FormGroup<{
+    username: FormControl<string>;
+    password: FormControl<string>;
     name: FormControl<string>; //姓名
     phone: FormControl<string>; //手机号
     email: FormControl<string>; //电子邮箱
+    identity: FormControl<string>; //人员类型
     // telephone: FormControl<string>; //办公电话
     // province: FormControl<string>; //省份
-    identity: FormControl<string>; //人员类型
     // idcard: FormControl<string>; //身份证号
     // departmentName: FormControl<string>; //所在部门
     // postName: FormControl<string>; //职务
   }> = this.fb.group({
+    username: ['', [Validators.required]],
+    password: ['', [Validators.required]],
     name: ['', [Validators.required]],
     phone: [''],
     email: ['', [Validators.required]],
+    identity: ['', [Validators.required]],
     // telephone: [''],
     // province: [''],
-    identity: ['', [Validators.required]],
     // idcard: ['', [Validators.required]],
     // departmentName: [''],
     // postName: [''],
@@ -82,37 +87,40 @@ export class AccountInfoComponent implements OnInit {
 
   async ngOnInit() {
     let user = Parse.User.current();
-    if (!user?.id) history.back();
-    this.user = user;
-    await this.getUnitTypes();
-    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;
+    if (user?.id) {
+      this.message.success('请先退出登录');
+      history.back();
     }
-    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') || ''],
-      identity: [profile?.get('identity') || '', [Validators.required]],
-      // departmentName: [user?.get('departmentName') || ''],
-      // postName: [profile?.get('postName') || ''],
-    });
-    this.identityFile = profile?.get('identityFile') || ''
-    this.companyId = user?.get('department')?.id || '';
-    this.companyType = profile?.get('companyType') || ''
+    // this.user = user;
+    await this.getUnitTypes();
+    // 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({
+    //   username: [user?.get('username'), [Validators.required]],
+    //   password: ['', [Validators.required]],
+    //   name: [user?.get('name') || '', [Validators.required]],
+    //   phone: [user?.get('phone') || ''],
+    //   email: [user?.get('email') || '', [Validators.required]],
+    //   // telephone: [profile?.get('telephone') || ''],
+    //   // province: [user?.get('province') || ''],
+    //   identity: [profile?.get('identity') || '', [Validators.required]],
+    //   // departmentName: [user?.get('departmentName') || ''],
+    //   // postName: [profile?.get('postName') || ''],
+    // });
+    // this.identityFile = profile?.get('identityFile') || ''
+    // this.companyId = user?.get('department')?.id || '';
+    // this.companyType = profile?.get('companyType') || ''
     this.provinceChange();
-    // console.log(this.companyId, this.identityFile);
-    // console.log(this.validateForm.value);
   }
   async getUnitTypes() {
     let query = new Parse.Query('Department');
@@ -130,9 +138,9 @@ export class AccountInfoComponent implements OnInit {
     // console.log(val);
     if (isChange) this.companyId = '';
     this.companys = [];
-    let parent = this.unitTypes.find(item=>item.name == this.companyType)
+    let parent = this.unitTypes.find((item) => item.name == this.companyType);
     // console.log(parent);
-    if(!parent?.id) return
+    if (!parent?.id) return;
     let query = new Parse.Query('Department');
     query.equalTo('parent', parent?.id);
     query.select('name', 'branch');
@@ -140,14 +148,16 @@ export class AccountInfoComponent implements OnInit {
     val && query.contains('name', val);
     let r = await query.find();
     if (r.length > 0) {
-      this.companys = r.map((item: Parse.Object) =>{ return { id: item.id, name: item.get('name') }});
+      this.companys = r.map((item: Parse.Object) => {
+        return { id: item.id, name: item.get('name') };
+      });
     }
   }
   submitForm(): void {
     console.log(this.validateForm.value);
     console.log(this.companyId);
     if (this.validateForm.valid) {
-      if (!this.companyId && this.validateForm.value.identity == '工作联系人') {
+      if (!this.companyId) {
         this.message.error('单位名称未选择或与单位类型不匹配,请重新选择');
         return;
       }
@@ -157,7 +167,13 @@ export class AccountInfoComponent implements OnInit {
         this.message.error('邮箱格式不正确');
         return;
       }
-      if (!this.identityFile && this.validateForm.value.identity == '工作联系人') {
+      let m =
+        /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[1589]))\d{8}$/;
+      if (!String(this.validateForm.value.phone).match(m)) {
+        this.message.error('手机号格式不正确');
+        return;
+      }
+      if (!this.identityFile) {
         this.message.error('请上传单位联系人认证文件');
         return;
       }
@@ -173,61 +189,85 @@ export class AccountInfoComponent implements OnInit {
       });
     }
   }
-
+  loading:boolean = false
   async profileSave(params: any) {
-    let queryDepart = new Parse.Query('Department')
-    queryDepart.equalTo('objectId', this.companyId);
-    queryDepart.select('objectId');
-    let depart = await queryDepart.first()
-    if(!depart?.id && this.validateForm.value.identity == '工作联系人'){
-      this.message.error('单位名称未选择或与单位类型不匹配,请重新选择');
-      return;
-    }
-    this.user?.set('name', params.name);
-    this.user?.set('email', params.email);
-    this.user?.set('phone', params.phone);
-    // this.user?.set('province', params.province);
-    this.user?.set('companyName', depart?.get('name'));
-    if(this.validateForm.value.identity == '工作联系人'){
+    this.loading = true
+    try {
+      let queryDepart = new Parse.Query('Department');
+      queryDepart.equalTo('objectId', this.companyId);
+      queryDepart.select('objectId');
+      let depart = await queryDepart.first();
+      if (!depart?.id) {
+        this.message.error('单位名称未选择或与单位类型不匹配,请重新选择');
+        this.loading = false
+        return;
+      }
+      let u = Parse.Object.extend('_User');
+      this.user = new u();
+      this.user?.set('username', params.username);
+      this.user?.set('password', params.password);
+      this.user?.set('name', params.name);
+      this.user?.set('email', params.email);
+      this.user?.set('phone', params.phone);
+      // this.user?.set('province', params.province);
+      this.user?.set('companyName', depart?.get('name'));
+      // if(this.validateForm.value.identity == '工作联系人'){
       this.user?.set('department', {
         __type: 'Pointer',
         className: 'Department',
         objectId: depart?.id,
       });
-    }
-    !this.user?.get('accountState') && this.user?.set('accountState', '待认证');
-    // this.user?.set('departmentName', params.departmentName);
-    await this.user?.save();
+      // }
+      !this.user?.get('accountState') &&
+        this.user?.set('accountState', '待认证');
+      // this.user?.set('departmentName', params.departmentName);
+      await this.user?.save();
 
-    let query = new Parse.Query('Profile');
-    query.equalTo('user', Parse.User.current()?.id);
-    query.notEqualTo('isDeleted', true);
-    let profile = await query.first();
-    if (!profile?.id) {
-      let obj = Parse.Object.extend('Profile');
-      profile = new obj();
-    }
-    profile?.set('user', Parse.User.current()?.toPointer());
-    profile?.set('company', {
-      __type: 'Pointer',
-      className: 'Company',
-      objectId: this.tbookSer.company,
-    });
-    // profile?.set('telephone', params.telephone);
-    if(this.validateForm.value.identity == '工作联系人'){
+      let query = new Parse.Query('Profile');
+      query.equalTo('user', Parse.User.current()?.id);
+      query.notEqualTo('isDeleted', true);
+      let profile = await query.first();
+      if (!profile?.id) {
+        let obj = Parse.Object.extend('Profile');
+        profile = new obj();
+      }
+      profile?.set('user', Parse.User.current()?.toPointer());
+      profile?.set('company', {
+        __type: 'Pointer',
+        className: 'Company',
+        objectId: this.tbookSer.company,
+      });
+      // profile?.set('telephone', params.telephone);
+      // if(this.validateForm.value.identity == '工作联系人'){
       profile?.set('companyType', this.companyType);
       profile?.set('identityFile', this.identityFile);
+      // }
+      profile?.set('email', params.email);
+      // profile?.set('idcard', params.idcard);
+      // profile?.set('postName', params.postName);
+      profile?.set('identity', params.identity);
+      let res = await profile?.save();
+      this.loading = false
+      this.modal.success({
+        nzTitle: '提交成功',
+        nzContent: '',
+        nzOnOk: () =>
+          this.router.navigate(['/user/login'], { replaceUrl: true }),
+      });
+    } catch (err: any) {
+      this.loading = false
+      console.log(err?.message);
+      let msg = '注册失败';
+      switch (err?.message) {
+        case 'Account already exists for this email address.':
+          msg = '注册失败,邮箱已存在';
+          break;
+        case 'Account already exists for this username.':
+          msg = '注册失败,用户名已存在';
+          break;
+      }
+      this.message.error(msg);
     }
-    profile?.set('email', params.email);
-    // profile?.set('idcard', params.idcard);
-    // profile?.set('postName', params.postName);
-    profile?.set('identity', params.identity);
-    let res = await profile?.save();
-    this.modal.success({
-      nzTitle: '提交成功',
-      nzContent: '',
-      nzOnOk: () => this.router.navigate(['/user/login'], { replaceUrl: true }),
-    });
   }
   upload(e: any) {
     console.log(e);

+ 6 - 0
projects/textbook/src/modules/login/login/login.component.ts

@@ -37,6 +37,12 @@ export class LoginComponent implements OnInit{
       login:(user,authClient)=>{
         console.log(user,Parse.User.current())
         this.authServr.profileVerify(this.modal)
+      },
+      beforeChangeModule:(data:any)=>{
+        if(data=='register'){
+          this.router.navigate(['/user/account_info'])
+        }
+        console.log(data);
       }
     });
     parseAuthing.initLoginModal();

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

@@ -18,6 +18,7 @@ export class ParseAuthing{
         beforeLogin:undefined, // 用户触发登录前(返回<boolean | Promise<boolean>>用于控制本次登录是否继续)。
         register:undefined, // 用户注册成功
         beforeRegister:undefined, // 用户触发注册前(返回<boolean | Promise<boolean>>用于控制本次注册是否继续)。
+        beforeChangeModule:undefined
     }
     constructor(options?:{
         login?:{(user:any,authenticationClient:any):void}
@@ -25,12 +26,14 @@ export class ParseAuthing{
         beforeLogin?:Function
         register?:Function
         beforeRegister?:Function
+        beforeChangeModule?:Function
     }){
         this.event['login'] = options?.login
         this.event['login-error'] = options?.loginError
         this.event['beforeLogin'] = options?.beforeLogin
         this.event['register'] = options?.register
         this.event['beforeRegister'] = options?.beforeRegister
+        this.event['before-change-module'] = options?.beforeChangeModule
     }
     initLoginModal(){
         this.authingGurad = new GuardFactory.Guard({
@@ -67,6 +70,12 @@ export class ParseAuthing{
                 this.event["login"](user,authClient)
             }
         })
+        this.authingGurad.on('before-change-module', (moduleType: 'register') => {
+            if(moduleType == 'register' && typeof this.event["beforeChangeModule"] == 'function'){
+                this.event["beforeChangeModule"](moduleType)
+            }
+            return
+        })
     }
     logout(){
         this.authingGurad.logout();