|
@@ -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;
|
|
|
}
|
|
|
}
|