No Description

updateinfo9.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. mui.ready(function() {
  2. mui.plusReady(function() {
  3. var userid = plus.storage.getItem('userid');
  4. var ws = plus.webview.currentWebview();
  5. var str = JSON.stringify(ws);
  6. var oDt = document.getElementsByClassName("frmtype");
  7. var oDegree;
  8. if(ws.edu) {
  9. $.ajax({
  10. "url": baseUrl + "/ajax/paper/" + ws.edu,
  11. "type": "get",
  12. "async": true,
  13. "success": function($data) {
  14. if($data.success) {
  15. plus.nativeUI.closeWaiting();; //新webview的载入完毕后关闭等待框
  16. ws.show("slide-in-right", 150); //把新webview窗体显示出来,显示动画效果为速度150毫秒的右侧移入动画
  17. $info = $data.data;
  18. oDt[0].value = $info.name;
  19. oDt[1].innerText = $info.year;
  20. oDt[2].value = $info.url;
  21. if(!$info.descp)
  22. $info.descp = "";
  23. document.getElementsByClassName("textareabox")[0].innerText = $info.descp;
  24. } else {
  25. plus.nativeUI.toast("服务器链接超时", toastStyle);
  26. return;
  27. }
  28. }
  29. });
  30. }
  31. function trim(str) { //删除左右两端的空格
  32.   
  33. return str.replace(/(^\s*)|(\s*$)/g, "");  
  34. }
  35. oDt[0].addEventListener("blur", function() {
  36. var length = trim(oDt[0].value);
  37. if(!length)
  38. plus.nativeUI.toast("标题名称不能为空");
  39. });
  40. var oEduYear = document.getElementById("eduYear");
  41. var oBtn = document.getElementsByClassName("btn")[0];
  42. oBtn.addEventListener("click", function() {
  43. var optionsJson = this.getAttribute('data-options') || '{}';
  44. var options = JSON.parse(optionsJson);
  45. var picker = new mui.DtPicker(options);
  46. picker.show(function(rs) {
  47. oEduYear.innerText = rs.text.substr(0, 4);
  48. });
  49. })
  50. function savePro() {
  51. var $data = {};
  52. $data.professorId = userid;
  53. $data.name = oDt[0].value;
  54. $data.year = oDt[1].innerText;
  55. $data.url = oDt[2].value;
  56. $data.descp = document.getElementsByClassName("textareabox")[0].innerText;
  57. if(ws.edu) {
  58. $data.id=ws.edu;
  59. }
  60. $.ajax({
  61. "url" :baseUrl+"/ajax/paper",
  62. "type" : ws.edu?"put" :"post",
  63. "async":true,
  64. "data" :ws.edu?JSON.stringify($data):$data,
  65. "contentType" : ws.edu ? "application/json"
  66. : "application/x-www-form-urlencoded",
  67. "success" : function(data) {
  68. var y=JSON.stringify(data)
  69. console.log(y)
  70. console.log(data);
  71. if (data.success)
  72. {
  73. var web=plus.webview.getWebviewById("proinforupdate-more.html");
  74. mui.fire(web,"newId");
  75. mui.back();
  76. }
  77. else
  78. {
  79. plus.nativeUI.toast("服务器链接超时", toastStyle);
  80. return;
  81. }
  82. }
  83. });
  84. }
  85. document.getElementsByClassName("topsave")[0].addEventListener("click",function(){
  86. var length1=trim(oDt[0].value);
  87. if(length1) {
  88. savePro();
  89. }else {
  90. plus.nativeUI.toast("标题名称不能为空");
  91. }
  92. });
  93. if(ws.edu)
  94. document.getElementsByClassName("exitbtn")[0].addEventListener("click",function(){
  95. $.ajax({
  96. "url" : baseUrl+"/ajax/paper/" + ws.edu,
  97. "type" : "DELETE",
  98. "success" : function($data) {
  99. if ($data.success) {
  100. var web=plus.webview.getWebviewById("proinforupdate-more.html");
  101. mui.fire(web,"newId");
  102. mui.back();
  103. }
  104. else {
  105. plus.nativeUI.toast("服务器链接超时", toastStyle);
  106. }
  107. }
  108. });
  109. });
  110. });
  111. })