Нет описания

resinforupdate.js 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. mui.ready(function() {
  2. mui.plusReady(function() {
  3. var userid = plus.storage.getItem('userid');
  4. var self = plus.webview.currentWebview();
  5. document.getElementById("userimg").setAttribute("resouFlag", self.reFlag);
  6. console.log(document.getElementById("userimg").getAttribute("resouFlag"))
  7. var resourceId = self.resourceId;
  8. window.addEventListener("resourceMess", function(event) {
  9. resourceMess();
  10. })
  11. //查询学术领域
  12. var subjectShow = function(data) {
  13. if(data != undefined && data.length != 0) {
  14. var subs = new Array();
  15. if(data.indexOf(',')) {
  16. subs = data.split(',');
  17. } else {
  18. subs[0] = data;
  19. }
  20. if(subs.length > 0) {
  21. var html = [];
  22. for(var i = 0; i < subs.length; i++) {
  23. html.push("<li>" + subs[i] + "</li>");
  24. };
  25. document.getElementsByClassName("infosubject")[0].innerHTML = html.join('');
  26. }
  27. }
  28. }
  29. //查询应用行业
  30. var industryShow = function(data) {
  31. if(data != undefined && data.length != 0) {
  32. var subs = new Array();
  33. if(data.indexOf(',')) {
  34. subs = data.split(',');
  35. } else {
  36. subs[0] = data;
  37. }
  38. if(subs.length > 0) {
  39. var html = [];
  40. for(var i = 0; i < subs.length; i++) {
  41. html.push("<li>" + subs[i] + "</li>");
  42. };
  43. document.getElementsByClassName("infoapply")[0].innerHTML = html.join('');
  44. }
  45. }
  46. }
  47. var resourceMess = function() {
  48. mui.ajax(baseUrl + "/ajax/resource/" + resourceId, {
  49. "type": "get",
  50. "async": true,
  51. "success": function(data) {
  52. var y = JSON.stringify(data);
  53. console.log(y);
  54. if(data.success) {
  55. var $data = data.data;
  56. plus.nativeUI.closeWaiting();
  57. self.show("slide-in-right", 150);
  58. //资源基本信息
  59. if($data.images.length) {
  60. document.getElementById("userimg").src = baseUrl + '/images/resource/' + $data.resourceId + '.jpg';
  61. }
  62. var oRes = document.getElementsByClassName("listtit2");
  63. oRes[0].innerText = $data.resourceName;
  64. oRes[1].innerText = $data.supportedServices;
  65. if($data.subject) {
  66. subjectShow($data.subject);
  67. } else {
  68. document.getElementById("subModify").innerText = "点击添加"
  69. }
  70. //应用行业
  71. if($data.industry) {
  72. industryShow($data.industry);
  73. } else {
  74. document.getElementById("indModify").innerText = "点击添加"
  75. }
  76. //详细介绍
  77. if($data.descp) {
  78. document.getElementById("descp1").innerText = $data.descp;
  79. } else {
  80. document.getElementById("desModify").innerText = "点击添加"
  81. }
  82. //合作备注
  83. if($data.cooperationNotes) {
  84. document.getElementById("cooperationNotes").innerText = $data.cooperationNotes;
  85. }
  86. } else {
  87. plus.nativeUI.toast("服务器链接超时", toastStyle);
  88. return;
  89. }
  90. }
  91. });
  92. }
  93. if(resourceId) {
  94. resourceMess();
  95. }
  96. document.getElementById("mess").addEventListener("click", function() {
  97. plus.nativeUI.showWaiting();
  98. var web = plus.webview.create("../html/updateinfo-res01.html", "updateinfo-res01.html", {}, {
  99. rsId: resourceId,
  100. reFlag: self.reFlag
  101. }); //后台创建webview并打开show.html
  102. web.addEventListener("loaded", function() {}, false);
  103. });
  104. document.getElementById("subject").addEventListener("click", function() {
  105. var nwaiting = plus.nativeUI.showWaiting();
  106. var web = plus.webview.create("../html/updateinfo-res02.html", "updateinfo-res02.html", {}, {
  107. rsId: resourceId
  108. }); //后台创建webview并打开show.html
  109. web.addEventListener("loaded", function() {}, false);
  110. });
  111. document.getElementById("industry").addEventListener("click", function() {
  112. var nwaiting = plus.nativeUI.showWaiting();
  113. var web = plus.webview.create("../html/updateinfo-res03.html", "updateinfo-res03.html", {}, {
  114. rsId: resourceId
  115. }); //后台创建webview并打开show.html
  116. web.addEventListener("loaded", function() {}, false);
  117. });
  118. document.getElementById("descp").addEventListener("click", function() {
  119. var nwaiting = plus.nativeUI.showWaiting();
  120. var web = plus.webview.create("../html/updateinfo-res04.html", "updateinfo-res04.html", {}, {
  121. rsId: resourceId,
  122. reFlag: self.reFlag
  123. }); //后台创建webview并打开show.html
  124. web.addEventListener("loaded", function() {}, false);
  125. });
  126. document.getElementById("cooperation").addEventListener("click", function() {
  127. var nwaiting = plus.nativeUI.showWaiting();
  128. var web = plus.webview.create("../html/updateinfo-res05.html", "updateinfo-res05.html", {}, {
  129. rsId: resourceId
  130. }); //后台创建webview并打开show.html
  131. web.addEventListener("loaded", function() {}, false);
  132. });
  133. //删除资源
  134. document.getElementsByClassName("exitbtn")[0].addEventListener("click", function() {
  135. $.ajax({
  136. "url": baseUrl + "/ajax/resource/" + resourceId,
  137. "type": "DELETE",
  138. "success": function($data) {
  139. if($data.success) {
  140. if(self.reFlag == 0) {
  141. var web = plus.webview.getWebviewById("html/proinforupdate.html");
  142. mui.fire(web, "newId");
  143. mui.back();
  144. } else if(self.reFlag == 1) {
  145. var web = plus.webview.getWebviewById("html/companyUpdata.html");
  146. mui.fire(web, "newId");
  147. mui.back();
  148. } else if(self.reFlag == 2) {
  149. var web = plus.webview.getWebviewById("html/studentUpdata.html");
  150. mui.fire(web, "newId");
  151. mui.back();
  152. }
  153. } else {
  154. plus.nativeUI.toast("服务器链接超时", toastStyle);
  155. }
  156. }
  157. });
  158. });
  159. });
  160. });