|
@@ -1,4 +1,4 @@
|
|
-import { Component, OnInit } from '@angular/core';
|
|
|
|
|
|
+import { Component, OnInit, ViewChild } from '@angular/core';
|
|
import { FormsModule } from '@angular/forms';
|
|
import { FormsModule } from '@angular/forms';
|
|
import {
|
|
import {
|
|
LoadingController,
|
|
LoadingController,
|
|
@@ -10,16 +10,27 @@ import { identityCodeValid } from '../../../services/utils';
|
|
import { AgreementComponent } from '../../login/agreement/agreement.component';
|
|
import { AgreementComponent } from '../../login/agreement/agreement.component';
|
|
import * as Parse from 'parse';
|
|
import * as Parse from 'parse';
|
|
import { NavComponent } from '../../../app/components/nav/nav.component';
|
|
import { NavComponent } from '../../../app/components/nav/nav.component';
|
|
-import { ionicStandaloneModules } from '../../ionic-standalone.modules';
|
|
|
|
|
|
+import {
|
|
|
|
+ AlertController,
|
|
|
|
+ ionicStandaloneModules,
|
|
|
|
+} from '../../ionic-standalone.modules';
|
|
|
|
+import { UploadComponent } from '../../../app/components/upload/upload.component';
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-certification',
|
|
selector: 'app-certification',
|
|
templateUrl: './certification.component.html',
|
|
templateUrl: './certification.component.html',
|
|
styleUrls: ['./certification.component.scss'],
|
|
styleUrls: ['./certification.component.scss'],
|
|
standalone: true,
|
|
standalone: true,
|
|
- imports: [...ionicStandaloneModules, FormsModule, NavComponent],
|
|
|
|
|
|
+ imports: [
|
|
|
|
+ ...ionicStandaloneModules,
|
|
|
|
+ FormsModule,
|
|
|
|
+ NavComponent,
|
|
|
|
+ UploadComponent,
|
|
|
|
+ ],
|
|
})
|
|
})
|
|
export class CertificationComponent implements OnInit {
|
|
export class CertificationComponent implements OnInit {
|
|
|
|
+ @ViewChild('upload') upload!: UploadComponent;
|
|
|
|
+
|
|
name: string = '';
|
|
name: string = '';
|
|
idCard: string = '';
|
|
idCard: string = '';
|
|
title: string =
|
|
title: string =
|
|
@@ -33,11 +44,15 @@ export class CertificationComponent implements OnInit {
|
|
agreement: boolean = false;
|
|
agreement: boolean = false;
|
|
registerAgreement: any;
|
|
registerAgreement: any;
|
|
profile?: Parse.Object;
|
|
profile?: Parse.Object;
|
|
|
|
+ cardtype: 'regions' | 'cn' = 'cn'; // 身份证类型
|
|
|
|
+ eduImage: string = '';
|
|
|
|
+
|
|
constructor(
|
|
constructor(
|
|
private service: HttpService,
|
|
private service: HttpService,
|
|
public loadCtrl: LoadingController,
|
|
public loadCtrl: LoadingController,
|
|
private modalController: ModalController,
|
|
private modalController: ModalController,
|
|
- public toastController: ToastController
|
|
|
|
|
|
+ private alertController: AlertController,
|
|
|
|
+ private toastController: ToastController
|
|
) {}
|
|
) {}
|
|
|
|
|
|
ngOnInit() {
|
|
ngOnInit() {
|
|
@@ -61,10 +76,17 @@ export class CertificationComponent implements OnInit {
|
|
this.profile = await query.first();
|
|
this.profile = await query.first();
|
|
if (this.profile?.id) {
|
|
if (this.profile?.id) {
|
|
this.isReal = this.profile.get('isCross');
|
|
this.isReal = this.profile.get('isCross');
|
|
- if (this.isReal)
|
|
|
|
|
|
+ if (this.isReal) {
|
|
localStorage.setItem('profile', JSON.stringify(this.profile.toJSON()));
|
|
localStorage.setItem('profile', JSON.stringify(this.profile.toJSON()));
|
|
- this.secretIdCard = this.profile.get('idcard')?.slice(0, 6);
|
|
|
|
- this.secretName = this.profile.get('name')?.slice(0, 1);
|
|
|
|
|
|
+ this.secretIdCard = this.profile.get('idcard')?.slice(0, 6);
|
|
|
|
+ this.secretName = this.profile.get('name')?.slice(0, 1);
|
|
|
|
+ } else if (this.profile.get('cardtype') === 'regions') {
|
|
|
|
+ this.cardtype = 'regions'
|
|
|
|
+ this.name = this.profile.get('name');
|
|
|
|
+ this.idCard = this.profile.get('idcard');
|
|
|
|
+ this.eduImage = this.profile.get('eduImage')
|
|
|
|
+ this.presentAlert('审核中',true);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
async showAgreement() {
|
|
async showAgreement() {
|
|
@@ -87,10 +109,10 @@ export class CertificationComponent implements OnInit {
|
|
toast.present();
|
|
toast.present();
|
|
}
|
|
}
|
|
|
|
|
|
- async check() {
|
|
|
|
- if(!this.agreement){
|
|
|
|
- this.presentToast('请先阅读且同意隐私协议',1500,'danger')
|
|
|
|
- return
|
|
|
|
|
|
+ async submit() {
|
|
|
|
+ if (!this.agreement) {
|
|
|
|
+ this.presentToast('请先阅读且同意隐私协议', 1500, 'danger');
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
this.loading = await this.loadCtrl.create();
|
|
this.loading = await this.loadCtrl.create();
|
|
this.loading.present();
|
|
this.loading.present();
|
|
@@ -115,10 +137,14 @@ export class CertificationComponent implements OnInit {
|
|
);
|
|
);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if(this.getAgeFromIdCard(this.idCard) < 18){
|
|
|
|
|
|
+ if (this.getAgeFromIdCard(this.idCard) < 18) {
|
|
this.loading.dismiss();
|
|
this.loading.dismiss();
|
|
- await this.presentToast('根据平台规定,仅限满18周岁用户使用。',1500,'danger')
|
|
|
|
- return
|
|
|
|
|
|
+ await this.presentToast(
|
|
|
|
+ '根据平台规定,仅限满18周岁用户使用。',
|
|
|
|
+ 1500,
|
|
|
|
+ 'danger'
|
|
|
|
+ );
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
let res: any = await this.service.postAuth(
|
|
let res: any = await this.service.postAuth(
|
|
this.company,
|
|
this.company,
|
|
@@ -129,8 +155,8 @@ export class CertificationComponent implements OnInit {
|
|
let { isok } = res.data.result;
|
|
let { isok } = res.data.result;
|
|
console.log(isok);
|
|
console.log(isok);
|
|
if (isok) {
|
|
if (isok) {
|
|
- let { sex,city } = res.data.result.IdCardInfor;
|
|
|
|
- this.anthProfile(sex,city);
|
|
|
|
|
|
+ let { sex, city } = res.data.result.IdCardInfor;
|
|
|
|
+ this.anthProfile(sex, city);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this.loading.dismiss();
|
|
this.loading.dismiss();
|
|
@@ -146,12 +172,13 @@ export class CertificationComponent implements OnInit {
|
|
}, 500);
|
|
}, 500);
|
|
}
|
|
}
|
|
|
|
|
|
- async anthProfile(sex: string,city:string) {
|
|
|
|
|
|
+ async anthProfile(sex?: string, city?: string) {
|
|
let user = Parse.User.current();
|
|
let user = Parse.User.current();
|
|
let query = new Parse.Query('Profile');
|
|
let query = new Parse.Query('Profile');
|
|
query.equalTo('idcard', this.idCard);
|
|
query.equalTo('idcard', this.idCard);
|
|
query.equalTo('company', this.company);
|
|
query.equalTo('company', this.company);
|
|
query.notEqualTo('isDeleted', true);
|
|
query.notEqualTo('isDeleted', true);
|
|
|
|
+ query.notEqualTo('user', Parse.User.current()?.id);
|
|
let res = await query.first();
|
|
let res = await query.first();
|
|
if (res && res.id) {
|
|
if (res && res.id) {
|
|
this.loading.dismiss();
|
|
this.loading.dismiss();
|
|
@@ -179,19 +206,33 @@ export class CertificationComponent implements OnInit {
|
|
}
|
|
}
|
|
this.profile?.set('idcard', this.idCard);
|
|
this.profile?.set('idcard', this.idCard);
|
|
this.profile?.set('name', this.name);
|
|
this.profile?.set('name', this.name);
|
|
- this.profile?.set('sex', sex);
|
|
|
|
- this.profile?.set('city', city);
|
|
|
|
- this.profile?.set('isCross', true);
|
|
|
|
- this.profile?.set('birthdate', String(this.getAgeFromIdCard(this.idCard)));
|
|
|
|
- await this.profile?.save();
|
|
|
|
- if (this.profile?.id) {
|
|
|
|
- localStorage.setItem('profile', JSON.stringify(this.profile.toJSON()));
|
|
|
|
- this.loading.dismiss();
|
|
|
|
- this.isReal = true;
|
|
|
|
- await this.presentToast('认证成功', 1500, 'primary');
|
|
|
|
- setTimeout(() => {
|
|
|
|
- history.back();
|
|
|
|
- }, 1500);
|
|
|
|
|
|
+ this.profile?.set('cardtype', this.cardtype);
|
|
|
|
+ if (this.cardtype === 'cn') {
|
|
|
|
+ this.profile?.set('sex', sex);
|
|
|
|
+ this.profile?.set('city', city);
|
|
|
|
+ this.profile?.set('isCross', true);
|
|
|
|
+ this.profile?.set(
|
|
|
|
+ 'birthdate',
|
|
|
|
+ String(this.getAgeFromIdCard(this.idCard))
|
|
|
|
+ );
|
|
|
|
+ await this.profile?.save();
|
|
|
|
+ if (this.profile?.id) {
|
|
|
|
+ localStorage.setItem('profile', JSON.stringify(this.profile.toJSON()));
|
|
|
|
+ this.loading.dismiss();
|
|
|
|
+ this.isReal = true;
|
|
|
|
+ await this.presentToast('认证成功', 1500, 'primary');
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ history.back();
|
|
|
|
+ }, 1500);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.profile?.set('eduImage',this.eduImage)
|
|
|
|
+ await this.profile?.save();
|
|
|
|
+ if (this.profile?.id) {
|
|
|
|
+ localStorage.setItem('profile', JSON.stringify(this.profile.toJSON()));
|
|
|
|
+ this.loading.dismiss();
|
|
|
|
+ this.presentAlert('提交成功,等待审核',true);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -208,10 +249,53 @@ export class CertificationComponent implements OnInit {
|
|
// 计算年龄
|
|
// 计算年龄
|
|
let age = today.getFullYear() - birthDate.getFullYear();
|
|
let age = today.getFullYear() - birthDate.getFullYear();
|
|
const monthDiff = today.getMonth() - birthDate.getMonth();
|
|
const monthDiff = today.getMonth() - birthDate.getMonth();
|
|
- if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
|
|
|
|
|
|
+ if (
|
|
|
|
+ monthDiff < 0 ||
|
|
|
|
+ (monthDiff === 0 && today.getDate() < birthDate.getDate())
|
|
|
|
+ ) {
|
|
age--;
|
|
age--;
|
|
}
|
|
}
|
|
return age;
|
|
return age;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ async changeFile(e: any) {
|
|
|
|
+ this.eduImage = e[0]?.url;
|
|
|
|
+ console.log(this.eduImage);
|
|
|
|
+ }
|
|
|
|
+ async submitRegions() {
|
|
|
|
+ if (!this.agreement) {
|
|
|
|
+ this.presentToast('请先阅读且同意隐私协议', 1500, 'danger');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.loading = await this.loadCtrl.create();
|
|
|
|
+ this.loading.present();
|
|
|
|
+ this.time && clearTimeout(this.time);
|
|
|
|
+ this.time = setTimeout(async () => {
|
|
|
|
+ this.name = this.name.trim();
|
|
|
|
+ this.idCard = this.idCard.trim();
|
|
|
|
+ console.log(this.name, this.idCard);
|
|
|
|
+ if (!this.idCard || !this.name || !this.eduImage) {
|
|
|
|
+ this.loading.dismiss();
|
|
|
|
+ await this.presentToast('请填写完整信息', 1500, 'danger');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.anthProfile();
|
|
|
|
+ }, 500);
|
|
|
|
+ }
|
|
|
|
+ async presentAlert(msg: string, isBack?: boolean) {
|
|
|
|
+ const alert = await this.alertController.create({
|
|
|
|
+ header: '提示',
|
|
|
|
+ message: msg,
|
|
|
|
+ buttons: [
|
|
|
|
+ {
|
|
|
|
+ text: '好的',
|
|
|
|
+ role: 'confirm',
|
|
|
|
+ handler: () => {
|
|
|
|
+ isBack && history.back();
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ });
|
|
|
|
+ await alert.present();
|
|
|
|
+ }
|
|
}
|
|
}
|