UNPKG

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

Version:

angular webapp : icpc.group.pms

109 lines 8.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var forms_1 = require("@angular/forms"); var ngx_webapp_fx_1 = require("@wjya/ngx-webapp-fx"); var ng_zorro_antd_1 = require("ng-zorro-antd"); var data_source_helper_1 = require("../../../service/data-source.helper"); var wechat_pay_setting_help_modal_1 = require("./wechat-pay-setting-help.modal"); var router_1 = require("@angular/router"); var WechatPaySettingComponent = /** @class */ (function () { function WechatPaySettingComponent(fb, dataSourceHelper, _message, activateRoute, userStorageService) { this.fb = fb; this.dataSourceHelper = dataSourceHelper; this._message = _message; this.activateRoute = activateRoute; this.userStorageService = userStorageService; this.next = new core_1.EventEmitter(); this.confirmApiKey = function (control) { if (!control.value) { return { required: true }; } else if (control.value.length !== 32) { return { length: true, error: true }; } }; this.getWxPayConfigByAppidDataSource = this.dataSourceHelper.getWxPayConfigByAppid; this.saveWxPayConfigByAppidDataSource = this.dataSourceHelper.saveWxPayConfigByAppid; this.validateForm = this.fb.group({ mchId: ['', [forms_1.Validators.required]], apiKey: ['', this.confirmApiKey], }); } WechatPaySettingComponent.prototype.getFormControl = function (name) { return this.validateForm.controls[name]; }; WechatPaySettingComponent.prototype.ngOnInit = function () { this.communityGroupId = this.userStorageService.getCurrentOffice().id; this.appId = this.activateRoute.snapshot.params['appId']; this.loadWxPayConfig(); }; WechatPaySettingComponent.prototype.loadWxPayConfig = function () { var _this = this; this.getWxPayConfigByAppidDataSource.findList({ appId: this.appId }).subscribe(function (res) { _this.validateForm.patchValue(res.body); }); }; WechatPaySettingComponent.prototype.genrate = function () { this.validateForm.patchValue({ apiKey: this.randomApiKey(32) }); }; WechatPaySettingComponent.prototype.save = function (entity) { var _this = this; this.saveWxPayConfigByAppidDataSource.create(null, { communityGroupId: this.communityGroupId, appId: this.appId, mchId: entity.mchId, apiKey: entity.apiKey }).subscribe(function (success) { _this._message.success('保存成功'); }, function (error) { _this._message.error(error.error); }); }; WechatPaySettingComponent.prototype.randomApiKey = function (size) { var characterArr = []; for (var i = 0; i < 26; i++) { characterArr[characterArr.length] = String.fromCharCode(65 + i); characterArr[characterArr.length] = String.fromCharCode(97 + i); } for (var i = 0; i < 10; i++) { characterArr[characterArr.length] = i.toString(); } var characterArrlength = characterArr.length; var createApiKey = ''; for (var i = 0; i < size; i++) { var j = Math.floor(Math.random() * characterArrlength); createApiKey += characterArr[j]; } return createApiKey; }; WechatPaySettingComponent.prototype.readHelp = function () { this.wechatPaySettingHelp.modalIsVisible = true; }; WechatPaySettingComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'zx-wechat-pay-setting', template: "<zx-header-block [title]=\"'\u652F\u4ED8\u8BBE\u7F6E'\" [showBottomLine]=\"false\" [showBreadcrumb]=\"true\" [breadcrumbAppendings]=\"['\u652F\u4ED8\u8BBE\u7F6E']\"><p>\u652F\u4ED8\u8BBE\u7F6E</p></zx-header-block><zx-content-block><ng-template #content><form nz-form [formGroup]=\"validateForm\"><div nz-form-item nz-row><div nz-form-label nz-col><label>\u5FAE\u4FE1\u5546\u6237\u53F7</label></div><div nz-col nz-form-control nzHasFeedback><nz-input formControlName=\"mchId\" [nzPlaceHolder]=\"'\u8BF7\u586B\u5199\u5FAE\u4FE1\u5546\u6237\u53F7'\" [nzSize]=\"'large'\"></nz-input><div nz-form-explain *ngIf=\"getFormControl('mchId').dirty&&getFormControl('mchId').hasError('required')\">\u5FAE\u4FE1\u5546\u6237\u53F7\u662F\u5FC5\u586B\u7684</div><span class=\"tip\"><span>\u5546\u6237\u53F7\u53EF\u4EE5\u70B9\u51FB\u516C\u4F17\u53F7>\u5FAE\u4FE1\u652F\u4ED8\u83DC\u5355\u529F\u80FD\u680F\u67E5\u770B\u3002</span> <a (click)=\"readHelp()\">\u67E5\u770B\u5E2E\u52A9</a></span></div></div><div nz-form-item nz-row><div nz-form-label nz-col><label>\u5FAE\u4FE1\u5546\u6237API\u5BC6\u94A5</label></div><div nz-col nz-form-control><div style=\"width: calc(100% - 92px); display: inline-block; margin-right: 4px;\" nz-form-control nzHasFeedback><nz-input formControlName=\"apiKey\" [nzPlaceHolder]=\"'\u8BF7\u586B\u5199\u5FAE\u4FE1\u5546\u6237API\u5BC6\u94A5'\" [nzSize]=\"'large'\"></nz-input></div><button nz-button [nzType]=\"'default'\" [nzSize]=\"'large'\" style=\"vertical-align: bottom\" (click)=\"genrate()\"><span>\u751F\u6210\u5BC6\u94A5</span></button><div nz-form-explain *ngIf=\"getFormControl('apiKey').dirty&&getFormControl('apiKey').hasError('required')\">\u5FAE\u4FE1\u5546\u6237API\u5BC6\u94A5\u662F\u5FC5\u586B\u7684</div><div nz-form-explain *ngIf=\"getFormControl('apiKey').dirty&&getFormControl('apiKey').hasError('length')\">\u5FAE\u4FE1\u5546\u6237API\u5BC6\u94A5\u5E94\u4E3A32\u4F4D\u5B57\u7B26</div><div class=\"tip\"><span>\u8BF7\u5C06\u5FAE\u4FE1\u5546\u6237API\u5BC6\u94A5\u6309\u5FAE\u4FE1\u8981\u6C42\u914D\u7F6E\u4E0E\u5FAE\u4FE1\u5546\u6237\u4E2D\u3002</span> <a href=\"/docs/ddd.html\" target=\"_blank\">\u64CD\u4F5C\u6307\u5357</a></div><div class=\"tip\" style=\"width: 610px;\">\u5982\u60A8\u7684\u5FAE\u4FE1\u5546\u6237\u8D26\u6237\u5DF2\u7ECF\u8BBE\u7F6E\u8FC7\u5FAE\u4FE1\u5546\u6237API\u5BC6\u94A5\uFF0C\u5219\u5728\u4EE5\u4E0A\u8F93\u5165\u6846\u586B\u5199\u5DF2\u6709\u7684\u5FAE\u4FE1\u5546\u6237API\u5BC6\u94A5\u3002</div></div></div><div class=\"br\"></div><div nz-form-item nz-row style=\"margin-bottom: 0;\"><button nz-button class=\"login-form-button\" [nzType]=\"'primary'\" (click)=\"save(validateForm.value)\" [disabled]=\"!validateForm.valid\">\u4FDD\u5B58</button></div></form></ng-template></zx-content-block><zx-wechat-pay-setting-help #wechatPaySettingHelp></zx-wechat-pay-setting-help>", 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:130px;\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 .tip > a{\n float:right;\n }\n " ] },] }, ]; /** @nocollapse */ WechatPaySettingComponent.ctorParameters = function () { return [ { type: forms_1.FormBuilder, }, { type: data_source_helper_1.DataSourceHelper, }, { type: ng_zorro_antd_1.NzMessageService, }, { type: router_1.ActivatedRoute, }, { type: ngx_webapp_fx_1.UserStorageService, }, ]; }; WechatPaySettingComponent.propDecorators = { "wechatPaySettingHelp": [{ type: core_1.ViewChild, args: ['wechatPaySettingHelp',] },], "next": [{ type: core_1.Output },], }; return WechatPaySettingComponent; }()); exports.WechatPaySettingComponent = WechatPaySettingComponent; //# sourceMappingURL=wechat-pay-setting.component.js.map