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

updateinfo9.js 3.2KB

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