MWF.xDesktop.requireApp("Setting", "Document", null, false); MWF.xApplication.Setting.MobileConnectDocument = new Class({ Extends: MWF.xApplication.Setting.Document, load: function () { this.node = new Element("div", { "styles": { "overflow": "hidden", "padding-bottom": "80px" } }).inject(this.contentAreaNode); this.titleName = new Element("div", { "styles": this.explorer.css.explorerContentTitleNode }).inject(this.node); this.titleName.set("text", this.lp.mobile_connectSetting); var o2CloudConnected = false; this.actions.collectConnected(function (json) { o2CloudConnected = json.data.value; }.bind(this), function (json) { o2CloudConnected = false; }.bind(this), false); this.mobileO2CloudConnectInput = new MWF.xApplication.Setting.Document.Button(this.explorer, this.node, { "lp": { "title": this.lp.mobile_connectO2Cloud, "infor": this.mobile_connectO2Cloud_infor, "action": this.lp.mobile_connectO2Cloud_action }, //"data": {"key": "proxyData", "valueKey": "ssos", "notEmpty": false }, "value": o2CloudConnected ? this.lp.mobile_connectO2Cloud_success : this.lp.mobile_connectO2Cloud_error, "itemTitle": o2CloudConnected ? this.lp.mobile_connectO2Cloud_success : this.lp.mobile_connectO2Cloud_error, "icon": o2CloudConnected ? "cloud.png" : "cloud_error.png", "action": function (e) { layout.desktop.openApplication(e, "Collect"); }.bind(this) }); this.mobileHttpProtocolInput = new MWF.xApplication.Setting.Document.Select(this.explorer, this.node, { "lp": { "title": this.lp.mobile_httpProtocol, "infor": this.lp.mobile_httpProtocol_infor }, "data": { "key": "proxyData", "valueKey": "httpProtocol" }, "value": this.explorer.proxyData.httpProtocol, "options": [{ "value": "http", "text": "http" }, { "value": "https", "text": "https" }] }); this.mobileCenterInput = new MWF.xApplication.Setting.Document.List(this.explorer, this.node, { "lp": { "title": this.lp.mobile_center, "infor": this.lp.mobile_center_infor, "editAction": this.lp.mobile_center_action }, "data": { "key": "proxyData", "valueKey": "center", "notEmpty": false }, "value": this.explorer.proxyData.center, "itemTitle": "{proxyHost}:{proxyPort}", "icon": "center.png" }); this.mobileWebInput = new MWF.xApplication.Setting.Document.List(this.explorer, this.node, { "lp": { "title": this.lp.mobile_web, "infor": this.lp.mobile_web_infor, "editAction": this.lp.mobile_web_action }, "data": { "key": "proxyData", "valueKey": "web", "notEmpty": false }, "value": this.explorer.proxyData.web, "itemTitle": "{proxyHost}:{proxyPort}", "icon": "webserver.png" }); this.mobileApplicationInput = new MWF.xApplication.Setting.Document.List(this.explorer, this.node, { "lp": { "title": this.lp.mobile_application, "infor": this.lp.mobile_application_infor, "editAction": this.lp.mobile_application_action }, "data": { "key": "proxyData", "valueKey": "applicationList", "notEmpty": false }, "value": this.explorer.proxyData.applicationList, "itemTitle": "{proxyHost}:{proxyPort}", "readonly": ["node"], "icon": "server.png" }); } }); MWF.xApplication.Setting.MobileModuleDocument = new Class({ Extends: MWF.xApplication.Setting.Document, load: function () { this.node = new Element("div", { "styles": { "overflow": "hidden", "padding-bottom": "80px" } }).inject(this.contentAreaNode); this.titleName = new Element("div", { "styles": this.explorer.css.explorerContentTitleNode }).inject(this.node); this.titleName.set("text", this.lp.mobile_moduleSetting); var options = [{ "value": "", "text": this.lp.mobile_index_defalue }]; if (this.explorer.portalData.portalList && this.explorer.portalData.portalList.length) { this.explorer.portalData.portalList.each(function (portal) { options.push({ "value": portal.id, "text": portal.name }); }.bind(this)); } this.mobileIndexInput = new MWF.xApplication.Setting.Document.Select(this.explorer, this.node, { "lp": { "title": this.lp.mobile_index, "infor": this.lp.mobile_index_infor }, "data": { "key": "nativeData", "valueKey": "indexPortal" }, "value": this.explorer.nativeData.indexPortal, "options": options }); //移动端简易模式 var simpleModeTitle = this.lp.mobile_module_simple_mode; var simpleModeInfor = this.lp.mobile_module_simple_mode_infor; new MWF.xApplication.Setting.Document.Check(this.explorer, this.node, { "lp": { "title": simpleModeTitle, "infor": simpleModeInfor }, "data": { "key": "nativeData", "valueKey": "simpleMode", "notEmpty": false }, "value": this.explorer.nativeData.simpleMode }); // app通讯录权限视图 var contactPermissionViewTitle = this.lp.mobile_module_contact_permission_view; var contactPermissionViewInfor = this.lp.mobile_module_contact_permission_view_infor; new MWF.xApplication.Setting.Document.Input(this.explorer, this.node, { "lp": { "title": contactPermissionViewTitle, "infor": contactPermissionViewInfor, "action": this.lp.mobile_module_contact_permission_view_action}, "data": { "key": "nativeData", "valueKey": "contactPermissionView", "notEmpty": false }, "value": this.explorer.nativeData.contactPermissionView || "addressPowerView" // 默认视图名 addressPowerView }); //显示系统通知 var systemMessageSwitchTitle = this.lp.mobile_module_system_message_switch; var systemMessageSwitchInfor = this.lp.mobile_module_system_message_switch_infor; new MWF.xApplication.Setting.Document.Check(this.explorer, this.node, { "lp": { "title": systemMessageSwitchTitle, "infor": systemMessageSwitchInfor }, "data": { "key": "nativeData", "valueKey": "systemMessageSwitch", "notEmpty": false }, "value": this.explorer.nativeData.systemMessageSwitch }); this.explorer.nativeData.nativeAppList.each(function (app, i) { var title = this.lp.mobile_module.replace("{name}", app.name); var infor = this.lp.mobile_module_infor.replace("{name}", app.name); new MWF.xApplication.Setting.Document.Check(this.explorer, this.node, { "lp": { "title": title, "infor": infor }, "data": { "key": "nativeData", "valueKey": "nativeAppList." + i + ".enable", "notEmpty": false }, "value": app.enable }); }.bind(this)); } }); // app在线打包功能 MWF.xApplication.Setting.AppPackOnlineDocument = new Class({ Extends: MWF.xApplication.Setting.Document, load: function () { var cssurl = "../x_component_Setting/$Main/default/apppack/index.css"; var htmlurl = "../x_component_Setting/$Main/default/apppack/index.html"; this.contentAreaNode.loadAll({ "css": [cssurl], "html": [htmlurl] }, { "bind": { "lp": this.lp, "data": {} }, "module": this }, function () { this.node = this.apppackBoxNode; this.checkConnectAppPackServer(); }.bind(this)); }, // 检查app打包服务器连接情况,包括是否已经登录O2云 checkConnectAppPackServer: function () { o2.Actions.load("x_program_center").AppPackAction.connect(function(json){ if (json && json.data) { var data = json.data if (data.status === 1001) { // 成功 获取token this.token = data.token; this.packServerUrl = data.packServerUrl; this.apppackErrorMsgNode.setStyles({ "display": "none" }); this.loadAppPackInfo(); } else if (data.status === 1) { // o2云未连接 o2云未启用 this.showErrorMsg(this.lp.mobile_apppack_message_o2cloud_not_enable); // this.app.notice(this.lp.mobile_apppack_message_o2cloud_not_enable, "error", this.contentAreaNode); } else if (data.status === 2) { // o2云未登录 // this.app.notice(this.lp.mobile_apppack_message_o2cloud_not_login, "error", this.contentAreaNode); this.showErrorMsg(this.lp.mobile_apppack_message_o2cloud_not_login); } else if (data.status === 3) { // 打包服务器未认证通过 // this.app.notice(this.lp.mobile_apppack_message_apppack_server_login_fail, "error", this.contentAreaNode); this.showErrorMsg(this.lp.mobile_apppack_message_apppack_server_login_fail); } } else { // this.app.notice(this.lp.mobile_apppack_message_check_connect_fail, "error", this.contentAreaNode); this.showErrorMsg(this.lp.mobile_apppack_message_check_connect_fail); } }.bind(this)); }, // 加载最近一次打包信息 loadAppPackInfo: function () { this.showLoading(); o2.Actions.load("x_program_center").AppPackAction.packInfo(this.token, function(json){ this.hiddenLoading(); if (json && json.type === "success") { this.packInfo = json.data; this.showPackInfoDetail(); } else { console.log("查询打包信息失败。。。") this.loadConfigProxy(); } }.bind(this), function(err){ console.log("错误拉,没有找到打包信息!"); console.log(err); this.hiddenLoading(); this.loadConfigProxy(); }.bind(this)); }, showLoading: function() { if (this.packLoadingNode) { this.hiddenLoading(); } this.packLoadingNode = new Element("div", { "class": "pack-loading" }).inject(this.apppackBoxNode); new Element("div", {"text": "Loading......"}).inject(this.packLoadingNode); }, hiddenLoading: function() { if (this.packLoadingNode) { this.packLoadingNode.destroy(); this.packLoadingNode = null; } }, // 显示错误信息 showErrorMsg: function(msg) { this.apppackErrorMsgNode.set("text", msg); this.apppackErrorMsgNode.setStyles({ "display": "" }); }, // 显示提交表单 showForm: function() { this.apppackShowBodyNode.setStyles({ "display": "none" }); this.apppackFormBodyNode.setStyles({ "display": "" }); this.apppackBtnNode.addEvents({ "click": function(e) { this.submitPack(); }.bind(this) }) }, // 显示打包详情 showPackInfoDetail: function () { if (this.packInfo) { this.apppackAppNameShowNode.set("text", this.packInfo.appName); this.apppackProtocolShowNode.set("text", this.packInfo.o2ServerProtocol); this.apppackHostShowNode.set("text", this.packInfo.o2ServerHost); this.apppackPortShowNode.set("text", this.packInfo.o2ServerPort); this.apppackContextShowNode.set("text", this.packInfo.o2ServerContext); this.apppackAppVersionNameShowNode.set("text", this.packInfo.versionName); this.apppackAppBuildNoShowNode.set("text", this.packInfo.buildNo); this.apppackUrlMappingShowNode.set("text", this.packInfo.urlMapping); var isPackAppIdOuter = this.lp.mobile_apppack_form_enable_outer_status_no; if (this.packInfo.isPackAppIdOuter && this.packInfo.isPackAppIdOuter === "2") { isPackAppIdOuter = this.lp.mobile_apppack_form_enable_outer_status_yes; } this.apppackIsPackAppIdOuterShowNode.set("text", isPackAppIdOuter); // var deleteHms = this.lp.mobile_apppack_form_enable_delete_hms_status_no; // if (this.packInfo.deleteHuawei && this.packInfo.deleteHuawei === "2") { // deleteHms = this.lp.mobile_apppack_form_enable_delete_hms_status_yes; // } // this.apppackIsDeleteHmsShowNode.set("text", deleteHms); this.apppackLogoShowImgNode.set("src", this.packServerUrl + this.packInfo.appLogoPath + "?token=" + this.token); var status = "" if (this.packInfo.packStatus === "0") { status = this.lp.mobile_apppack_status_order_inline; this.apppackStatusRefreshNode.setStyles({ "display": "" }); this.apppackStatusRefreshNode.addEvents({ "click": function(e) { this.loadAppPackInfo(); }.bind(this) }) this.apppackReInputBtnNode.setStyles({ "display": "none" }); this.apppackRePackBtnNode.setStyles({"display": "none"}) } else if (this.packInfo.packStatus === "1") { status = this.lp.mobile_apppack_status_packing this.apppackStatusRefreshNode.setStyles({ "display": "" }); this.apppackStatusRefreshNode.addEvents({ "click": function(e) { this.loadAppPackInfo(); }.bind(this) }) this.apppackReInputBtnNode.setStyles({ "display": "none" }); this.apppackRePackBtnNode.setStyles({"display": "none"}) } else if (this.packInfo.packStatus === "2") { status = this.lp.mobile_apppack_status_pack_end this.apppackStatusRefreshNode.setStyles({ "display": "none" }); this.apppackReInputBtnNode.setStyles({ "display": "" }); this.apppackReInputBtnNode.addEvents({ "click": function(e) { this.reInput(); }.bind(this) }) this.apppackRePackBtnNode.setStyles({"display": ""}) this.apppackRePackBtnNode.addEvents({ "click": function(e) { this.reSubmitPack(); }.bind(this) }) } else { status = this.lp.mobile_apppack_status_pack_error this.apppackStatusRefreshNode.setStyles({ "display": "none" }); this.apppackReInputBtnNode.setStyles({ "display": "" }); this.apppackReInputBtnNode.addEvents({ "click": function(e) { this.reInput(); }.bind(this) }) this.apppackRePackBtnNode.setStyles({"display": "none"}) } this.apppackStatusShowNode.set("text", status); if (this.packInfo.apkPath && this.packInfo.packStatus === "2") { // 显示发布区域 this.apppackPublishShowNode.setStyles({ "display": ""}); if (!this.packInfo.appFile) { // 还未发布到本地 this.apppackPublishBtnNode.setStyles({ "display": ""}); //显示发布按钮 this.apppackPublishBtnNode.addEvents({ "click": function(e) { this.publishAPK2Local(); }.bind(this) }); this.apppackPublishStatusInfoNode.set("text", ""); // 弹出发布提示 this.confirm(this.lp.alert, this.lp.mobile_apppack_message_confirm_publish, function() { this.publishAPK2Local(); }.bind(this)); } else if (this.packInfo.appFile.status === 0) { // 发布中 this.apppackPublishBtnNode.setStyles({ "display": "none"}); //隐藏发布按钮 this.apppackPublishStatusInfoNode.set("text", this.lp.mobile_apppack_publish_status_doing); } else if (this.packInfo.appFile.status === 1) { // 发布完成 this.apppackPublishBtnNode.setStyles({ "display": "none"}); //隐藏发布按钮 this.apppackPublishStatusInfoNode.set("text", this.lp.mobile_apppack_publish_status_completed); // 发布完成,显示下载按钮 var url = o2.Actions.getHost("x_program_center") + "/x_program_center/jaxrs/apppack/pack/info/file/download/" + this.packInfo.appFile.id ; url = o2.filterUrl(url); this.apppackDownloadLinkNode.set("href", url); this.apppackDownloadShowNode.setStyles({ "display": "" }); } else if (this.packInfo.appFile.status === 2) { // 发布失败 this.apppackPublishBtnNode.setStyles({ "display": ""}); //显示发布按钮 this.apppackPublishStatusInfoNode.set("text", this.lp.mobile_apppack_publish_status_fail); this.apppackPublishBtnNode.addEvents({ "click": function(e) { this.publishAPK2Local(); }.bind(this) }); } else { this.apppackPublishStatusInfoNode.set("text", ""); } } else { this.apppackDownloadShowNode.setStyles({ "display": "none" }); } this.apppackShowBodyNode.setStyles({ "display": "" }); this.apppackFormBodyNode.setStyles({ "display": "none" }); } }, // 发布打包好的apk到本地 publishAPK2Local: function() { if (this.packInfo) { var url = o2.Actions.getHost("") var data = { 'token': this.token, 'apkPath': this.packInfo.apkPath, 'packInfoId': this.packInfo.id, 'appVersionName': this.packInfo.versionName, 'appVersionNo': this.packInfo.buildNo, 'isPackAppIdOuter': this.packInfo.isPackAppIdOuter, 'webUrl': url, } this.showLoading(); o2.Actions.load("x_program_center").AppPackAction.publishApk(data, function(json){ this.hiddenLoading(); if (json.data && json.data.value) { // 提交成功 获取最新打包对象信息 this.loadAppPackInfo(); }else { this.app.notice(json.message, "error", this.contentAreaNode); } }.bind(this), function (error) { this.hiddenLoading(); console.log(error); this.app.notice(error, "error", this.contentAreaNode); }.bind(this)); } else { console.log("没有打包信息,不能发布"); } }, // 重新输入 提交表单 reInput: function () { // 填充内容 if (this.packInfo) { this.apppackProtocolInputNode.set("value", this.packInfo.o2ServerProtocol); this.apppackHostInputNode.set("value", this.packInfo.o2ServerHost); this.apppackPortInputNode.set("value", this.packInfo.o2ServerPort); this.apppackContextInputNode.set("value", this.packInfo.o2ServerContext); this.apppackAppNameInputNode.set("value", this.packInfo.appName); this.apppackAppVersionNameInputNode.set("value", ""); // 重新填写 版本号清空 this.apppackAppBuildNoInputNode.set("value", ""); // 重新填写 版本号清空 this.apppackUrlMappingInputNode.set("value", this.packInfo.urlMapping); var isPackAppIdOuter = false; if (this.packInfo.isPackAppIdOuter && this.packInfo.isPackAppIdOuter === "2") { isPackAppIdOuter = true; } this.apppackIsPackAppIdOuterInputNode.set("checked", isPackAppIdOuter); // var deleteHms = false; // if (this.packInfo.deleteHuawei && this.packInfo.deleteHuawei === "2") { // deleteHms = true; // } // this.apppackIsDeleteHmsInputNode.set("checked", deleteHms); } this.showForm(); }, // 获取本地配置的proxy地址 loadConfigProxy: function () { o2.Actions.load("x_program_center").ConfigAction.getProxy(function(json){ this.hiddenLoading(); // 填充 if (json && json.data) { var data = json.data if (data.httpProtocol) { this.apppackProtocolInputNode.set("value", data.httpProtocol); } else { this.apppackProtocolInputNode.set("value", "http"); } if (data.center) { if (data.center.proxyHost) { this.apppackHostInputNode.set("value", data.center.proxyHost); } if (data.center.proxyPort) { this.apppackPortInputNode.set("value", data.center.proxyPort); } else { this.apppackPortInputNode.set("value", "20030"); } } else { this.apppackPortInputNode.set("value", "20030"); } } this.apppackContextInputNode.set("value", "/x_program_center"); this.showForm(); }.bind(this)) }, // 直接用原有资料重新打包 reSubmitPack: function() { this.confirm(this.lp.alert, this.lp.mobile_apppack_message_alert_submit, function() { this.showLoading(); o2.Actions.load("x_program_center").AppPackAction.androidPackReStart(this.token, function (json) { console.log(json) this.hiddenLoading(); if (json.data && json.data.value) { // 提交成功 获取最新打包对象信息 this.loadAppPackInfo(); } else { this.app.notice(json.message, "error", this.contentAreaNode); } }.bind(this), function (error) { this.hiddenLoading(); console.log(error); this.app.notice(error, "error", this.contentAreaNode); }.bind(this)); }.bind(this)); }, // 提交打包 submitPack: function () { var appName = this.apppackAppNameInputNode.get("value"); if (!appName || appName === "") { this.app.notice(this.lp.mobile_apppack_message_appname_not_empty, "error", this.contentAreaNode); return; } if (appName.length > 6) { this.app.notice(this.lp.mobile_apppack_message_appname_len_max_6, "error", this.contentAreaNode); return; } var files = this.apppackLogoInputNode.files; if (files.length) { var file = files.item(0); var fileExt = file.name.substring(file.name.lastIndexOf(".")); if (fileExt.toLowerCase() !== ".png") { this.app.notice(this.lp.mobile_apppack_message_app_logo_need_png, "error", this.contentAreaNode); return; } } else { this.app.notice(this.lp.mobile_apppack_message_app_logo_not_empty, "error", this.contentAreaNode); return; } var protocol = this.apppackProtocolInputNode.get("value"); if (!protocol || protocol === "") { this.app.notice(this.lp.mobile_apppack_message_portocol_not_empty, "error", this.contentAreaNode); return; } if (protocol !== "http" && protocol !== "https") { this.app.notice(this.lp.mobile_apppack_message_portocol_http_https, "error", this.contentAreaNode); return; } var host = this.apppackHostInputNode.get("value"); if (!host || host === "") { this.app.notice(this.lp.mobile_apppack_message_host_not_empty, "error", this.contentAreaNode); return; } if (host.startsWith("http://") || host.startsWith("https://")) { this.app.notice(this.lp.mobile_apppack_message_host_format_error, "error", this.contentAreaNode); return; } if (host.indexOf(":") > 0) { this.app.notice(this.lp.mobile_apppack_message_host_format_error, "error", this.contentAreaNode); return; } var port = this.apppackPortInputNode.get("value"); if (!port || port === "") { this.app.notice(this.lp.mobile_apppack_message_port_not_empty, "error", this.contentAreaNode); return; } var context = this.apppackContextInputNode.get("value"); if (!context || context === "") { this.app.notice(this.lp.mobile_apppack_message_context_not_empty, "error", this.contentAreaNode); return; } var appVersionName = this.apppackAppVersionNameInputNode.get("value"); var appBuildNo = this.apppackAppBuildNoInputNode.get("value"); var isPackAppIdOuter = this.apppackIsPackAppIdOuterInputNode.checked ? "2" : "1"; // var deleteHms = this.apppackIsDeleteHmsInputNode.checked ? "2" : "1"; var urlMapping = this.apppackUrlMappingInputNode.get("value"); this.confirm(this.lp.alert, this.lp.mobile_apppack_message_alert_submit, function() { this.showLoading(); var formData = new FormData(); formData.append('file', file); formData.append('fileName', file.name); formData.append('appName', appName); formData.append('o2ServerProtocol', protocol); formData.append('o2ServerHost', host); formData.append('o2ServerPort', port); formData.append('o2ServerContext', context); formData.append('appVersionName', appVersionName); formData.append('appBuildNo', appBuildNo); formData.append('isPackAppIdOuter', isPackAppIdOuter); formData.append('deleteHuawei', "1"); formData.append('urlMapping', urlMapping); formData.append('token', this.token); o2.Actions.load("x_program_center").AppPackAction.androidPackStart(formData, "{}",function (json) { console.log(json) this.hiddenLoading(); if (json.data && json.data.value) { // 提交成功 获取最新打包对象信息 this.loadAppPackInfo(); } else { this.app.notice(json.message, "error", this.contentAreaNode); } }.bind(this), function (error) { this.hiddenLoading(); console.log(error); this.app.notice(error, "error", this.contentAreaNode); }.bind(this)); }.bind(this)); }, //确认 confirm: function (title, text, okCallback) { var width = 600; var height = 110; var size = this.app.content.getSize(); var x = (size.x - width) / 2; var y = (size.y - height) / 2; MWF.require("MWF.xDesktop.Dialog", function () { var dlg = new MWF.xDesktop.Dialog({ "title": title, "style": "settingStyle", "top": y, "left": x, "width": width, "height": height, "text": text, "maskNode": this.app.content, "container": this.app.content, "buttonList": [ { "text": this.lp.ok, "action": function () { if (okCallback) { okCallback(); } this.close(); } }, { "text": this.lp.cancel, "action": function () { this.close(); } } ] }); dlg.show(); }.bind(this)); } }); // 微信菜单 MWF.xApplication.Setting.MPWeixinMenuSettingDocument = new Class({ Extends: MWF.xApplication.Setting.Document, load: function () { var cssurl = "../x_component_Setting/$Main/default/mpweixin/mpweixin.css"; var htmlurl = "../x_component_Setting/$Main/default/mpweixin/menu.html"; this.contentAreaNode.loadAll({ "css": [cssurl], "html": [htmlurl] }, { "bind": { "lp": this.lp, "data": {} }, "module": this }, function () { this.node = this.mpwxMenuNode; this.initMenuData(); this.loadMenu(); this.loadPublishBtn(); this.subscribeEvent(); }.bind(this)); }, initMenuData: function() { //处理数据 // var list = this.explorer.mpweixinListData; if (!this.menuList) { this.menuList = this.explorer.mpweixinListData || []; } //去除 subscribe var subscribe = null; for (let index = 0; index < this.menuList.length; index++) { const element = this.menuList[index]; if (element.type && element.type === "subscribe") { subscribe = element; } } if (subscribe) { this.menuList.erase(subscribe); } }, //发布菜单 点击事件 loadPublishBtn: function() { this.mpwxPublishBtnNode.addEvents({ "click": function(){ if (this.menuList && this.menuList.length > 0) { this.confirm(this.lp.alert, this.lp.mobile_mpweixin_menu_msg_publish_2_wxmp, function () { o2.Actions.load("x_program_center").MPWeixinAction.menuCreate2Weixin(function (json) { this.app.notice(this.lp.mobile_mpweixin_menu_msg_publish_success, "success", this.contentAreaNode); }.bind(this)); }.bind(this)); } }.bind(this) }); }, // 关注回复消息 subscribeEvent: function() { if (this.explorer.mpweixinSubscribe) { this.mpweixinSubscribe = this.explorer.mpweixinSubscribe; if (this.mpweixinSubscribe.name && this.mpweixinSubscribe.name !== "") { //已经存在 name肯定不为空 this.mpwxMenuSubscribeInputNode.set("value", this.mpweixinSubscribe.content || ""); } else { // 新的 没有数据 this.mpweixinSubscribe = { id: "mock_new", name: "subscribe", type: "subscribe" }; } } else { this.mpweixinSubscribe = { id: "mock_new", name: "subscribe", type: "subscribe" }; } //保存事件 this.mpwxSaveSubscribeBtnNode.addEvents({ "click": function(){ this.saveSubscribeMenu(); }.bind(this) }); }, saveSubscribeMenu: function() { var content = this.mpwxMenuSubscribeInputNode.get("value"); if (!content || content === "") { this.app.notice(this.lp.mobile_mpweixin_menu_form_subscribe_content_error_empty, "error", this.contentAreaNode); return; } this.mpweixinSubscribe.content = content; //新建的菜单 click类型需要设置key if (this.mpweixinSubscribe.id.startsWith('mock_')) { delete this.mpweixinSubscribe.id; //新增要删除id } //写入数据 远程写入 还有 上级数组中 if (!this.mpweixinSubscribe.id) { //新增 o2.Actions.load("x_program_center").MPWeixinAction.menuAdd(this.mpweixinSubscribe,function (json) { this.app.notice(this.lp.mobile_mpweixin_menu_save_success, "success", this.contentAreaNode); }.bind(this)); }else { // 更新 o2.Actions.load("x_program_center").MPWeixinAction.menuUpdate(this.mpweixinSubscribe.id, this.mpweixinSubscribe,function (json) { this.app.notice(this.lp.mobile_mpweixin_menu_save_success, "success", this.contentAreaNode); }.bind(this)); } }, loadMenu: function () { this.mpwxMenuListNode.empty(); // 生成菜单 if (this.menuList && this.menuList.length > 0) { if (!this.showSubId) { this.showSubId = this.menuList[0].id;//初始化 showSubId 表示哪个子菜单是显示的 } if (!this.currentMenuId) { this.currentMenuId = this.menuList[0].id;//初始化 currentMenuId 表示当前选中的菜单ID } for (let index = 0; index < this.menuList.length; index++) { const element = this.menuList[index]; this.firstLevelMenu(element); } } this.firstLevelAddButton(); }, //第一层级的新建按钮 firstLevelAddButton: function () { var addLi = new Element("li", { "class": "js_addMenuBox pre_menu_item grid_item no_extra" }).inject(this.mpwxMenuListNode); new Element("a", { "class": "pre_menu_link js_addL1Btn", "href": "javascript:void(0);" }).inject(addLi); new Element("i", { "class": "icon14_menu_add" }).inject(addLi); //点击事件 addLi.addEvents({ "click": function () { this.createNewFirstMenuMock(); }.bind(this) }); }, // 第一层级 菜单 UI //