@wjya/ngx-webapp-icpc.group.pms
Version:
angular webapp : icpc.group.pms
260 lines • 20.9 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ngx_utils_1 = require("@wjya/ngx-utils");
var core_1 = require("@angular/core");
var forms_1 = require("@angular/forms");
var ngx_webapp_fx_1 = require("@wjya/ngx-webapp-fx");
var data_source_helper_1 = require("../../service/data-source.helper");
var register_agreement_modal_1 = require("./register-agreement.modal");
var router_1 = require("@angular/router");
var RegisterComponent = /** @class */ (function () {
function RegisterComponent(fb, dataSourceHelper, authServerProvider, loginService, router, activatedRoute) {
var _this = this;
this.fb = fb;
this.dataSourceHelper = dataSourceHelper;
this.authServerProvider = authServerProvider;
this.loginService = loginService;
this.router = router;
this.activatedRoute = activatedRoute;
this.next = new core_1.EventEmitter();
this.modalIsVisible = false;
this.options = [];
this.myreg = new RegExp('^[1][3,4,5,7,8][0-9]{9}$');
this.accountReg = new RegExp('^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]+$');
this.fileList = [];
this.fileList1 = [];
this.previewImage = '';
this.previewVisible = false;
this.number = null;
this.isClick = false;
this.SMS_TOKEN = '550389ae875f3d184b6cea1583623476311c354e';
this.verificationCodeError = 'hidden';
this.accountError = 'hidden';
this.t = null;
this.confirmCheckPassword = function (control) {
if (!control.value) {
return { required: true };
}
else if (control.value !== _this.validateForm.controls.password.value) {
return { confirm: true, error: true };
}
};
this.confirmAccount = function (control) {
if (!control.value) {
return { required: true };
}
else if (!_this.accountReg.test(control.value)) {
return { confirm: true, error: true };
}
else if (control.value.length < 8) {
return { length: true, error: true };
}
};
this.confirmName = function (control) {
if (!control.value) {
return { required: true };
}
else if (control.value.length > 8) {
return { length: true, error: true };
}
};
this.confirmPhone = function (control) {
if (!control.value) {
return { required: true };
}
else if (!_this.myreg.test(control.value)) {
return { length: true, error: true };
}
};
this.confirmCode = function (control) {
if (!control.value) {
return { required: true };
}
else if (control.value.length !== 6) {
return { length: true, error: true };
}
};
this.confirmChecked = function (control) {
if (!control.value) {
return { required: true };
}
};
this.handlePreview = function (file) {
_this.previewImage = file.url || file.thumbUrl;
_this.previewVisible = true;
};
this.removeLogoPhoto = function (file) {
if (file.status === 'removed') {
_this.validateForm.patchValue({ logo: null });
}
return true;
};
this.removeIconPhoto = function (file) {
if (file.status === 'removed') {
_this.validateForm.patchValue({ icon: null });
}
return true;
};
this.registerType = this.activatedRoute.snapshot.data[0]['registerType'];
// if (this.registerType === 'propertyCompany') {
// }
this.dataSource = this.dataSourceHelper.communityGroupAccountRegister;
this.sendVerificationCodeDataSource = this.dataSourceHelper.sendVerificationCode;
this.partnerAccountRegisterDataSource = this.dataSourceHelper.partnerAccountRegister;
this.validateForm = this.fb.group({
name: [null, [forms_1.Validators.required]],
logo: [null],
icon: [null],
account: [null, this.confirmAccount],
password: [null, this.confirmAccount],
checkPassword: [null, this.confirmCheckPassword],
contactName: [null, this.confirmName],
contactPhone: [null, this.confirmPhone],
verificationCode: [null, this.confirmCode],
checked: [null, this.confirmChecked]
});
}
RegisterComponent.prototype.getFormControl = function (name) {
return this.validateForm.controls[name];
};
RegisterComponent.prototype.ngOnInit = function () {
};
RegisterComponent.prototype.handleCancel = function () {
this.modalIsVisible = false;
};
RegisterComponent.prototype.resetForm = function () {
this.validateForm.reset();
for (var _i = 0, _a = Object.keys(this.validateForm.controls); _i < _a.length; _i++) {
var key = _a[_i];
this.validateForm.controls[key].markAsPristine();
}
};
RegisterComponent.prototype.register = function (entity) {
var _this = this;
if (this.registerType === 'propertyCompany') {
this.dataSource.create(entity).subscribe(function (success) {
if (!success.body.success) {
if (success.body.accountError) {
_this.accountError = 'show';
}
else if (success.body.verificationCodeError) {
_this.verificationCodeError = 'show';
}
}
else {
_this.loginService.login({
username: _this.validateForm.controls['account'].value,
password: _this.validateForm.controls['password'].value,
rememberMe: true,
grant_type: 'password'
}).then(function () {
_this.next.emit();
});
}
});
}
else if (this.registerType === 'cityPartner') {
this.partnerAccountRegisterDataSource.create(entity).subscribe(function (success) {
if (!success.body.success) {
if (success.body.accountError) {
_this.accountError = 'show';
}
else if (success.body.verificationCodeError) {
_this.verificationCodeError = 'show';
}
}
else {
_this.loginService.login({
username: _this.validateForm.controls['account'].value,
password: _this.validateForm.controls['password'].value,
rememberMe: true,
grant_type: 'password'
}).then(function () {
_this.next.emit();
});
}
});
}
};
Object.defineProperty(RegisterComponent.prototype, "isDisabled", {
get: function () {
if (this.isClick) {
return true;
}
if (this.myreg.test(this.validateForm.controls['contactPhone'].value)) {
return false;
}
return true;
},
enumerable: true,
configurable: true
});
RegisterComponent.prototype.getAuthToken = function () {
return this.authServerProvider.getToken();
};
RegisterComponent.prototype.getLogoStatus = function (e) {
if (e.file.status === 'done') {
this.validateForm.patchValue({ logo: e.file.response.info.md5 });
}
};
RegisterComponent.prototype.getIconStatus = function (e) {
if (e.file.status === 'done') {
this.validateForm.patchValue({ icon: e.file.response.info.md5 });
}
};
RegisterComponent.prototype.getVerifyCode = function () {
var _this = this;
this.sendVerificationCodeDataSource.findList({
mobile: this.validateForm.controls['contactPhone'].value,
time: new Date().getTime(),
token: ngx_utils_1.convertMd5.hex_md5(this.validateForm.controls['contactPhone'].value + new Date().getTime() + this.SMS_TOKEN)
}).subscribe(function (success) {
_this.isClick = true;
_this.number = 60;
_this.t = setInterval(function () {
_this.number--;
if (_this.number <= 0) {
clearInterval(_this.t);
_this.t = null;
_this.number = null;
_this.isClick = false;
}
}, 1000);
});
};
RegisterComponent.prototype.readRegisterAgreement = function () {
this.registerAgreement.modalIsVisible = true;
};
RegisterComponent.prototype.ngOnDestroy = function () {
clearInterval(this.t);
this.t = null;
};
RegisterComponent.prototype.back = function () {
this.router.navigate(['/login']);
};
RegisterComponent.decorators = [
{ type: core_1.Component, args: [{
selector: 'zx-register',
template: "<form nz-form [formGroup]=\"validateForm\"><div class=\"title\">{{registerType === 'propertyCompany' ? '\u96C6\u56E2\u4FE1\u606F' : '\u57CE\u5E02\u5408\u4F19\u4EBA\u4FE1\u606F'}}</div><div nz-form-item nz-row><div nz-form-label nz-col><label nz-form-item-required>\u4F01\u4E1A\u540D\u79F0</label></div><div nz-col nz-form-control nzHasFeedback><nz-input formControlName=\"name\" [nzPlaceHolder]=\"'\u8BF7\u586B\u5199\u4F01\u4E1A\u540D\u79F0'\" [nzSize]=\"'large'\"></nz-input><div nz-form-explain *ngIf=\"getFormControl('name').dirty&&getFormControl('name').hasError('required')\">\u4F01\u4E1A\u540D\u79F0\u662F\u5FC5\u586B\u7684</div><span class=\"tip\">\u8BF7\u5728\u8F93\u5165\u6846\u586B\u5199\u4F01\u4E1A\u5168\u79F0</span></div></div><div nz-form-item nz-row><div nz-form-label nz-col><label>\u4F01\u4E1Alogo</label></div><div nz-col nz-form-control nzHasFeedback class=\"logo\"><nz-upload [nzAction]=\"'/base/api/_public/picture/upload'\" nzListType=\"picture-card\" [(nzFileList)]=\"fileList\" [nzShowButton]=\"fileList.length < 1\" [nzPreview]=\"handlePreview\" (nzChange)=\"getLogoStatus($event)\" [nzRemove]=\"removeLogoPhoto\"><i class=\"anticon anticon-plus\"></i></nz-upload><div class=\"tip\">\u8BF7\u4E0A\u4F20\u5C3A\u5BF8\u4E3A200px*48px\u7684\u4F01\u4E1Alogo\uFF0Clogo\u53F3\u4FA7\u6587\u5B57\u63A8\u8350\u4F7F\u7528\u767D\u8272</div><nz-modal [nzVisible]=\"previewVisible\" [nzContent]=\"modalContent\" [nzFooter]=\"null\" (nzOnCancel)=\"previewVisible=false\"><ng-template #modalContent><img [src]=\"previewImage\" [ngStyle]=\"{ 'width': '100%' }\"/></ng-template></nz-modal></div></div><div nz-form-item nz-row><div nz-form-label nz-col><label>\u4F01\u4E1A\u56FE\u6807</label></div><div nz-col nz-form-control nzHasFeedback class=\"icon\"><nz-upload [nzAction]=\"'/base/api/_public/picture/upload'\" nzListType=\"picture-card\" [(nzFileList)]=\"fileList1\" [nzShowButton]=\"fileList1.length < 1\" [nzPreview]=\"handlePreview\" (nzChange)=\"getIconStatus($event)\" [nzRemove]=\"removeIconPhoto\"><i class=\"anticon anticon-plus\"></i></nz-upload><div class=\"tip\">\u8BF7\u4E0A\u4F20\u5C3A\u5BF8\u4E3A48px*48px\u7684\u4F01\u4E1A\u56FE\u6807</div></div></div><div class=\"br\"></div><div class=\"title\">\u767B\u9646\u8D26\u53F7</div><div nz-form-item nz-row><div nz-form-label nz-col><label nz-form-item-required>\u4F01\u4E1A\u8D26\u53F7</label></div><div nz-col nz-form-control nzHasFeedback><nz-input formControlName=\"account\" [nzPlaceHolder]=\"'\u8BF7\u586B\u5199\u767B\u9646\u8D26\u53F7'\" [nzSize]=\"'large'\" (ngModelChange)=\"accountError = 'hidden'\"></nz-input><div nz-form-explain *ngIf=\"getFormControl('account').dirty&&getFormControl('account').hasError('required')\">\u4F01\u4E1A\u8D26\u53F7\u662F\u5FC5\u586B\u7684</div><div nz-form-explain *ngIf=\"getFormControl('account').dirty&&getFormControl('account').hasError('confirm')\">\u8D26\u53F7\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u586B\u5199\u6B63\u786E\u683C\u5F0F</div><div nz-form-explain *ngIf=\"getFormControl('account').dirty&&getFormControl('account').hasError('length')\">\u8D26\u53F7\u957F\u5EA6\u4E0D\u8DB38\u4F4D</div><div nz-form-explain *ngIf=\"accountError === 'show'\" style=\"color: #f04134\">\u8D26\u53F7\u5DF2\u7ECF\u5B58\u5728</div><span class=\"tip\">\u8D26\u6237\u5FC5\u987B\u7531\u5B57\u6BCD\u3001\u6570\u5B57\u7EC4\u6210\uFF0C\u6700\u77ED8\u4F4D\uFF0C\u533A\u5206\u5927\u5C0F\u5199</span></div></div><div nz-form-item nz-row><div nz-form-label nz-col><label nz-form-item-required>\u767B\u9646\u5BC6\u7801</label></div><div nz-col nz-form-control nzHasFeedback><nz-input formControlName=\"password\" [nzPlaceHolder]=\"'\u8BF7\u586B\u5199\u767B\u9646\u5BC6\u7801'\" [nzSize]=\"'large'\" [nzType]=\"'password'\"></nz-input><div nz-form-explain *ngIf=\"getFormControl('password').dirty&&getFormControl('password').hasError('required')\">\u786E\u8BA4\u5BC6\u7801\u662F\u5FC5\u586B\u7684</div><div nz-form-explain *ngIf=\"getFormControl('password').dirty&&getFormControl('password').hasError('confirm')\">\u5BC6\u7801\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u586B\u5199\u6B63\u786E\u683C\u5F0F</div><div nz-form-explain *ngIf=\"getFormControl('password').dirty&&getFormControl('password').hasError('length')\">\u5BC6\u7801\u957F\u5EA6\u4E0D\u8DB38\u4F4D</div><span class=\"tip\">\u767B\u9646\u5BC6\u7801\u5FC5\u987B\u7531\u5B57\u6BCD\u3001\u6570\u5B57\u7EC4\u6210\uFF0C\u6700\u77ED8\u4F4D\uFF0C\u533A\u5206\u5927\u5C0F\u5199</span></div></div><div nz-form-item nz-row><div nz-form-label nz-col><label nz-form-item-required>\u786E\u8BA4\u5BC6\u7801</label></div><div nz-col nz-form-control nzHasFeedback><nz-input formControlName=\"checkPassword\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u786E\u8BA4\u5BC6\u7801'\" [nzSize]=\"'large'\" [nzType]=\"'password'\"></nz-input><div nz-form-explain *ngIf=\"getFormControl('checkPassword').dirty&&getFormControl('checkPassword').hasError('required')\">\u786E\u8BA4\u5BC6\u7801\u662F\u5FC5\u586B\u7684</div><div nz-form-explain *ngIf=\"getFormControl('checkPassword').dirty&&getFormControl('checkPassword').hasError('confirm')\">\u4E24\u6B21\u8F93\u5165\u7684\u5BC6\u7801\u4E0D\u4E00\u81F4</div><span class=\"tip\">\u8BF7\u5728\u518D\u6B21\u8F93\u5165\u5BC6\u7801</span></div></div><div class=\"br\"></div><div class=\"title\">\u8054\u7CFB\u4EBA\u4FE1\u606F</div><div nz-form-item nz-row><div nz-form-label nz-col><label nz-form-item-required>\u8054\u7CFB\u4EBA\u59D3\u540D</label></div><div nz-col nz-form-control nzHasFeedback><nz-input formControlName=\"contactName\" [nzPlaceHolder]=\"'\u8BF7\u586B\u5199\u7BA1\u7406\u5458\u59D3\u540D'\" [nzSize]=\"'large'\"></nz-input><div nz-form-explain *ngIf=\"getFormControl('contactName').dirty&&getFormControl('contactName').hasError('required')\">\u7BA1\u7406\u5458\u59D3\u540D\u662F\u5FC5\u586B\u7684</div><div nz-form-explain *ngIf=\"getFormControl('contactName').dirty&&getFormControl('contactName').hasError('length')\">\u7BA1\u7406\u5458\u59D3\u540D\u957F\u5EA6\u8D85\u8FC78\u4F4D</div><span class=\"tip\">\u6700\u957F8\u4F4D</span></div></div><div nz-form-item nz-row><div nz-form-label nz-col><label nz-form-item-required>\u8054\u7CFB\u4EBA\u624B\u673A</label></div><div nz-col nz-form-control><div style=\"width: calc(100% - 106px); display: inline-block; margin-right: 4px;\" nz-form-control nzHasFeedback><nz-input formControlName=\"contactPhone\" [nzPlaceHolder]=\"'\u8BF7\u586B\u5199\u8054\u7CFB\u7535\u8BDD'\" [nzSize]=\"'large'\" [nzType]=\"'number'\"></nz-input></div><button nz-button [nzType]=\"'default'\" [nzSize]=\"'large'\" style=\"vertical-align: bottom;width: 102px\" [disabled]=\"isDisabled\" (click)=\"getVerifyCode()\"><span>{{number ? number : '\u83B7\u53D6\u9A8C\u8BC1\u7801'}}</span></button><div nz-form-explain *ngIf=\"getFormControl('contactPhone').dirty&&getFormControl('contactPhone').hasError('required')\">\u8054\u7CFB\u4EBA\u624B\u673A\u662F\u5FC5\u586B\u7684</div><div nz-form-explain *ngIf=\"getFormControl('contactPhone').dirty&&getFormControl('contactPhone').hasError('length')\">\u7535\u8BDD\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u586B\u5199\u6B63\u786E\u683C\u5F0F</div><span class=\"tip\">\u8BF7\u8F93\u516511\u4F4D\u624B\u673A\u53F7\u7801</span></div></div><div nz-form-item nz-row><div nz-form-label nz-col><label nz-form-item-required>\u9A8C\u8BC1\u7801</label></div><div nz-col nz-form-control><nz-input formControlName=\"verificationCode\" [nzPlaceHolder]=\"'\u8BF7\u586B\u5199\u9A8C\u8BC1\u7801'\" [nzSize]=\"'large'\" [nzType]=\"'number'\" (ngModelChange)=\"verificationCodeError = 'hidden'\"></nz-input><div nz-form-explain *ngIf=\"getFormControl('verificationCode').dirty&&getFormControl('verificationCode').hasError('required')\">\u9A8C\u8BC1\u7801\u662F\u5FC5\u586B\u7684</div><div nz-form-explain *ngIf=\"verificationCodeError === 'show'\" style=\"color: #f04134\">\u9A8C\u8BC1\u7801\u9519\u8BEF</div><div nz-form-explain *ngIf=\"getFormControl('verificationCode').dirty&&getFormControl('verificationCode').hasError('length')\">\u9A8C\u8BC1\u7801\u5E94\u4E3A6\u4F4D\u6570\u5B57</div><span class=\"tip\">\u8BF7\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801</span></div></div><div class=\"br\"></div><div nz-row style=\"margin-bottom: 24px;\"><div nz-col nz-form-control><label nz-checkbox formControlName=\"checked\" nz-form-item-required><span style=\"vertical-align: middle\">\u6211\u540C\u610F\u5E76\u9075\u5B88</span></label> <a style=\"vertical-align: middle\" (click)=\"readRegisterAgreement()\">\u300A\u6211\u5BB6\u4E91\u667A\u6167\u793E\u533A\u7BA1\u7406\u5E73\u53F0\u670D\u52A1\u534F\u8BAE\u300B</a></div></div><div nz-form-item nz-row><button nz-button class=\"login-form-button\" [nzType]=\"'primary'\" (click)=\"register(validateForm.value)\" [disabled]=\"!validateForm.valid\">{{registerType === 'propertyCompany' ? '\u6CE8 \u518C' : '\u63D0\u4EA4\u7533\u8BF7'}}</button> <button nz-button class=\"login-form-button\" [nzType]=\"'default'\" (click)=\"back()\">\u8FD4 \u56DE</button></div></form><zx-register-agreement #registerAgreement></zx-register-agreement>",
styles: [
"\n :host .br {\n height: 1px;\n width: 100%;\n margin: 30px 0;\n border-top: 1px dashed #ddd;\n }\n :host ::ng-deep .ant-form-item-label{\n width:100px;\n float:left;\n }\n :host ::ng-deep .ant-form-item-control-wrapper{\n width:500px;\n float:left;\n }\n :host .title{\n font-size: 16px;\n font-weight: bold;\n margin-bottom: 12px;\n }\n :host .tip{\n color:#c0c0c0;\n }\n :host ::ng-deep .logo .ant-upload.ant-upload-select-picture-card{\n width:200px;\n height:48px;\n line-height: 0px;\n }\n :host ::ng-deep .icon .ant-upload.ant-upload-select-picture-card{\n width:48px;\n height:48px;\n line-height: 0px;\n }\n :host ::ng-deep .logo .ant-upload-list-picture-card .ant-upload-list-item{\n float: none;\n width: 218px;\n height: 66px;\n }\n :host ::ng-deep .icon .ant-upload-list-picture-card .ant-upload-list-item{\n float: none;\n width: 66px;\n height: 66px;\n }\n "
]
},] },
];
/** @nocollapse */
RegisterComponent.ctorParameters = function () { return [
{ type: forms_1.FormBuilder, },
{ type: data_source_helper_1.DataSourceHelper, },
{ type: ngx_webapp_fx_1.AuthServerProvider, },
{ type: ngx_webapp_fx_1.LoginService, },
{ type: router_1.Router, },
{ type: router_1.ActivatedRoute, },
]; };
RegisterComponent.propDecorators = {
"next": [{ type: core_1.Output },],
"registerAgreement": [{ type: core_1.ViewChild, args: ['registerAgreement',] },],
};
return RegisterComponent;
}());
exports.RegisterComponent = RegisterComponent;
//# sourceMappingURL=register.component.js.map