Няма описание

updateinfo-res01.js 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. mui.ready(function() {
  2. mui.plusReady(function() {
  3. var userid = plus.storage.getItem('userid');
  4. var ws = plus.webview.currentWebview();
  5. console.log(ws.reFlag)
  6. var oDt = document.getElementsByClassName("frmtype");
  7. var service = document.getElementsByClassName("textareabox");
  8. function personalMessage() {
  9. mui.ajax(baseUrl + "/ajax/resource/" + ws.rsId, {
  10. dataType: 'json', //数据格式类型
  11. type: 'GET', //http请求类型
  12. timeout: 10000, //超时设置
  13. success: function(data) {
  14. plus.nativeUI.closeWaiting();
  15. ws.show("slide-in-right", 150);
  16. var $data = data.data;
  17. //资源基本信息
  18. oDt[0].value = $data.resourceName;
  19. service[0].innerText = $data.supportedServices
  20. },
  21. error: function() {
  22. plus.nativeUI.toast("服务器链接超时", toastStyle);
  23. return;
  24. }
  25. });
  26. }
  27. function trim(str) { //删除左右两端的空格   
  28. return str.replace(/(^\s*)|(\s*$)/g, "");  
  29. }
  30. oDt[0].addEventListener("blur", function() {
  31. var length = trim(oDt[0].value);
  32. if(!length)
  33. plus.nativeUI.toast("资源名称不能为空");
  34. });
  35. service[0].addEventListener("blur", function() {
  36. var length = trim(service[0].value);
  37. if(!length)
  38. plus.nativeUI.toast("应用用途不能为空");
  39. });
  40. function savePro() {
  41. var $data = {};
  42. $data.resourceName = oDt[0].value;
  43. $data.supportedServices = service[0].value;
  44. if(ws.rsId) {
  45. $data.resourceId = ws.rsId;
  46. mui.ajax(baseUrl + "/ajax/resource/nameAndSupport", {
  47. "type": "post",
  48. "async": true,
  49. "data": $data,
  50. "error": function(type, xhr, errorThrown) {
  51. console.log(JSON.stringify(type));
  52. console.log(JSON.stringify(xhr));
  53. console.log(JSON.stringify(errorThrown));
  54. },
  55. "success": function(data) {
  56. var y = JSON.stringify(data)
  57. if(data.success) {
  58. plus.nativeUI.showWaiting();
  59. var web = plus.webview.getWebviewById("resinforupdate.html");
  60. mui.fire(web, "resourceMess");
  61. mui.back();
  62. if(ws.reFlag == 0) {
  63. var web1 = plus.webview.getWebviewById("html/proinforupdate.html");
  64. mui.fire(web1, "newId", {
  65. rd: 1
  66. });
  67. } else if(ws.reFlag == 1) {
  68. var web2 = plus.webview.getWebviewById("html/companyUpdata.html");
  69. mui.fire(web2, "newId", {
  70. rd: 1
  71. });
  72. } else if(ws.reFlag == 2) {
  73. var web2 = plus.webview.getWebviewById("html/studentUpdata.html");
  74. mui.fire(web2, "newId", {
  75. rd: 1
  76. });
  77. }
  78. } else {
  79. plus.nativeUI.toast("服务器链接超时", toastStyle);
  80. return;
  81. }
  82. }
  83. });
  84. } else {
  85. $data.professorId = userid;
  86. mui.ajax(baseUrl + "/ajax/resource", {
  87. "type": "post",
  88. "async": true,
  89. "data": $data,
  90. "success": function(data) {
  91. var y = JSON.stringify(data)
  92. if(data.success) {
  93. var id = data.data;
  94. plus.nativeUI.showWaiting();
  95. if(ws.reFlag == 0) {
  96. var web2 = plus.webview.getWebviewById("html/proinforupdate.html");
  97. mui.fire(web2, "newId", {
  98. rd: 1
  99. });
  100. } else if(ws.reFlag == 1) {
  101. var web2 = plus.webview.getWebviewById("html/companyUpdata.html");
  102. mui.fire(web2, "newId", {
  103. rd: 1
  104. });
  105. } else if(ws.reFlag == 2) {
  106. var web2 = plus.webview.getWebviewById("html/studentUpdata.html");
  107. mui.fire(web2, "newId", {
  108. rd: 1
  109. });
  110. }
  111. var web = plus.webview.create("../html/resinforupdate.html", "resinforupdate.html", {}, {
  112. resourceId: id,
  113. reFlag: ws.reFlag
  114. }); //后台创建webview并打开show.html
  115. web.addEventListener("loaded", function() {}, false);
  116. } else {
  117. plus.nativeUI.toast("服务器链接超时", toastStyle);
  118. return;
  119. }
  120. }
  121. });
  122. }
  123. }
  124. if(ws.rsId) {
  125. personalMessage()
  126. }
  127. document.getElementsByClassName("topsave")[0].addEventListener("click", function() {
  128. var length1 = trim(oDt[0].value);
  129. var length2 = trim(service[0].value);
  130. if(length1 && length2) {
  131. savePro();
  132. } else if(!length1 && length2) {
  133. plus.nativeUI.toast("资源名称不能为空");
  134. } else if(length1 && !length2) {
  135. plus.nativeUI.toast("应用用途不能为空");
  136. } else if(!length1 && !length2) {
  137. plus.nativeUI.toast("资源名称不能为空&&应用用途不能为空");
  138. }
  139. });
  140. });
  141. })