Nenhuma Descrição

updateinfo11.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. if(ws.edu) {
  8. $.ajax({
  9. "url" :baseUrl+"/ajax/honor/"+ws.edu,
  10. "type" : "get" ,
  11. "async":true,
  12. "success" : function($data) {
  13. if ($data.success)
  14. {
  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].value=$info.year;
  20. if(!$info.descp)
  21. $info.descp="";
  22. document.getElementsByClassName("textareabox")[0].innerText=$info.descp;
  23. }
  24. else
  25. {
  26. plus.nativeUI.toast("服务器链接超时", toastStyle);
  27. return;
  28. }
  29. }
  30. });
  31. }
  32. function trim(str) { //删除左右两端的空格
  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. function savePro() {
  41. var $data = {};
  42. $data.professorId = userid;
  43. $data.name =oDt[0].value;
  44. $data.year = oDt[1].value;
  45. $data.descp = document.getElementsByClassName("textareabox")[0].innerText;
  46. if(ws.edu) {
  47. $data.id=ws.edu;
  48. }
  49. $.ajax({
  50. "url" :baseUrl+"/ajax/honor",
  51. "type" : ws.edu?"put" :"post",
  52. "async":true,
  53. "data" :ws.edu?JSON.stringify($data):$data,
  54. "contentType" : ws.edu ? "application/json"
  55. : "application/x-www-form-urlencoded",
  56. "success" : function(data) {
  57. var y=JSON.stringify(data)
  58. if (data.success)
  59. {
  60. var web=plus.webview.getWebviewById("proinforupdate-more.html");
  61. mui.fire(web,"newId");
  62. mui.back();
  63. }
  64. else
  65. {
  66. plus.nativeUI.toast("服务器链接超时", toastStyle);
  67. return;
  68. }
  69. }
  70. });
  71. }
  72. document.getElementsByClassName("topsave")[0].addEventListener("click",function(){
  73. var length1=trim(oDt[0].value);
  74. if(length1) {
  75. savePro();
  76. }else {
  77. plus.nativeUI.toast("获奖名称不能为空");
  78. }
  79. });
  80. if(ws.edu)
  81. document.getElementsByClassName("exitbtn")[0].addEventListener("click",function(){
  82. $.ajax({
  83. "url" : baseUrl+"/ajax/honor/" + ws.edu,
  84. "type" : "DELETE",
  85. "success" : function($data) {
  86. if ($data.success) {
  87. var web=plus.webview.getWebviewById("proinforupdate-more.html");
  88. mui.fire(web,"newId");
  89. mui.back();
  90. }
  91. else {
  92. plus.nativeUI.toast("服务器链接超时", toastStyle);
  93. }
  94. }
  95. });
  96. });
  97. });
  98. })