UNPKG

@wjya/ngx-webapp-icpc.group.pms

Version:

angular webapp : icpc.group.pms

159 lines 11 kB
"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 data_source_helper_1 = require("../../service/data-source.helper"); var ng_zorro_antd_1 = require("ng-zorro-antd"); var router_1 = require("@angular/router"); var PersonalComponent = /** @class */ (function () { function PersonalComponent(fb, dataSourceHelper, _message, router) { var _this = this; this.fb = fb; this.dataSourceHelper = dataSourceHelper; this._message = _message; this.router = router; 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.number = null; this.isClick = false; this.SMS_TOKEN = '550389ae875f3d184b6cea1583623476311c354e'; this.verificationCodeError = false; 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.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.dataSource = this.dataSourceHelper.personalResetPassword; this.sendVerificationCodeDataSource = this.dataSourceHelper.sendVerificationCode; this.validateForm = this.fb.group({ password: [null, this.confirmAccount], checkPassword: [null, this.confirmCheckPassword], contactPhone: [null, this.confirmPhone], verificationCode: [null, this.confirmCode], }); } PersonalComponent.prototype.getFormControl = function (name) { return this.validateForm.controls[name]; }; PersonalComponent.prototype.ngOnInit = function () { }; PersonalComponent.prototype.handleCancel = function () { this.modalIsVisible = false; }; PersonalComponent.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(); } }; Object.defineProperty(PersonalComponent.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 }); PersonalComponent.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); }); }; PersonalComponent.prototype.resetPassword = function (entity) { var _this = this; this.dataSource.create(null, { contactPhone: entity.contactPhone, password: entity.password, verificationCode: entity.verificationCode }).subscribe(function (success) { _this._message.success('修改成功'); }, function (error) { _this._message.error('修改失败'); }); }; PersonalComponent.prototype.back = function () { this.router.navigate(['/login']); }; PersonalComponent.prototype.ngOnDestroy = function () { clearInterval(this.t); this.t = null; }; PersonalComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'zx-personal', template: "<form nz-form [formGroup]=\"validateForm\" style=\"margin-top: 20px;\"><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=\"overflow: hidden;\"><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><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><div class=\"tip\">\u8BF7\u8F93\u516511\u4F4D\u624B\u673A\u53F7\u7801</div></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'\"></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=\"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 nz-form-item nz-row><div nz-form-label nz-col><label nz-form-item-required>\u65B0\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\">\u5B57\u6BCD\u3001\u6570\u5B57\u6216\u8005\u82F1\u6587\u7B26\u53F7\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\u518D\u6B21\u8F93\u5165\u5BC6\u7801</span></div></div><div class=\"br\"></div><div nz-form-item nz-row><button nz-button class=\"login-form-button\" [nzType]=\"'primary'\" (click)=\"resetPassword(validateForm.value)\" [disabled]=\"!validateForm.valid\">\u63D0 \u4EA4</button> <button nz-button class=\"login-form-button\" [nzType]=\"'default'\" (click)=\"back()\">\u8FD4 \u56DE</button></div></form>", 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 " ] },] }, ]; /** @nocollapse */ PersonalComponent.ctorParameters = function () { return [ { type: forms_1.FormBuilder, }, { type: data_source_helper_1.DataSourceHelper, }, { type: ng_zorro_antd_1.NzMessageService, }, { type: router_1.Router, }, ]; }; PersonalComponent.propDecorators = { "next": [{ type: core_1.Output },], }; return PersonalComponent; }()); exports.PersonalComponent = PersonalComponent; //# sourceMappingURL=personal.component.js.map