(function (vc) { vc.extends({ data: { addCommunityWechatInfo: { weChatId: '', name: '', appId: '', appSecret: '', payPassword: '1', objType: '1000', objId: '', mchId: '1', mchName: '1', remarks: '', objTypes: '', types: '', weChatType: '', certPath: '' } }, _initMethod: function () { vc.getDict('small_wechat', "obj_type", function (_data) { $that.addCommunityWechatInfo.objTypes = _data; }); vc.getDict('small_wechat', "wechat_type", function (_data) { $that.addCommunityWechatInfo.types = _data; }); }, _initEvent: function () { vc.on('addCommunityWechat', 'openAddCommunityWechatModal', function (_param) { vc.copyObject(_param,$that.addCommunityWechatInfo); $('#addCommunityWechatModel').modal('show'); }); }, methods: { addCommunityWechatValidate() { return vc.validate.validate({ addCommunityWechatInfo: $that.addCommunityWechatInfo }, { 'addCommunityWechatInfo.name': [ { limit: "required", param: "", errInfo: "名称不能为空" }, { limit: "maxIn", param: "1,100", errInfo: "名称不能超过100位" } ], 'addCommunityWechatInfo.appId': [ { limit: "required", param: "", errInfo: "appId不能为空" }, { limit: "maxin", param: "1,100", errInfo: "appId不能超过100位" } ], }); }, saveCommunityWeChatInfo: function () { if (!$that.addCommunityWechatValidate()) { vc.toast(vc.validate.errInfo); return; } vc.http.apiPost( '/smallWeChat.saveAdminSmallWeChat', JSON.stringify($that.addCommunityWechatInfo), { emulateJSON: true }, function (json, res) { //vm.menus = vm.refreshMenuActive(JSON.parse(json),0); let _json = JSON.parse(json) if (_json.code == '0') { //关闭model $('#addCommunityWechatModel').modal('hide'); $that.clearAddCommunityWechatInfo(); vc.emit('communityWechat', 'listSmallWeChat', {}); vc.emit('communityMini', 'listSmallWeChat', {}); vc.toast("添加成功"); return; } else { vc.toast(_json.msg); } }, function (errInfo, error) { console.log('请求失败处理'); vc.message(errInfo); }); }, clearAddCommunityWechatInfo: function () { $that.addCommunityWechatInfo = { weChatId: '', name: '', appId: '', appSecret: '', payPassword: '1', objType: '', objId: '', mchId: '1', mchName: '1', weChatType: '', types: $that.addCommunityWechatInfo.types, remarks: '', objTypes: $that.addCommunityWechatInfo.objTypes, certPath: '', }; }, getObjType: function () { } } }); })(window.vc);