Geen omschrijving

updateinfo11.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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].innerText=$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. 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.descp = document.getElementsByClassName("textareabox")[0].innerText;
  56. if(ws.edu) {
  57. $data.id=ws.edu;
  58. }
  59. $.ajax({
  60. "url" :baseUrl+"/ajax/honor",
  61. "type" : ws.edu?"put" :"post",
  62. "async":true,
  63. "data" :ws.edu?JSON.stringify($data):$data,
  64. "contentType" : ws.edu ? "application/json"
  65. : "application/x-www-form-urlencoded",
  66. "success" : function(data) {
  67. var y=JSON.stringify(data)
  68. if (data.success)
  69. {
  70. var web=plus.webview.getWebviewById("proinforupdate-more.html");
  71. mui.fire(web,"newId");
  72. mui.back();
  73. }
  74. else
  75. {
  76. plus.nativeUI.toast("服务器链接超时", toastStyle);
  77. return;
  78. }
  79. }
  80. });
  81. }
  82. document.getElementsByClassName("topsave")[0].addEventListener("click",function(){
  83. var length1=trim(oDt[0].value);
  84. if(length1) {
  85. savePro();
  86. }else {
  87. plus.nativeUI.toast("获奖名称不能为空");
  88. }
  89. });
  90. if(ws.edu)
  91. document.getElementsByClassName("exitbtn")[0].addEventListener("click",function(){
  92. $.ajax({
  93. "url" : baseUrl+"/ajax/honor/" + ws.edu,
  94. "type" : "DELETE",
  95. "success" : function($data) {
  96. if ($data.success) {
  97. var web=plus.webview.getWebviewById("proinforupdate-more.html");
  98. mui.fire(web,"newId");
  99. mui.back();
  100. }
  101. else {
  102. plus.nativeUI.toast("服务器链接超时", toastStyle);
  103. }
  104. }
  105. });
  106. });
  107. });
  108. })