SettingMobile.js 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379
  1. MWF.xDesktop.requireApp("Setting", "Document", null, false);
  2. MWF.xApplication.Setting.MobileConnectDocument = new Class({
  3. Extends: MWF.xApplication.Setting.Document,
  4. load: function () {
  5. this.node = new Element("div", { "styles": { "overflow": "hidden", "padding-bottom": "80px" } }).inject(this.contentAreaNode);
  6. this.titleName = new Element("div", { "styles": this.explorer.css.explorerContentTitleNode }).inject(this.node);
  7. this.titleName.set("text", this.lp.mobile_connectSetting);
  8. var o2CloudConnected = false;
  9. this.actions.collectConnected(function (json) {
  10. o2CloudConnected = json.data.value;
  11. }.bind(this), function (json) {
  12. o2CloudConnected = false;
  13. }.bind(this), false);
  14. this.mobileO2CloudConnectInput = new MWF.xApplication.Setting.Document.Button(this.explorer, this.node, {
  15. "lp": { "title": this.lp.mobile_connectO2Cloud, "infor": this.mobile_connectO2Cloud_infor, "action": this.lp.mobile_connectO2Cloud_action },
  16. //"data": {"key": "proxyData", "valueKey": "ssos", "notEmpty": false },
  17. "value": o2CloudConnected ? this.lp.mobile_connectO2Cloud_success : this.lp.mobile_connectO2Cloud_error,
  18. "itemTitle": o2CloudConnected ? this.lp.mobile_connectO2Cloud_success : this.lp.mobile_connectO2Cloud_error,
  19. "icon": o2CloudConnected ? "cloud.png" : "cloud_error.png",
  20. "action": function (e) {
  21. layout.desktop.openApplication(e, "Collect");
  22. }.bind(this)
  23. });
  24. this.mobileHttpProtocolInput = new MWF.xApplication.Setting.Document.Select(this.explorer, this.node, {
  25. "lp": { "title": this.lp.mobile_httpProtocol, "infor": this.lp.mobile_httpProtocol_infor },
  26. "data": { "key": "proxyData", "valueKey": "httpProtocol" },
  27. "value": this.explorer.proxyData.httpProtocol,
  28. "options": [{ "value": "http", "text": "http" }, { "value": "https", "text": "https" }]
  29. });
  30. this.mobileCenterInput = new MWF.xApplication.Setting.Document.List(this.explorer, this.node, {
  31. "lp": { "title": this.lp.mobile_center, "infor": this.lp.mobile_center_infor, "editAction": this.lp.mobile_center_action },
  32. "data": { "key": "proxyData", "valueKey": "center", "notEmpty": false },
  33. "value": this.explorer.proxyData.center,
  34. "itemTitle": "{proxyHost}:{proxyPort}",
  35. "icon": "center.png"
  36. });
  37. this.mobileWebInput = new MWF.xApplication.Setting.Document.List(this.explorer, this.node, {
  38. "lp": { "title": this.lp.mobile_web, "infor": this.lp.mobile_web_infor, "editAction": this.lp.mobile_web_action },
  39. "data": { "key": "proxyData", "valueKey": "web", "notEmpty": false },
  40. "value": this.explorer.proxyData.web,
  41. "itemTitle": "{proxyHost}:{proxyPort}",
  42. "icon": "webserver.png"
  43. });
  44. this.mobileApplicationInput = new MWF.xApplication.Setting.Document.List(this.explorer, this.node, {
  45. "lp": { "title": this.lp.mobile_application, "infor": this.lp.mobile_application_infor, "editAction": this.lp.mobile_application_action },
  46. "data": { "key": "proxyData", "valueKey": "applicationList", "notEmpty": false },
  47. "value": this.explorer.proxyData.applicationList,
  48. "itemTitle": "{proxyHost}:{proxyPort}",
  49. "readonly": ["node"],
  50. "icon": "server.png"
  51. });
  52. }
  53. });
  54. MWF.xApplication.Setting.MobileModuleDocument = new Class({
  55. Extends: MWF.xApplication.Setting.Document,
  56. load: function () {
  57. this.node = new Element("div", { "styles": { "overflow": "hidden", "padding-bottom": "80px" } }).inject(this.contentAreaNode);
  58. this.titleName = new Element("div", { "styles": this.explorer.css.explorerContentTitleNode }).inject(this.node);
  59. this.titleName.set("text", this.lp.mobile_moduleSetting);
  60. var options = [{ "value": "", "text": this.lp.mobile_index_defalue }];
  61. if (this.explorer.portalData.portalList && this.explorer.portalData.portalList.length) {
  62. this.explorer.portalData.portalList.each(function (portal) {
  63. options.push({
  64. "value": portal.id,
  65. "text": portal.name
  66. });
  67. }.bind(this));
  68. }
  69. this.mobileIndexInput = new MWF.xApplication.Setting.Document.Select(this.explorer, this.node, {
  70. "lp": { "title": this.lp.mobile_index, "infor": this.lp.mobile_index_infor },
  71. "data": { "key": "nativeData", "valueKey": "indexPortal" },
  72. "value": this.explorer.nativeData.indexPortal,
  73. "options": options
  74. });
  75. //移动端简易模式
  76. var simpleModeTitle = this.lp.mobile_module_simple_mode;
  77. var simpleModeInfor = this.lp.mobile_module_simple_mode_infor;
  78. new MWF.xApplication.Setting.Document.Check(this.explorer, this.node, {
  79. "lp": { "title": simpleModeTitle, "infor": simpleModeInfor },
  80. "data": { "key": "nativeData", "valueKey": "simpleMode", "notEmpty": false },
  81. "value": this.explorer.nativeData.simpleMode
  82. });
  83. // app通讯录权限视图
  84. var contactPermissionViewTitle = this.lp.mobile_module_contact_permission_view;
  85. var contactPermissionViewInfor = this.lp.mobile_module_contact_permission_view_infor;
  86. new MWF.xApplication.Setting.Document.Input(this.explorer, this.node, {
  87. "lp": { "title": contactPermissionViewTitle, "infor": contactPermissionViewInfor, "action": this.lp.mobile_module_contact_permission_view_action},
  88. "data": { "key": "nativeData", "valueKey": "contactPermissionView", "notEmpty": false },
  89. "value": this.explorer.nativeData.contactPermissionView || "addressPowerView" // 默认视图名 addressPowerView
  90. });
  91. //显示系统通知
  92. var systemMessageSwitchTitle = this.lp.mobile_module_system_message_switch;
  93. var systemMessageSwitchInfor = this.lp.mobile_module_system_message_switch_infor;
  94. new MWF.xApplication.Setting.Document.Check(this.explorer, this.node, {
  95. "lp": { "title": systemMessageSwitchTitle, "infor": systemMessageSwitchInfor },
  96. "data": { "key": "nativeData", "valueKey": "systemMessageSwitch", "notEmpty": false },
  97. "value": this.explorer.nativeData.systemMessageSwitch
  98. });
  99. this.explorer.nativeData.nativeAppList.each(function (app, i) {
  100. var title = this.lp.mobile_module.replace("{name}", app.name);
  101. var infor = this.lp.mobile_module_infor.replace("{name}", app.name);
  102. new MWF.xApplication.Setting.Document.Check(this.explorer, this.node, {
  103. "lp": { "title": title, "infor": infor },
  104. "data": { "key": "nativeData", "valueKey": "nativeAppList." + i + ".enable", "notEmpty": false },
  105. "value": app.enable
  106. });
  107. }.bind(this));
  108. }
  109. });
  110. // app在线打包功能
  111. MWF.xApplication.Setting.AppPackOnlineDocument = new Class({
  112. Extends: MWF.xApplication.Setting.Document,
  113. load: function () {
  114. var cssurl = "../x_component_Setting/$Main/default/apppack/index.css";
  115. var htmlurl = "../x_component_Setting/$Main/default/apppack/index.html";
  116. this.contentAreaNode.loadAll({ "css": [cssurl], "html": [htmlurl] }, { "bind": { "lp": this.lp, "data": {} }, "module": this }, function () {
  117. this.node = this.apppackBoxNode;
  118. this.checkConnectAppPackServer();
  119. }.bind(this));
  120. },
  121. // 检查app打包服务器连接情况,包括是否已经登录O2云
  122. checkConnectAppPackServer: function () {
  123. o2.Actions.load("x_program_center").AppPackAction.connect(function(json){
  124. if (json && json.data) {
  125. var data = json.data
  126. if (data.status === 1001) { // 成功 获取token
  127. this.token = data.token;
  128. this.packServerUrl = data.packServerUrl;
  129. this.apppackErrorMsgNode.setStyles({
  130. "display": "none"
  131. });
  132. this.loadAppPackInfo();
  133. } else if (data.status === 1) { // o2云未连接 o2云未启用
  134. this.showErrorMsg(this.lp.mobile_apppack_message_o2cloud_not_enable);
  135. // this.app.notice(this.lp.mobile_apppack_message_o2cloud_not_enable, "error", this.contentAreaNode);
  136. } else if (data.status === 2) { // o2云未登录
  137. // this.app.notice(this.lp.mobile_apppack_message_o2cloud_not_login, "error", this.contentAreaNode);
  138. this.showErrorMsg(this.lp.mobile_apppack_message_o2cloud_not_login);
  139. } else if (data.status === 3) { // 打包服务器未认证通过
  140. // this.app.notice(this.lp.mobile_apppack_message_apppack_server_login_fail, "error", this.contentAreaNode);
  141. this.showErrorMsg(this.lp.mobile_apppack_message_apppack_server_login_fail);
  142. }
  143. } else {
  144. // this.app.notice(this.lp.mobile_apppack_message_check_connect_fail, "error", this.contentAreaNode);
  145. this.showErrorMsg(this.lp.mobile_apppack_message_check_connect_fail);
  146. }
  147. }.bind(this));
  148. },
  149. // 加载最近一次打包信息
  150. loadAppPackInfo: function () {
  151. this.showLoading();
  152. o2.Actions.load("x_program_center").AppPackAction.packInfo(this.token, function(json){
  153. this.hiddenLoading();
  154. if (json && json.type === "success") {
  155. this.packInfo = json.data;
  156. this.showPackInfoDetail();
  157. } else {
  158. console.log("查询打包信息失败。。。")
  159. this.loadConfigProxy();
  160. }
  161. }.bind(this), function(err){
  162. console.log("错误拉,没有找到打包信息!");
  163. console.log(err);
  164. this.hiddenLoading();
  165. this.loadConfigProxy();
  166. }.bind(this));
  167. },
  168. showLoading: function() {
  169. if (this.packLoadingNode) {
  170. this.hiddenLoading();
  171. }
  172. this.packLoadingNode = new Element("div", { "class": "pack-loading" }).inject(this.apppackBoxNode);
  173. new Element("div", {"text": "Loading......"}).inject(this.packLoadingNode);
  174. },
  175. hiddenLoading: function() {
  176. if (this.packLoadingNode) {
  177. this.packLoadingNode.destroy();
  178. this.packLoadingNode = null;
  179. }
  180. },
  181. // 显示错误信息
  182. showErrorMsg: function(msg) {
  183. this.apppackErrorMsgNode.set("text", msg);
  184. this.apppackErrorMsgNode.setStyles({
  185. "display": ""
  186. });
  187. },
  188. // 显示提交表单
  189. showForm: function() {
  190. this.apppackShowBodyNode.setStyles({
  191. "display": "none"
  192. });
  193. this.apppackFormBodyNode.setStyles({
  194. "display": ""
  195. });
  196. this.apppackBtnNode.addEvents({
  197. "click": function(e) {
  198. this.submitPack();
  199. }.bind(this)
  200. })
  201. },
  202. // 显示打包详情
  203. showPackInfoDetail: function () {
  204. if (this.packInfo) {
  205. this.apppackAppNameShowNode.set("text", this.packInfo.appName);
  206. this.apppackProtocolShowNode.set("text", this.packInfo.o2ServerProtocol);
  207. this.apppackHostShowNode.set("text", this.packInfo.o2ServerHost);
  208. this.apppackPortShowNode.set("text", this.packInfo.o2ServerPort);
  209. this.apppackContextShowNode.set("text", this.packInfo.o2ServerContext);
  210. this.apppackAppVersionNameShowNode.set("text", this.packInfo.versionName);
  211. this.apppackAppBuildNoShowNode.set("text", this.packInfo.buildNo);
  212. this.apppackUrlMappingShowNode.set("text", this.packInfo.urlMapping);
  213. var isPackAppIdOuter = this.lp.mobile_apppack_form_enable_outer_status_no;
  214. if (this.packInfo.isPackAppIdOuter && this.packInfo.isPackAppIdOuter === "2") {
  215. isPackAppIdOuter = this.lp.mobile_apppack_form_enable_outer_status_yes;
  216. }
  217. this.apppackIsPackAppIdOuterShowNode.set("text", isPackAppIdOuter);
  218. // var deleteHms = this.lp.mobile_apppack_form_enable_delete_hms_status_no;
  219. // if (this.packInfo.deleteHuawei && this.packInfo.deleteHuawei === "2") {
  220. // deleteHms = this.lp.mobile_apppack_form_enable_delete_hms_status_yes;
  221. // }
  222. // this.apppackIsDeleteHmsShowNode.set("text", deleteHms);
  223. this.apppackLogoShowImgNode.set("src", this.packServerUrl + this.packInfo.appLogoPath + "?token=" + this.token);
  224. var status = ""
  225. if (this.packInfo.packStatus === "0") {
  226. status = this.lp.mobile_apppack_status_order_inline;
  227. this.apppackStatusRefreshNode.setStyles({
  228. "display": ""
  229. });
  230. this.apppackStatusRefreshNode.addEvents({
  231. "click": function(e) {
  232. this.loadAppPackInfo();
  233. }.bind(this)
  234. })
  235. this.apppackReInputBtnNode.setStyles({
  236. "display": "none"
  237. });
  238. this.apppackRePackBtnNode.setStyles({"display": "none"})
  239. } else if (this.packInfo.packStatus === "1") {
  240. status = this.lp.mobile_apppack_status_packing
  241. this.apppackStatusRefreshNode.setStyles({
  242. "display": ""
  243. });
  244. this.apppackStatusRefreshNode.addEvents({
  245. "click": function(e) {
  246. this.loadAppPackInfo();
  247. }.bind(this)
  248. })
  249. this.apppackReInputBtnNode.setStyles({
  250. "display": "none"
  251. });
  252. this.apppackRePackBtnNode.setStyles({"display": "none"})
  253. } else if (this.packInfo.packStatus === "2") {
  254. status = this.lp.mobile_apppack_status_pack_end
  255. this.apppackStatusRefreshNode.setStyles({
  256. "display": "none"
  257. });
  258. this.apppackReInputBtnNode.setStyles({
  259. "display": ""
  260. });
  261. this.apppackReInputBtnNode.addEvents({
  262. "click": function(e) {
  263. this.reInput();
  264. }.bind(this)
  265. })
  266. this.apppackRePackBtnNode.setStyles({"display": ""})
  267. this.apppackRePackBtnNode.addEvents({
  268. "click": function(e) {
  269. this.reSubmitPack();
  270. }.bind(this)
  271. })
  272. } else {
  273. status = this.lp.mobile_apppack_status_pack_error
  274. this.apppackStatusRefreshNode.setStyles({
  275. "display": "none"
  276. });
  277. this.apppackReInputBtnNode.setStyles({
  278. "display": ""
  279. });
  280. this.apppackReInputBtnNode.addEvents({
  281. "click": function(e) {
  282. this.reInput();
  283. }.bind(this)
  284. })
  285. this.apppackRePackBtnNode.setStyles({"display": "none"})
  286. }
  287. this.apppackStatusShowNode.set("text", status);
  288. if (this.packInfo.apkPath && this.packInfo.packStatus === "2") {
  289. // 显示发布区域
  290. this.apppackPublishShowNode.setStyles({ "display": ""});
  291. if (!this.packInfo.appFile) { // 还未发布到本地
  292. this.apppackPublishBtnNode.setStyles({ "display": ""}); //显示发布按钮
  293. this.apppackPublishBtnNode.addEvents({
  294. "click": function(e) {
  295. this.publishAPK2Local();
  296. }.bind(this)
  297. });
  298. this.apppackPublishStatusInfoNode.set("text", "");
  299. // 弹出发布提示
  300. this.confirm(this.lp.alert, this.lp.mobile_apppack_message_confirm_publish, function() {
  301. this.publishAPK2Local();
  302. }.bind(this));
  303. } else if (this.packInfo.appFile.status === 0) { // 发布中
  304. this.apppackPublishBtnNode.setStyles({ "display": "none"}); //隐藏发布按钮
  305. this.apppackPublishStatusInfoNode.set("text", this.lp.mobile_apppack_publish_status_doing);
  306. } else if (this.packInfo.appFile.status === 1) { // 发布完成
  307. this.apppackPublishBtnNode.setStyles({ "display": "none"}); //隐藏发布按钮
  308. this.apppackPublishStatusInfoNode.set("text", this.lp.mobile_apppack_publish_status_completed);
  309. // 发布完成,显示下载按钮
  310. var url = o2.Actions.getHost("x_program_center") + "/x_program_center/jaxrs/apppack/pack/info/file/download/" + this.packInfo.appFile.id ;
  311. url = o2.filterUrl(url);
  312. this.apppackDownloadLinkNode.set("href", url);
  313. this.apppackDownloadShowNode.setStyles({
  314. "display": ""
  315. });
  316. } else if (this.packInfo.appFile.status === 2) { // 发布失败
  317. this.apppackPublishBtnNode.setStyles({ "display": ""}); //显示发布按钮
  318. this.apppackPublishStatusInfoNode.set("text", this.lp.mobile_apppack_publish_status_fail);
  319. this.apppackPublishBtnNode.addEvents({
  320. "click": function(e) {
  321. this.publishAPK2Local();
  322. }.bind(this)
  323. });
  324. } else {
  325. this.apppackPublishStatusInfoNode.set("text", "");
  326. }
  327. } else {
  328. this.apppackDownloadShowNode.setStyles({
  329. "display": "none"
  330. });
  331. }
  332. this.apppackShowBodyNode.setStyles({
  333. "display": ""
  334. });
  335. this.apppackFormBodyNode.setStyles({
  336. "display": "none"
  337. });
  338. }
  339. },
  340. // 发布打包好的apk到本地
  341. publishAPK2Local: function() {
  342. if (this.packInfo) {
  343. var url = o2.Actions.getHost("")
  344. var data = {
  345. 'token': this.token,
  346. 'apkPath': this.packInfo.apkPath,
  347. 'packInfoId': this.packInfo.id,
  348. 'appVersionName': this.packInfo.versionName,
  349. 'appVersionNo': this.packInfo.buildNo,
  350. 'isPackAppIdOuter': this.packInfo.isPackAppIdOuter,
  351. 'webUrl': url,
  352. }
  353. this.showLoading();
  354. o2.Actions.load("x_program_center").AppPackAction.publishApk(data, function(json){
  355. this.hiddenLoading();
  356. if (json.data && json.data.value) {
  357. // 提交成功 获取最新打包对象信息
  358. this.loadAppPackInfo();
  359. }else {
  360. this.app.notice(json.message, "error", this.contentAreaNode);
  361. }
  362. }.bind(this), function (error) {
  363. this.hiddenLoading();
  364. console.log(error);
  365. this.app.notice(error, "error", this.contentAreaNode);
  366. }.bind(this));
  367. } else {
  368. console.log("没有打包信息,不能发布");
  369. }
  370. },
  371. // 重新输入 提交表单
  372. reInput: function () {
  373. // 填充内容
  374. if (this.packInfo) {
  375. this.apppackProtocolInputNode.set("value", this.packInfo.o2ServerProtocol);
  376. this.apppackHostInputNode.set("value", this.packInfo.o2ServerHost);
  377. this.apppackPortInputNode.set("value", this.packInfo.o2ServerPort);
  378. this.apppackContextInputNode.set("value", this.packInfo.o2ServerContext);
  379. this.apppackAppNameInputNode.set("value", this.packInfo.appName);
  380. this.apppackAppVersionNameInputNode.set("value", ""); // 重新填写 版本号清空
  381. this.apppackAppBuildNoInputNode.set("value", ""); // 重新填写 版本号清空
  382. this.apppackUrlMappingInputNode.set("value", this.packInfo.urlMapping);
  383. var isPackAppIdOuter = false;
  384. if (this.packInfo.isPackAppIdOuter && this.packInfo.isPackAppIdOuter === "2") {
  385. isPackAppIdOuter = true;
  386. }
  387. this.apppackIsPackAppIdOuterInputNode.set("checked", isPackAppIdOuter);
  388. // var deleteHms = false;
  389. // if (this.packInfo.deleteHuawei && this.packInfo.deleteHuawei === "2") {
  390. // deleteHms = true;
  391. // }
  392. // this.apppackIsDeleteHmsInputNode.set("checked", deleteHms);
  393. }
  394. this.showForm();
  395. },
  396. // 获取本地配置的proxy地址
  397. loadConfigProxy: function () {
  398. o2.Actions.load("x_program_center").ConfigAction.getProxy(function(json){
  399. this.hiddenLoading();
  400. // 填充
  401. if (json && json.data) {
  402. var data = json.data
  403. if (data.httpProtocol) {
  404. this.apppackProtocolInputNode.set("value", data.httpProtocol);
  405. } else {
  406. this.apppackProtocolInputNode.set("value", "http");
  407. }
  408. if (data.center) {
  409. if (data.center.proxyHost) {
  410. this.apppackHostInputNode.set("value", data.center.proxyHost);
  411. }
  412. if (data.center.proxyPort) {
  413. this.apppackPortInputNode.set("value", data.center.proxyPort);
  414. } else {
  415. this.apppackPortInputNode.set("value", "20030");
  416. }
  417. } else {
  418. this.apppackPortInputNode.set("value", "20030");
  419. }
  420. }
  421. this.apppackContextInputNode.set("value", "/x_program_center");
  422. this.showForm();
  423. }.bind(this))
  424. },
  425. // 直接用原有资料重新打包
  426. reSubmitPack: function() {
  427. this.confirm(this.lp.alert, this.lp.mobile_apppack_message_alert_submit, function() {
  428. this.showLoading();
  429. o2.Actions.load("x_program_center").AppPackAction.androidPackReStart(this.token, function (json) {
  430. console.log(json)
  431. this.hiddenLoading();
  432. if (json.data && json.data.value) {
  433. // 提交成功 获取最新打包对象信息
  434. this.loadAppPackInfo();
  435. } else {
  436. this.app.notice(json.message, "error", this.contentAreaNode);
  437. }
  438. }.bind(this), function (error) {
  439. this.hiddenLoading();
  440. console.log(error);
  441. this.app.notice(error, "error", this.contentAreaNode);
  442. }.bind(this));
  443. }.bind(this));
  444. },
  445. // 提交打包
  446. submitPack: function () {
  447. var appName = this.apppackAppNameInputNode.get("value");
  448. if (!appName || appName === "") {
  449. this.app.notice(this.lp.mobile_apppack_message_appname_not_empty, "error", this.contentAreaNode);
  450. return;
  451. }
  452. if (appName.length > 6) {
  453. this.app.notice(this.lp.mobile_apppack_message_appname_len_max_6, "error", this.contentAreaNode);
  454. return;
  455. }
  456. var files = this.apppackLogoInputNode.files;
  457. if (files.length) {
  458. var file = files.item(0);
  459. var fileExt = file.name.substring(file.name.lastIndexOf("."));
  460. if (fileExt.toLowerCase() !== ".png") {
  461. this.app.notice(this.lp.mobile_apppack_message_app_logo_need_png, "error", this.contentAreaNode);
  462. return;
  463. }
  464. } else {
  465. this.app.notice(this.lp.mobile_apppack_message_app_logo_not_empty, "error", this.contentAreaNode);
  466. return;
  467. }
  468. var protocol = this.apppackProtocolInputNode.get("value");
  469. if (!protocol || protocol === "") {
  470. this.app.notice(this.lp.mobile_apppack_message_portocol_not_empty, "error", this.contentAreaNode);
  471. return;
  472. }
  473. if (protocol !== "http" && protocol !== "https") {
  474. this.app.notice(this.lp.mobile_apppack_message_portocol_http_https, "error", this.contentAreaNode);
  475. return;
  476. }
  477. var host = this.apppackHostInputNode.get("value");
  478. if (!host || host === "") {
  479. this.app.notice(this.lp.mobile_apppack_message_host_not_empty, "error", this.contentAreaNode);
  480. return;
  481. }
  482. if (host.startsWith("http://") || host.startsWith("https://")) {
  483. this.app.notice(this.lp.mobile_apppack_message_host_format_error, "error", this.contentAreaNode);
  484. return;
  485. }
  486. if (host.indexOf(":") > 0) {
  487. this.app.notice(this.lp.mobile_apppack_message_host_format_error, "error", this.contentAreaNode);
  488. return;
  489. }
  490. var port = this.apppackPortInputNode.get("value");
  491. if (!port || port === "") {
  492. this.app.notice(this.lp.mobile_apppack_message_port_not_empty, "error", this.contentAreaNode);
  493. return;
  494. }
  495. var context = this.apppackContextInputNode.get("value");
  496. if (!context || context === "") {
  497. this.app.notice(this.lp.mobile_apppack_message_context_not_empty, "error", this.contentAreaNode);
  498. return;
  499. }
  500. var appVersionName = this.apppackAppVersionNameInputNode.get("value");
  501. var appBuildNo = this.apppackAppBuildNoInputNode.get("value");
  502. var isPackAppIdOuter = this.apppackIsPackAppIdOuterInputNode.checked ? "2" : "1";
  503. // var deleteHms = this.apppackIsDeleteHmsInputNode.checked ? "2" : "1";
  504. var urlMapping = this.apppackUrlMappingInputNode.get("value");
  505. this.confirm(this.lp.alert, this.lp.mobile_apppack_message_alert_submit, function() {
  506. this.showLoading();
  507. var formData = new FormData();
  508. formData.append('file', file);
  509. formData.append('fileName', file.name);
  510. formData.append('appName', appName);
  511. formData.append('o2ServerProtocol', protocol);
  512. formData.append('o2ServerHost', host);
  513. formData.append('o2ServerPort', port);
  514. formData.append('o2ServerContext', context);
  515. formData.append('appVersionName', appVersionName);
  516. formData.append('appBuildNo', appBuildNo);
  517. formData.append('isPackAppIdOuter', isPackAppIdOuter);
  518. formData.append('deleteHuawei', "1");
  519. formData.append('urlMapping', urlMapping);
  520. formData.append('token', this.token);
  521. o2.Actions.load("x_program_center").AppPackAction.androidPackStart(formData, "{}",function (json) {
  522. console.log(json)
  523. this.hiddenLoading();
  524. if (json.data && json.data.value) {
  525. // 提交成功 获取最新打包对象信息
  526. this.loadAppPackInfo();
  527. } else {
  528. this.app.notice(json.message, "error", this.contentAreaNode);
  529. }
  530. }.bind(this), function (error) {
  531. this.hiddenLoading();
  532. console.log(error);
  533. this.app.notice(error, "error", this.contentAreaNode);
  534. }.bind(this));
  535. }.bind(this));
  536. },
  537. //确认
  538. confirm: function (title, text, okCallback) {
  539. var width = 600;
  540. var height = 110;
  541. var size = this.app.content.getSize();
  542. var x = (size.x - width) / 2;
  543. var y = (size.y - height) / 2;
  544. MWF.require("MWF.xDesktop.Dialog", function () {
  545. var dlg = new MWF.xDesktop.Dialog({
  546. "title": title,
  547. "style": "settingStyle",
  548. "top": y,
  549. "left": x,
  550. "width": width,
  551. "height": height,
  552. "text": text,
  553. "maskNode": this.app.content,
  554. "container": this.app.content,
  555. "buttonList": [
  556. {
  557. "text": this.lp.ok,
  558. "action": function () {
  559. if (okCallback) { okCallback(); }
  560. this.close();
  561. }
  562. },
  563. {
  564. "text": this.lp.cancel,
  565. "action": function () { this.close(); }
  566. }
  567. ]
  568. });
  569. dlg.show();
  570. }.bind(this));
  571. }
  572. });
  573. // 微信菜单
  574. MWF.xApplication.Setting.MPWeixinMenuSettingDocument = new Class({
  575. Extends: MWF.xApplication.Setting.Document,
  576. load: function () {
  577. var cssurl = "../x_component_Setting/$Main/default/mpweixin/mpweixin.css";
  578. var htmlurl = "../x_component_Setting/$Main/default/mpweixin/menu.html";
  579. this.contentAreaNode.loadAll({ "css": [cssurl], "html": [htmlurl] }, { "bind": { "lp": this.lp, "data": {} }, "module": this }, function () {
  580. this.node = this.mpwxMenuNode;
  581. this.initMenuData();
  582. this.loadMenu();
  583. this.loadPublishBtn();
  584. this.subscribeEvent();
  585. }.bind(this));
  586. },
  587. initMenuData: function() {
  588. //处理数据
  589. // var list = this.explorer.mpweixinListData;
  590. if (!this.menuList) {
  591. this.menuList = this.explorer.mpweixinListData || [];
  592. }
  593. //去除 subscribe
  594. var subscribe = null;
  595. for (let index = 0; index < this.menuList.length; index++) {
  596. const element = this.menuList[index];
  597. if (element.type && element.type === "subscribe") {
  598. subscribe = element;
  599. }
  600. }
  601. if (subscribe) {
  602. this.menuList.erase(subscribe);
  603. }
  604. },
  605. //发布菜单 点击事件
  606. loadPublishBtn: function() {
  607. this.mpwxPublishBtnNode.addEvents({
  608. "click": function(){
  609. if (this.menuList && this.menuList.length > 0) {
  610. this.confirm(this.lp.alert, this.lp.mobile_mpweixin_menu_msg_publish_2_wxmp, function () {
  611. o2.Actions.load("x_program_center").MPWeixinAction.menuCreate2Weixin(function (json) {
  612. this.app.notice(this.lp.mobile_mpweixin_menu_msg_publish_success, "success", this.contentAreaNode);
  613. }.bind(this));
  614. }.bind(this));
  615. }
  616. }.bind(this)
  617. });
  618. },
  619. // 关注回复消息
  620. subscribeEvent: function() {
  621. if (this.explorer.mpweixinSubscribe) {
  622. this.mpweixinSubscribe = this.explorer.mpweixinSubscribe;
  623. if (this.mpweixinSubscribe.name && this.mpweixinSubscribe.name !== "") { //已经存在 name肯定不为空
  624. this.mpwxMenuSubscribeInputNode.set("value", this.mpweixinSubscribe.content || "");
  625. } else { // 新的 没有数据
  626. this.mpweixinSubscribe = {
  627. id: "mock_new",
  628. name: "subscribe",
  629. type: "subscribe"
  630. };
  631. }
  632. } else {
  633. this.mpweixinSubscribe = {
  634. id: "mock_new",
  635. name: "subscribe",
  636. type: "subscribe"
  637. };
  638. }
  639. //保存事件
  640. this.mpwxSaveSubscribeBtnNode.addEvents({
  641. "click": function(){
  642. this.saveSubscribeMenu();
  643. }.bind(this)
  644. });
  645. },
  646. saveSubscribeMenu: function() {
  647. var content = this.mpwxMenuSubscribeInputNode.get("value");
  648. if (!content || content === "") {
  649. this.app.notice(this.lp.mobile_mpweixin_menu_form_subscribe_content_error_empty, "error", this.contentAreaNode);
  650. return;
  651. }
  652. this.mpweixinSubscribe.content = content;
  653. //新建的菜单 click类型需要设置key
  654. if (this.mpweixinSubscribe.id.startsWith('mock_')) {
  655. delete this.mpweixinSubscribe.id; //新增要删除id
  656. }
  657. //写入数据 远程写入 还有 上级数组中
  658. if (!this.mpweixinSubscribe.id) { //新增
  659. o2.Actions.load("x_program_center").MPWeixinAction.menuAdd(this.mpweixinSubscribe,function (json) {
  660. this.app.notice(this.lp.mobile_mpweixin_menu_save_success, "success", this.contentAreaNode);
  661. }.bind(this));
  662. }else { // 更新
  663. o2.Actions.load("x_program_center").MPWeixinAction.menuUpdate(this.mpweixinSubscribe.id, this.mpweixinSubscribe,function (json) {
  664. this.app.notice(this.lp.mobile_mpweixin_menu_save_success, "success", this.contentAreaNode);
  665. }.bind(this));
  666. }
  667. },
  668. loadMenu: function () {
  669. this.mpwxMenuListNode.empty();
  670. // 生成菜单
  671. if (this.menuList && this.menuList.length > 0) {
  672. if (!this.showSubId) {
  673. this.showSubId = this.menuList[0].id;//初始化 showSubId 表示哪个子菜单是显示的
  674. }
  675. if (!this.currentMenuId) {
  676. this.currentMenuId = this.menuList[0].id;//初始化 currentMenuId 表示当前选中的菜单ID
  677. }
  678. for (let index = 0; index < this.menuList.length; index++) {
  679. const element = this.menuList[index];
  680. this.firstLevelMenu(element);
  681. }
  682. }
  683. this.firstLevelAddButton();
  684. },
  685. //第一层级的新建按钮
  686. firstLevelAddButton: function () {
  687. var addLi = new Element("li", { "class": "js_addMenuBox pre_menu_item grid_item no_extra" }).inject(this.mpwxMenuListNode);
  688. new Element("a", { "class": "pre_menu_link js_addL1Btn", "href": "javascript:void(0);" }).inject(addLi);
  689. new Element("i", { "class": "icon14_menu_add" }).inject(addLi);
  690. //点击事件
  691. addLi.addEvents({
  692. "click": function () {
  693. this.createNewFirstMenuMock();
  694. }.bind(this)
  695. });
  696. },
  697. // 第一层级 菜单 UI
  698. // <li class="jsMenu pre_menu_item grid_item jslevel1 ui-sortable ui-sortable-disabled size1of3 current selected" id="menu_0">
  699. // <a href="javascript:void(0);" class="pre_menu_link" draggable="false">
  700. // <i class="icon_menu_dot js_icon_menu_dot dn" style="display: none;"></i>
  701. // <i class="icon20_common sort_gray"></i>
  702. // <span class="js_l1Title">菜单名称</span>
  703. // </a>
  704. // <div class="sub_pre_menu_box js_l2TitleBox" >
  705. // <ul class="sub_pre_menu_list">
  706. // <li id="1618290787255_subMenu_menu_0_0" class="jslevel2">
  707. // <a href="javascript:void(0);" class="jsSubView" draggable="false">
  708. // <span class="sub_pre_menu_inner js_sub_pre_menu_inner">
  709. // <i class="icon20_common sort_gray"></i>
  710. // <span class="js_l2Title">子菜单名称单名称</span>
  711. // </span>
  712. // </a>
  713. // </li>
  714. // <li id="1618290787255_subMenu_menu_0_0" class="jslevel2 current"><a href="javascript:void(0);" class="jsSubView" draggable="false"><span class="sub_pre_menu_inner js_sub_pre_menu_inner"><i class="icon20_common sort_gray"></i><span class="js_l2Title">子菜单名称</span></span></a></li>
  715. // <li class="js_addMenuBox">
  716. // <a href="javascript:void(0);" class="jsSubView js_addL2Btn" title="最多添加5个子菜单" draggable="false">
  717. // <span class="sub_pre_menu_inner js_sub_pre_menu_inner">
  718. // <i class="icon14_menu_add"></i></span></a>
  719. // </li>
  720. // </ul>
  721. // <i class="arrow arrow_out"></i>
  722. // <i class="arrow arrow_in"></i>
  723. // </div>
  724. // </li>
  725. firstLevelMenu: function (menu) {
  726. var sub_button = menu.sub_button;
  727. var menuClass = "jsMenu pre_menu_item grid_item jslevel1 ui-sortable ui-sortable-disabled size1of3";
  728. if (this.currentMenuId && this.currentMenuId === menu.id) {
  729. menuClass = "jsMenu pre_menu_item grid_item jslevel1 ui-sortable ui-sortable-disabled size1of3 current";
  730. }
  731. var menuLi = new Element("li", { "class": menuClass }).inject(this.mpwxMenuListNode);
  732. var menuA = new Element("a", { "class": "pre_menu_link", "href": "javascript:void(0);" }).inject(menuLi);
  733. new Element("span", { "class": "js_l1Title", "text": menu.name }).inject(menuA);
  734. menuLi.addEvents({
  735. "click": function () {
  736. menu.o2Level = "1"
  737. this.clickMenu(menu.id, menu);
  738. }.bind(this)
  739. });
  740. //子菜单
  741. var subDiv = new Element("div", { "class": "sub_pre_menu_box js_l2TitleBox" }).inject(menuLi);
  742. var subUl = new Element("ul", { "class": "sub_pre_menu_list" }).inject(subDiv);
  743. if (!sub_button || sub_button.length < 5) {
  744. this.secondLevelAddButton(menu, subUl); //新增按钮放上面
  745. }
  746. if (sub_button && sub_button.length > 0) {
  747. // 子菜单是倒叙的
  748. sub_button.sort(function (a, b) {
  749. var x = a.order.toLowerCase();
  750. var y = b.order.toLowerCase();
  751. if (x < y) { return 1; }
  752. if (x > y) { return -1; }
  753. return 0;
  754. })
  755. for (let index = 0; index < sub_button.length; index++) {
  756. const element = sub_button[index];
  757. this.secondLevelMenu(element, subUl, menu);
  758. }
  759. }
  760. new Element("i", { "class": "arrow arrow_out" }).inject(subDiv);
  761. new Element("i", { "class": "arrow arrow_in" }).inject(subDiv);
  762. if (this.showSubId && this.showSubId === menu.id) {
  763. subDiv.setStyles({
  764. "display": ""
  765. });
  766. } else {
  767. subDiv.setStyles({
  768. "display": "none"
  769. });
  770. }
  771. },
  772. // 子菜单 新建按钮
  773. secondLevelAddButton: function (parentMenu, parentNode) {
  774. var addLi = new Element("li", { "class": "js_addMenuBox" }).inject(parentNode);
  775. var addA = new Element("a", { "class": "jsSubView js_addL2Btn", "href": "javascript:void(0);" }).inject(addLi);
  776. var span = new Element("span", { "class": "sub_pre_menu_inner js_sub_pre_menu_inner" }).inject(addA);
  777. new Element("i", { "class": "icon14_menu_add" }).inject(span);
  778. addLi.addEvents({
  779. "click": function (ev) {
  780. console.log("点击了新增,属于 " + parentMenu.name);
  781. this.createNewSubMenuMock(parentMenu);
  782. ev.stopPropagation()
  783. }.bind(this)
  784. });
  785. },
  786. // 子菜单 UI
  787. secondLevelMenu: function (menu, parentNode, parentMenu) {
  788. var menuClass = "jslevel2";
  789. if (this.currentMenuId && this.currentMenuId === menu.id) {
  790. menuClass = "jslevel2 current";
  791. }
  792. var menuLi = new Element("li", { "class": menuClass }).inject(parentNode);
  793. var menuA = new Element("a", { "class": "jsSubView", "href": "javascript:void(0);" }).inject(menuLi);
  794. var firstSapn = new Element("span", { "class": "sub_pre_menu_inner js_sub_pre_menu_inner" }).inject(menuA);
  795. new Element("i", { "class": "icon20_common sort_gray" }).inject(firstSapn);
  796. new Element("span", { "class": "js_l2Title", "text": menu.name }).inject(firstSapn);
  797. menuLi.addEvents({
  798. "click": function (ev) {
  799. menu.o2Level = "2"
  800. this.clickMenu(parentMenu.id, menu);
  801. ev.stopPropagation();
  802. }.bind(this)
  803. });
  804. },
  805. //右边区域 装载
  806. menuRightBoxCreate: function (menu) {
  807. this.mpwxMenuFormHeaderNode.empty();
  808. // 头部
  809. new Element("h4", { "class": "global_info", "text": menu.name }).inject(this.mpwxMenuFormHeaderNode);
  810. var deleteNode = new Element("div", { "class": "global_extra" }).inject(this.mpwxMenuFormHeaderNode);
  811. var deleteA = new Element("a", { "href": "javascript:void(0);", "text": this.lp.mobile_mpweixin_menu_deleteBtnName_label }).inject(deleteNode);
  812. deleteA.addEvents({
  813. "click": function (ev) {
  814. this.deleteAction(menu);
  815. ev.stopPropagation();
  816. }.bind(this)
  817. })
  818. // 表单页面
  819. new MWF.xApplication.Setting.MPWeixinMenuSettingDocument.MenuForm(this, this.mpwxMenuFormNode, menu);
  820. },
  821. //点击菜单执行
  822. clickMenu: function (showSubId, menu) {
  823. this.showSubId = showSubId; //showSubId 表示哪个子菜单是显示的
  824. this.currentMenuId = menu.id;//currentMenuId 表示当前选中的菜单ID
  825. this.menuRightBoxCreate(menu);
  826. this.loadMenu();
  827. },
  828. //创建子菜单
  829. createNewSubMenuMock: function (parent) {
  830. let sub = parent.sub_button;
  831. //最多可创建5个
  832. if (sub && sub.length >= 5 ) {
  833. this.app.notice(this.lp.mobile_mpweixin_menu_msg_sub_max_len, "error", this.contentAreaNode);
  834. return;
  835. }
  836. if (parent.id.startsWith('mock_')) {
  837. this.app.notice(this.lp.mobile_mpweixin_menu_msg_parent_no_save, "error", this.contentAreaNode);
  838. return;
  839. }
  840. // 排序号生成
  841. let order = "000001";
  842. if (sub && sub.length > 0) {
  843. let bigestOrder = sub[0].order;//第一条 因为上面已经排序过了 所以第一条是最大的
  844. const intOrder = parseInt(bigestOrder);
  845. if (!isNaN(intOrder)) {
  846. let o = intOrder + 1;
  847. let os = '' + o;
  848. for (let len = os.length; len < 6; len = os.length) {
  849. os = "0" + os;
  850. }
  851. order = os;
  852. }
  853. }
  854. // id mock_开头 正式保存的时候知道是新增的 可以清除 后台生成id
  855. let body = {
  856. "id": "mock_" + o2.uuid(),
  857. "name": this.lp.mobile_mpweixin_menu_default_new_name,
  858. "parentId": parent.id,
  859. "type": "click", //默认文字消息
  860. "order": order,
  861. "o2Level": "2" // 2第二层级菜单
  862. };
  863. if (sub) {
  864. parent.sub_button.push(body);
  865. } else {
  866. parent.sub_button = [body];
  867. }
  868. for (let index = 0; index < this.menuList.length; index++) {
  869. const element = this.menuList[index];
  870. if (element.id === parent.id) {
  871. this.menuList[index] = parent;
  872. }
  873. }
  874. this.clickMenu(parent.id, body);
  875. },
  876. // 创建第一层菜单
  877. createNewFirstMenuMock: function() {
  878. //最多可创建3个
  879. if (this.menuList && this.menuList.length >=3 ) {
  880. this.app.notice(this.lp.mobile_mpweixin_menu_msg_first_max_len, "error", this.contentAreaNode);
  881. return;
  882. }
  883. // 排序号生成
  884. let order = "000001";
  885. if (this.menuList && this.menuList.length > 0) {
  886. let bigestOrder = this.menuList[this.menuList.length-1].order;//最后一条是最大的号码
  887. console.log("最大的order " + bigestOrder);
  888. const intOrder = parseInt(bigestOrder);
  889. if (!isNaN(intOrder)) {
  890. let o = intOrder + 1;
  891. let os = '' + o;
  892. for (let len = os.length; len < 6; len = os.length) {
  893. os = "0" + os;
  894. }
  895. order = os;
  896. }
  897. console.log("最大的order " + intOrder);
  898. }
  899. // id mock_开头 正式保存的时候知道是新增的 可以清除 后台生成id
  900. let body = {
  901. "id": "mock_" + o2.uuid(),
  902. "name": this.lp.mobile_mpweixin_menu_default_new_name,
  903. "type": "click", //默认文字消息
  904. "order": order,
  905. "o2Level": "1" // 1第一层级菜单
  906. };
  907. if (this.menuList) {
  908. this.menuList.push(body);
  909. } else {
  910. this.menuList = [body];
  911. }
  912. this.clickMenu(body.id, body);
  913. },
  914. // 更新list中的数据对象
  915. setMenuData(menu) {
  916. if (this.menuList && this.menuList.length > 0) {
  917. for (let index = 0; index < this.menuList.length; index++) {
  918. const element = this.menuList[index];
  919. if (element.id === menu.id) {
  920. this.menuList[index] = menu;
  921. break;
  922. }
  923. var flag = false;
  924. if (element.sub_button && element.sub_button.length > 0) {
  925. for (let i = 0; i < element.sub_button.length; i++) {
  926. const child = element.sub_button[i];
  927. if (child.id === menu.id) {
  928. flag = true;
  929. element.sub_button[i] = menu;
  930. }
  931. }
  932. }
  933. if (flag) {
  934. this.menuList[index] = element;
  935. break;
  936. }
  937. }
  938. this.loadMenu();
  939. }
  940. },
  941. // 删除数据
  942. deleteAction: function(menu) {
  943. if (menu.id) {
  944. if (menu.id.startsWith("mock_")) {
  945. console.log("没有保存到数据库的数据 直接删除就行。");
  946. this.removeDataUI(menu);
  947. }else {
  948. this.confirm(this.lp.alert, this.lp.mobile_mpweixin_menu_delete_alert_msg, function () {
  949. o2.Actions.load("x_program_center").MPWeixinAction.menuDelete(menu.id,function (json) {
  950. //刷新数据
  951. this.removeDataUI(menu);
  952. this.app.notice(this.lp.mobile_mpweixin_menu_delete_success, "success", this.contentAreaNode);
  953. }.bind(this));
  954. }.bind(this));
  955. }
  956. }
  957. },
  958. // 删除数据后更新ui
  959. removeDataUI: function(menu) {
  960. this.mpwxMenuFormHeaderNode.empty();
  961. this.mpwxMenuFormNode.empty();
  962. this.showSubId = null;
  963. this.currentMenuId = null;
  964. if (this.menuList && this.menuList.length > 0) {
  965. for (let index = 0; index < this.menuList.length; index++) {
  966. const element = this.menuList[index];
  967. if (element.id === menu.id) {
  968. this.menuList.erase(menu);
  969. console.log("删除成功。。。。。上级")
  970. break;
  971. }
  972. var flag = false;
  973. if (element.sub_button && element.sub_button.length > 0) {
  974. for (let i = 0; i < element.sub_button.length; i++) {
  975. const child = element.sub_button[i];
  976. if (child.id === menu.id) {
  977. flag = true;
  978. element.sub_button.erase(menu);
  979. console.log("删除成功。。。。子级。")
  980. }
  981. }
  982. }
  983. if (flag) {
  984. this.menuList[index] = element;
  985. break;
  986. }
  987. }
  988. this.loadMenu();
  989. }
  990. },
  991. //确认
  992. confirm: function (title, text, okCallback) {
  993. var width = 600;
  994. var height = 110;
  995. var size = this.app.content.getSize();
  996. var x = (size.x - width) / 2;
  997. var y = (size.y - height) / 2;
  998. MWF.require("MWF.xDesktop.Dialog", function () {
  999. var dlg = new MWF.xDesktop.Dialog({
  1000. "title": title,
  1001. "style": "settingStyle",
  1002. "top": y,
  1003. "left": x,
  1004. "width": width,
  1005. "height": height,
  1006. "text": text,
  1007. "maskNode": this.app.content,
  1008. "container": this.app.content,
  1009. "buttonList": [
  1010. {
  1011. "text": this.lp.ok,
  1012. "action": function () {
  1013. if (okCallback) { okCallback(); }
  1014. this.close();
  1015. }
  1016. },
  1017. {
  1018. "text": this.lp.cancel,
  1019. "action": function () { this.close(); }
  1020. }
  1021. ]
  1022. });
  1023. dlg.show();
  1024. }.bind(this));
  1025. }
  1026. });
  1027. //菜单表单功能
  1028. MWF.xApplication.Setting.MPWeixinMenuSettingDocument.MenuForm = new Class({
  1029. Implements: [Options, Events],
  1030. initialize: function (menuApp, contentAreaNode, menu, options) {
  1031. this.setOptions(options);
  1032. this.menuApp = menuApp;
  1033. this.explorer = menuApp.explorer;
  1034. this.app = this.explorer.app;
  1035. this.lp = this.app.lp;
  1036. this.contentAreaNode = contentAreaNode;
  1037. this.actions = this.app.actions;
  1038. this.css = this.app.css;
  1039. this.menu = menu;
  1040. this.load();
  1041. },
  1042. load: function () {
  1043. this.contentAreaNode.empty();
  1044. this.nameInputCreate();
  1045. this.orderInputCreate();
  1046. if (this.menu.sub_button && this.menu.sub_button.length > 0) { //父菜单 如果存在子菜单就不需要编辑类型
  1047. this.haSubMenus = true;
  1048. } else {
  1049. this.haSubMenus = false;
  1050. this.typeRadioCreate();
  1051. }
  1052. this.saveButtonCreate();
  1053. },
  1054. //菜单名称
  1055. nameInputCreate: function () {
  1056. this.nameInputBoxNode = new Element("div", { "class": "frm_control_group js_setNameBox" }).inject(this.contentAreaNode);
  1057. var labelNode = new Element("label", { "class": "frm_label" }).inject(this.nameInputBoxNode);
  1058. new Element("strong", { "class": "title js_menuTitle", "text": this.lp.mobile_mpweixin_menu_form_name_label }).inject(labelNode);
  1059. var inputNode = new Element("div", { "class": "frm_controls" }).inject(this.nameInputBoxNode);
  1060. var spanNode = new Element("span", { "class": "frm_input_box with_counter counter_in append" }).inject(inputNode);
  1061. this.nameInputNode = new Element("input", { "class": "frm_input js_menu_name", "type": "text", "value": this.menu.name }).inject(spanNode);
  1062. //事件?
  1063. var nameTips = this.lp.mobile_mpweixin_menu_form_name_tips_4
  1064. if (this.menu.o2Level && this.menu.o2Level === "1"){
  1065. nameTips = this.lp.mobile_mpweixin_menu_form_name_tips_4
  1066. } else {
  1067. nameTips = this.lp.mobile_mpweixin_menu_form_name_tips_6
  1068. }
  1069. this.nameInputTipsNode = new Element("p", { "class": "frm_tips js_titleNolTips", "text": nameTips }).inject(inputNode);
  1070. this.nameInputErrorTipsNode = new Element("p", { "class": "frm_msg fail js_titleEorTips dn", "text": this.lp.mobile_mpweixin_menu_form_name_error }).inject(inputNode);
  1071. },
  1072. //菜单排序号
  1073. orderInputCreate: function () {
  1074. this.orderInputBoxNode = new Element("div", { "class": "frm_control_group js_setNameBox" }).inject(this.contentAreaNode);
  1075. var labelNode = new Element("label", { "class": "frm_label" }).inject(this.orderInputBoxNode);
  1076. new Element("strong", { "class": "title js_menuTitle", "text": this.lp.mobile_mpweixin_menu_form_order_label }).inject(labelNode);
  1077. var inputNode = new Element("div", { "class": "frm_controls" }).inject(this.orderInputBoxNode);
  1078. var spanNode = new Element("span", { "class": "frm_input_box with_counter counter_in append" }).inject(inputNode);
  1079. this.orderInputNode = new Element("input", { "class": "frm_input js_menu_name", "type": "text", "value": this.menu.order }).inject(spanNode);
  1080. //事件?
  1081. this.orderInputTipsNode = new Element("p", { "class": "frm_tips js_titleNolTips", "text": this.lp.mobile_mpweixin_menu_form_order_tips }).inject(inputNode);
  1082. this.orderInputErrorTipsNode = new Element("p", { "class": "frm_msg fail js_titleEorTips dn", "text": this.lp.mobile_mpweixin_menu_form_order_error }).inject(inputNode);
  1083. },
  1084. //菜单类型
  1085. typeRadioCreate: function () {
  1086. this.typeRadioBoxNode = new Element("div", { "class": "frm_control_group" }).inject(this.contentAreaNode);
  1087. var labelNode = new Element("label", { "class": "frm_label" }).inject(this.typeRadioBoxNode);
  1088. new Element("strong", { "class": "title js_menuContent", "text": this.lp.mobile_mpweixin_menu_form_radio_label }).inject(labelNode);
  1089. var groupNode = new Element("div", { "class": "frm_controls frm_vertical_pt" }).inject(this.typeRadioBoxNode);
  1090. //消息类型
  1091. this.msgTypeRadioBoxNode = new Element("label", { "class": "frm_radio_label js_radio_sendMsg" }).inject(groupNode);
  1092. new Element("i", { "class": "icon_radio" }).inject(this.msgTypeRadioBoxNode);
  1093. new Element("span", { "class": "lbl_content", "text": this.lp.mobile_mpweixin_menu_form_radio_type_msg }).inject(this.msgTypeRadioBoxNode);
  1094. new Element("input", { "class": "frm_radio", "type": "radio" }).inject(this.msgTypeRadioBoxNode);
  1095. this.msgTypeRadioBoxNode.addEvents({
  1096. "click": function () {
  1097. this.changeMenuType("click")
  1098. }.bind(this)
  1099. });
  1100. //网页类型
  1101. this.urlTypeRadioBoxNode = new Element("label", { "class": "frm_radio_label js_radio_sendMsg" }).inject(groupNode);
  1102. new Element("i", { "class": "icon_radio" }).inject(this.urlTypeRadioBoxNode);
  1103. new Element("span", { "class": "lbl_content", "text": this.lp.mobile_mpweixin_menu_form_radio_type_url }).inject(this.urlTypeRadioBoxNode);
  1104. new Element("input", { "class": "frm_radio", "type": "radio" }).inject(this.urlTypeRadioBoxNode);
  1105. this.urlTypeRadioBoxNode.addEvents({
  1106. "click": function () {
  1107. this.changeMenuType("view")
  1108. }.bind(this)
  1109. });
  1110. //小程序
  1111. this.miniprogramTypeRadioBoxNode = new Element("label", { "class": "frm_radio_label js_radio_sendMsg" }).inject(groupNode);
  1112. new Element("i", { "class": "icon_radio" }).inject(this.miniprogramTypeRadioBoxNode);
  1113. new Element("span", { "class": "lbl_content", "text": this.lp.mobile_mpweixin_menu_form_radio_type_miniprogram }).inject(this.miniprogramTypeRadioBoxNode);
  1114. new Element("input", { "class": "frm_radio", "type": "radio" }).inject(this.miniprogramTypeRadioBoxNode);
  1115. this.miniprogramTypeRadioBoxNode.addEvents({
  1116. "click": function () {
  1117. this.changeMenuType("miniprogram")
  1118. }.bind(this)
  1119. });
  1120. // 3个类型的具体内容
  1121. this.typeContentCreate();
  1122. this.changeMenuType(this.menu.type)
  1123. },
  1124. //保存按钮
  1125. saveButtonCreate: function () {
  1126. //<span id="pubBt" class="btn btn_input btn_primary"><button>保存并发布</button></span>
  1127. var buttonDiv = new Element("div", { "class": "btn-box" }).inject(this.contentAreaNode);
  1128. this.submitButtonNode = new Element("span", { "class": "btn btn_input btn_primary" }).inject(buttonDiv);
  1129. new Element("button", { "text": this.lp.save }).inject(this.submitButtonNode);
  1130. this.submitButtonNode.addEvents({
  1131. "click": function () {
  1132. this.submitAction();
  1133. }.bind(this)
  1134. })
  1135. },
  1136. typeContentCreate: function () {
  1137. var outContentNode = new Element("div", { "class": "menu_content_container" }).inject(this.contentAreaNode);
  1138. this.msgContentCreate(outContentNode);
  1139. this.urlContentCreate(outContentNode);
  1140. this.miniprogramContentCreate(outContentNode);
  1141. },
  1142. //文字消息
  1143. msgContentCreate: function (outContentNode) {
  1144. this.msgTypeContentNode = new Element("div", { "class": "menu_content dn" }).inject(outContentNode);
  1145. new Element("p", { "class": "menu_content_tips tips_global js_url_tips", "text": this.lp.mobile_mpweixin_menu_form_type_msg_tips }).inject(this.msgTypeContentNode);
  1146. var inputOutNode = new Element("div", { "class": "frm_control_group js_setNameBox" }).inject(this.msgTypeContentNode);
  1147. new Element("label", { "class": "frm_label", "text": this.lp.mobile_mpweixin_menu_form_type_msg_label }).inject(inputOutNode);
  1148. var inputNode = new Element("div", { "class": "frm_controls" }).inject(inputOutNode);
  1149. var spanNode = new Element("span", { "class": "frm_textarea_box with_counter counter_in append" }).inject(inputNode);
  1150. this.msgTypeContentInputNode = new Element("textarea", { "class": "frm_textarea js_menu_name", "value": this.menu.content }).inject(spanNode);
  1151. },
  1152. // 网页链接
  1153. urlContentCreate: function (outContentNode) {
  1154. this.urlTypeContentNode = new Element("div", { "class": "menu_content dn" }).inject(outContentNode);
  1155. new Element("p", { "class": "menu_content_tips tips_global js_url_tips", "text": this.lp.mobile_mpweixin_menu_form_type_url_tips }).inject(this.urlTypeContentNode);
  1156. var inputOutNode = new Element("div", { "class": "frm_control_group js_setNameBox" }).inject(this.urlTypeContentNode);
  1157. new Element("label", { "class": "frm_label", "text": this.lp.mobile_mpweixin_menu_form_type_url_label }).inject(inputOutNode);
  1158. var inputNode = new Element("div", { "class": "frm_controls" }).inject(inputOutNode);
  1159. var spanNode = new Element("span", { "class": "frm_input_box with_counter counter_in append" }).inject(inputNode);
  1160. this.urlTypeContentInputNode = new Element("input", { "class": "frm_input js_menu_name", "type": "text", "value": this.menu.url }).inject(spanNode);
  1161. },
  1162. // 小程序
  1163. miniprogramContentCreate: function (outContentNode) {
  1164. this.miniprogramTypeContentNode = new Element("div", { "class": "menu_content dn" }).inject(outContentNode);
  1165. new Element("p", { "class": "menu_content_tips tips_global js_url_tips", "text": this.lp.mobile_mpweixin_menu_form_type_miniprogram_tips }).inject(this.miniprogramTypeContentNode);
  1166. // 小程序id
  1167. var inputOutNode = new Element("div", { "class": "frm_control_group js_setNameBox" }).inject(this.miniprogramTypeContentNode);
  1168. new Element("label", { "class": "frm_label", "text": this.lp.mobile_mpweixin_menu_form_type_miniprogram_appid_label }).inject(inputOutNode);
  1169. var inputNode = new Element("div", { "class": "frm_controls" }).inject(inputOutNode);
  1170. var spanNode = new Element("span", { "class": "frm_input_box with_counter counter_in append" }).inject(inputNode);
  1171. this.miniprogramTypeAppIdContentInputNode = new Element("input", { "class": "frm_input js_menu_name", "type": "text", "value": this.menu.appid , "placeholder": this.lp.mobile_mpweixin_menu_form_type_miniprogram_appid_placeholder }).inject(spanNode);
  1172. // 小程序路径
  1173. var inputPathOutNode = new Element("div", { "class": "frm_control_group js_setNameBox" }).inject(this.miniprogramTypeContentNode);
  1174. new Element("label", { "class": "frm_label", "text": this.lp.mobile_mpweixin_menu_form_type_miniprogram_path_label }).inject(inputPathOutNode);
  1175. var inputPathNode = new Element("div", { "class": "frm_controls" }).inject(inputPathOutNode);
  1176. var spanPathNode = new Element("span", { "class": "frm_input_box with_counter counter_in append" }).inject(inputPathNode);
  1177. this.miniprogramTypePathContentInputNode = new Element("input", { "class": "frm_input js_menu_name", "type": "text", "value": this.menu.pagepath , "placeholder": this.lp.mobile_mpweixin_menu_form_type_miniprogram_path_placeholder }).inject(spanPathNode);
  1178. // 备用网页
  1179. var inputUrlOutNode = new Element("div", { "class": "frm_control_group js_setNameBox" }).inject(this.miniprogramTypeContentNode);
  1180. new Element("label", { "class": "frm_label", "text": this.lp.mobile_mpweixin_menu_form_type_miniprogram_url_label }).inject(inputUrlOutNode);
  1181. var inputUrlNode = new Element("div", { "class": "frm_controls" }).inject(inputUrlOutNode);
  1182. var spanUrlNode = new Element("span", { "class": "frm_input_box with_counter counter_in append" }).inject(inputUrlNode);
  1183. this.miniprogramTypeUrlContentInputNode = new Element("input", { "class": "frm_input js_menu_name", "type": "text", "value": this.menu.url , "placeholder": this.lp.mobile_mpweixin_menu_form_type_miniprogram_url_placeholder }).inject(spanUrlNode);
  1184. },
  1185. changeMenuType: function (type) {
  1186. if (type) {
  1187. this.menu.type = type;
  1188. if (type === "view") {
  1189. this.msgTypeRadioBoxNode.removeClass("selected");
  1190. this.msgTypeContentNode.addClass("dn");
  1191. this.urlTypeRadioBoxNode.addClass("selected");
  1192. this.urlTypeContentNode.removeClass("dn");
  1193. this.miniprogramTypeRadioBoxNode.removeClass("selected");
  1194. this.miniprogramTypeContentNode.addClass("dn");
  1195. } else if (type === "miniprogram") {
  1196. this.msgTypeRadioBoxNode.removeClass("selected");
  1197. this.msgTypeContentNode.addClass("dn");
  1198. this.urlTypeRadioBoxNode.removeClass("selected");
  1199. this.urlTypeContentNode.addClass("dn");
  1200. this.miniprogramTypeRadioBoxNode.addClass("selected");
  1201. this.miniprogramTypeContentNode.removeClass("dn");
  1202. } else {
  1203. this.msgTypeRadioBoxNode.addClass("selected");
  1204. this.msgTypeContentNode.removeClass("dn");
  1205. this.urlTypeRadioBoxNode.removeClass("selected");
  1206. this.urlTypeContentNode.addClass("dn");
  1207. this.miniprogramTypeRadioBoxNode.removeClass("selected");
  1208. this.miniprogramTypeContentNode.addClass("dn");
  1209. }
  1210. } else {
  1211. this.msgTypeRadioBoxNode.addClass("selected");
  1212. this.msgTypeContentNode.removeClass("dn");
  1213. this.urlTypeRadioBoxNode.removeClass("selected");
  1214. this.urlTypeContentNode.addClass("dn");
  1215. this.miniprogramTypeRadioBoxNode.removeClass("selected");
  1216. this.miniprogramTypeContentNode.addClass("dn");
  1217. }
  1218. },
  1219. //提交菜单数据
  1220. submitAction: function() {
  1221. var name = this.nameInputNode.get("value");
  1222. if (!name || name === "") {
  1223. this.app.notice(this.lp.mobile_mpweixin_menu_form_name_error_empty, "error", this.menuApp.contentAreaNode);
  1224. return;
  1225. }
  1226. if (this.menu.o2Level && this.menu.o2Level === "1") {
  1227. if (name.length > 4) {
  1228. this.app.notice(this.lp.mobile_mpweixin_menu_form_name_error_max_len_4, "error", this.menuApp.contentAreaNode);
  1229. return;
  1230. }
  1231. } else {
  1232. if (name.length > 6) {
  1233. this.app.notice(this.lp.mobile_mpweixin_menu_form_name_error_max_len_6, "error", this.menuApp.contentAreaNode);
  1234. return;
  1235. }
  1236. }
  1237. var order = this.orderInputNode.get("value");
  1238. if (!order || order === "") {
  1239. this.app.notice(this.lp.mobile_mpweixin_menu_form_order_error_empty, "error", this.menuApp.contentAreaNode);
  1240. return;
  1241. }
  1242. //数字
  1243. var reg = /^[\d]+$/;
  1244. var s = reg.test(order);
  1245. if (s === false) {
  1246. this.app.notice(this.lp.mobile_mpweixin_menu_form_order_error_not_number, "error", this.menuApp.contentAreaNode);
  1247. return;
  1248. }
  1249. if (order.length > 6) {
  1250. this.app.notice(this.lp.mobile_mpweixin_menu_form_order_error_max_len, "error", this.menuApp.contentAreaNode);
  1251. return;
  1252. }
  1253. this.menu.name = name;
  1254. this.menu.order = order;
  1255. //父菜单 只需要name和order
  1256. if (this.haSubMenus && this.haSubMenus === true) {
  1257. console.log("存在子菜单菜单");
  1258. }else {
  1259. var type = this.menu.type;
  1260. if (type === "view") { //网页
  1261. var url = this.urlTypeContentInputNode.get("value");
  1262. if (!url || url === "") {
  1263. this.app.notice(this.lp.mobile_mpweixin_menu_form_type_url_error_empty, "error", this.menuApp.contentAreaNode);
  1264. return;
  1265. }
  1266. this.menu.url = url;
  1267. //新建的菜单删除id
  1268. if (this.menu.id.startsWith('mock_')) {
  1269. delete this.menu.id; //新增要删除id
  1270. }
  1271. } else if (type === "miniprogram") { //小程序
  1272. var appid = this.miniprogramTypeAppIdContentInputNode.get("value");
  1273. if (!appid || appid === "") {
  1274. this.app.notice(this.lp.mobile_mpweixin_menu_form_type_miniprogram_appid_error_empty, "error", this.menuApp.contentAreaNode);
  1275. return;
  1276. }
  1277. var path = this.miniprogramTypePathContentInputNode.get("value");
  1278. if (!path || path === "") {
  1279. this.app.notice(this.lp.mobile_mpweixin_menu_form_type_miniprogram_path_error_empty, "error", this.menuApp.contentAreaNode);
  1280. return;
  1281. }
  1282. var url = this.miniprogramTypeUrlContentInputNode.get("value");
  1283. if (!url || url === "") {
  1284. this.app.notice(this.lp.mobile_mpweixin_menu_form_type_miniprogram_url_error_empty, "error", this.menuApp.contentAreaNode);
  1285. return;
  1286. }
  1287. this.menu.appid = appid;
  1288. this.menu.pagepath = path;
  1289. this.menu.url = url;
  1290. //新建的菜单删除id
  1291. if (this.menu.id.startsWith('mock_')) {
  1292. delete this.menu.id; //新增要删除id
  1293. }
  1294. } else { //消息
  1295. var content = this.msgTypeContentInputNode.get("value");
  1296. if (!content || content === "") {
  1297. this.app.notice(this.lp.mobile_mpweixin_menu_form_type_msg_error_empty, "error", this.menuApp.contentAreaNode);
  1298. return;
  1299. }
  1300. this.menu.content = content;
  1301. //新建的菜单 click类型需要设置key
  1302. if (this.menu.id.startsWith('mock_')) {
  1303. this.menu.key = this.menu.id;
  1304. delete this.menu.id; //新增要删除id
  1305. }
  1306. }
  1307. }
  1308. //写入数据 远程写入 还有 上级数组中
  1309. if (!this.menu.id) { //新增
  1310. o2.Actions.load("x_program_center").MPWeixinAction.menuAdd(this.menu,function (json) {
  1311. this.menu.id = json.data.id;//更新id
  1312. this.menuApp.setMenuData(this.menu);
  1313. this.app.notice(this.lp.mobile_mpweixin_menu_save_success, "success", this.menuApp.contentAreaNode);
  1314. }.bind(this));
  1315. }else { // 更新
  1316. o2.Actions.load("x_program_center").MPWeixinAction.menuUpdate(this.menu.id, this.menu,function (json) {
  1317. this.menuApp.setMenuData(this.menu);
  1318. this.app.notice(this.lp.mobile_mpweixin_menu_save_success, "success", this.menuApp.contentAreaNode);
  1319. }.bind(this));
  1320. }
  1321. },
  1322. });
  1323. MWF.xApplication.Setting.MobileStyleDocument = new Class({
  1324. Extends: MWF.xApplication.Setting.Document,
  1325. load: function () {
  1326. this.node = new Element("div", { "styles": { "overflow": "hidden", "padding-bottom": "80px" } }).inject(this.contentAreaNode);
  1327. this.titleName = new Element("div", { "styles": this.explorer.css.explorerContentTitleNode }).inject(this.node);
  1328. this.titleName.set("text", this.lp.mobile_styleSetting);
  1329. this.explorer.imagesData.images.each(function (img, i) {
  1330. var imgName = this.lp.mobile_style_imgs[img.name];
  1331. var title = this.lp.mobile_style.replace("{name}", imgName);
  1332. var infor = this.lp.mobile_style_infor.replace("{name}", imgName);
  1333. new MWF.xApplication.Setting.Document.Image(this.explorer, this.node, {
  1334. "lp": { "title": title, "infor": "" },
  1335. "data": { "key": "imagesData", "valueKey": "applicationList", "notEmpty": false },
  1336. "value": img,
  1337. "itemTitle": infor,
  1338. "iconData": img.value
  1339. });
  1340. }.bind(this));
  1341. }
  1342. });