162 lines
4.3 KiB
TypeScript
162 lines
4.3 KiB
TypeScript
import { BaseLogic, Methods } from "@logic/Base.logic";
|
||
import { Inject } from "@ann/Ioc.annotation";
|
||
import { PublicServiceImpl } from '@/core/service/impl/Public.Service.impl';
|
||
import { BussinessServiceImpl } from '@/core/service/impl/Bussiness.service.impl';
|
||
|
||
export interface Enterprise {
|
||
name: string
|
||
credit_code: string
|
||
business_term: string | number
|
||
reg_address: string
|
||
legal_name: string
|
||
legal_cellphone: string
|
||
id_card_num: string
|
||
telnum: string
|
||
bank: string
|
||
bank_num: string
|
||
front_image_id: string
|
||
bank_image_id: string
|
||
business_license: string
|
||
front_image: string
|
||
bank_image: string
|
||
license_image: string
|
||
}
|
||
|
||
export class EnterpriseCertificationLogic extends BaseLogic implements Methods {
|
||
|
||
@Inject()
|
||
public readonly PublicServiceImpl!: PublicServiceImpl;
|
||
|
||
@Inject()
|
||
public readonly BussinessServiceImpl!: BussinessServiceImpl;
|
||
|
||
constructor(point: any) {
|
||
super();
|
||
this.VueApp = point;
|
||
}
|
||
|
||
public async StartUp(): Promise<void> {
|
||
await this.getBussinessDetail()
|
||
}
|
||
|
||
public param: Enterprise = {
|
||
name : "",
|
||
credit_code : "",
|
||
business_term : "",
|
||
reg_address : "",
|
||
legal_name : "",
|
||
legal_cellphone : "",
|
||
id_card_num : "",
|
||
telnum : "",
|
||
bank : "",
|
||
bank_num : "",
|
||
front_image_id : "",
|
||
bank_image_id : "",
|
||
business_license : "",
|
||
front_image : "",
|
||
bank_image : "",
|
||
license_image : ""
|
||
}
|
||
|
||
public fileList1: { url: string, uid: string, name: string }[] = []
|
||
public fileList2: { url: string, uid: string, name: string }[] = []
|
||
public fileList3: { url: string, uid: string, name: string }[] = []
|
||
public placeholderText: string = "长期有效,无需选择时间";
|
||
public textaa: string = ""
|
||
|
||
private async getBussinessDetail() {
|
||
let res = await this.BussinessServiceImpl.getBussinessDetail();
|
||
|
||
if (res.business_term != 0) {
|
||
res.business_term = res.business_term * 1000
|
||
this.textaa = this.formateDate(res.business_term)
|
||
}
|
||
|
||
if(res) {
|
||
// res.business_term = res.business_term * 1000
|
||
this.param = res
|
||
this.fileList1 = [ {
|
||
uid : res.front_image_id,
|
||
url : res.front_image,
|
||
name : '1.png'
|
||
} ]
|
||
this.fileList2 = [ {
|
||
uid : res.bank_image_id,
|
||
url : res.bank_image,
|
||
name : '1.png'
|
||
} ]
|
||
this.fileList3 = [ {
|
||
uid : res.business_license,
|
||
url : res.license_image,
|
||
name : '1.png'
|
||
} ]
|
||
}
|
||
}
|
||
|
||
private formateDate(datetime: any) {
|
||
// let = "2019-11-06T16:00:00.000Z"
|
||
function addDateZero(num: any) {
|
||
return (num < 10 ? "0" + num : num);
|
||
}
|
||
|
||
let d = new Date(datetime);
|
||
let formatdatetime = d.getFullYear() + '-' + addDateZero(d.getMonth() + 1) + '-' + addDateZero(d.getDate());
|
||
return formatdatetime;
|
||
}
|
||
|
||
public async bussinessSetBussiness() {
|
||
let param = this.param
|
||
let { fileList1, fileList2, fileList3 } = this
|
||
if(fileList1.length > 0) {
|
||
param.front_image_id = fileList1[0].uid
|
||
}
|
||
if(fileList2.length > 0) {
|
||
param.bank_image_id = fileList2[0].uid
|
||
}
|
||
if(fileList3.length > 0) {
|
||
param.business_license = fileList3[0].uid
|
||
}
|
||
console.log("this.textaa; ",this.textaa);
|
||
|
||
if (this.textaa == null || this.textaa.length === 0) {
|
||
param.business_term = '0'
|
||
} else {
|
||
param.business_term = this.textaa;
|
||
param.business_term = this.formateDate(param.business_term)
|
||
}
|
||
console.log(param);
|
||
|
||
await this.BussinessServiceImpl.bussinessSetBussiness(param)
|
||
}
|
||
|
||
public async httpImage(data: httpRequestImg, type: number) {
|
||
let formData = new FormData()
|
||
formData.append('file', data.file)
|
||
formData.append('file_type', type == 3 ? 'business_license' : 'id_card')
|
||
let res = await this.PublicServiceImpl.uploadFile(formData)
|
||
if(res) {
|
||
if(type === 1) {
|
||
this.fileList1 = [ {
|
||
uid : res.id,
|
||
url : res.path,
|
||
name : '1.png'
|
||
} ]
|
||
}
|
||
if(type === 2) {
|
||
this.fileList2 = [ {
|
||
uid : res.id,
|
||
url : res.path,
|
||
name : '1.png'
|
||
} ]
|
||
}
|
||
if(type === 3) {
|
||
this.fileList3 = [ {
|
||
uid : res.id,
|
||
url : res.path,
|
||
name : '1.png'
|
||
} ]
|
||
}
|
||
}
|
||
}
|
||
}
|