wormDescribe.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <!--<link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">-->
  8. <link href="../css/mui.min.css" rel="stylesheet" />
  9. <link rel="stylesheet" type="text/css" href="../css/iconfont.css" />
  10. <link href="../css/common.css" rel="stylesheet" />
  11. <style type="text/css">
  12. .headRightIcon:before {
  13. margin: 3px 0 -3px 0;
  14. }
  15. /*input*/
  16. .mui-table-view-cell input {
  17. line-height: 30px;
  18. width: 100%;
  19. height: inherit;
  20. margin-bottom: 0;
  21. padding: 0;
  22. -webkit-user-select: text;
  23. border: none;
  24. border-radius: none;
  25. outline: 0;
  26. background-color: #fff;
  27. -webkit-appearance: none;
  28. }
  29. input::-webkit-input-placeholder {
  30. color: #BEBEBE;
  31. }
  32. input::-moz-placeholder {
  33. /* Mozilla Firefox 19+ */
  34. color: #BEBEBE;
  35. }
  36. input:-moz-placeholder {
  37. /* Mozilla Firefox 4 to 18 */
  38. color: #BEBEBE;
  39. }
  40. input:-ms-input-placeholder {
  41. /* Internet Explorer 10-11 */
  42. color: #BEBEBE;
  43. }
  44. /*select*/
  45. .mui-input-row select {
  46. padding: 0;
  47. margin: 0;
  48. height: 30px;
  49. font-size: 17px;
  50. }
  51. /*btn*/
  52. .btnBox {
  53. margin: 15px;
  54. text-align: center;
  55. }
  56. .btnBox button {
  57. width: 60%;
  58. border-radius: 10px;
  59. line-height: 26px;
  60. font-size: 18px;
  61. letter-spacing: 5px;
  62. background: #21b2e7;
  63. color: #fff;
  64. }
  65. .nullData {
  66. top: 45px;
  67. }
  68. </style>
  69. </head>
  70. <body>
  71. <header class="mui-bar mui-bar-nav">
  72. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  73. <h1 class="mui-title">添加描述</h1>
  74. <a class="headRightIcon iconfont icon-worm mui-pull-right" id="categoryBtn">种类</a>
  75. </header>
  76. <div class="mui-content">
  77. <ul class="mui-table-view" id="user">
  78. <li class="mui-table-view-cell">
  79. <span class="equipTitle">害虫名称</span>
  80. <div class="mui-input-row mui-select">
  81. <select name="wormName" id="wormName">
  82. </select>
  83. </div>
  84. </li>
  85. <li class="mui-table-view-cell">
  86. <span class="equipTitle">数量</span>
  87. <p><input type="number" name="" placeholder="请输入数量" id="wormnum" value="" /></p>
  88. </li>
  89. <li class="mui-table-view-cell">
  90. <span class="equipTitle">作物种类</span>
  91. <p><input type="text" name="" placeholder="选填项" id="cropArea" value="" /></p>
  92. </li>
  93. <li class="mui-table-view-cell">
  94. <span class="equipTitle">虫害阶段</span>
  95. <p><input type="text" name="" placeholder="选填项" id="worstage" value="" /></p>
  96. </li>
  97. </ul>
  98. <div class="btnBox">
  99. <button class="" id="sendBtn">确定</button>
  100. </div>
  101. </div>
  102. <script src="../js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
  103. <script src="../js/mui.min.js"></script>
  104. <script src="../js/common.js"></script>
  105. <script type="text/javascript">
  106. var equipId;
  107. var addr;
  108. mui.init();
  109. window.addEventListener('refresh', function(e) { //执行刷新
  110. location.reload();
  111. });
  112. mui.plusReady(function() {
  113. var self = plus.webview.currentWebview();
  114. equipId = self.equipId;
  115. addr = self.addr;
  116. console.log(equipId);
  117. console.log(addr);
  118. mui.ajax('http://120.27.222.26/cbd_describe_img', {
  119. data: {
  120. req: 'pest_kind',
  121. addr: addr
  122. },
  123. dataType: 'json', //服务器返回json格式数据
  124. type: 'get', //HTTP请求类型
  125. timeout: 10000, //超时时间设置为10秒;
  126. success: function(data) {
  127. var html = '';
  128. if(data.length) {
  129. for(var i = 0; i < data.length; i++) {
  130. html += '<option value="' + data[i].pest_name + '">' + data[i].pest_name + '</option>'
  131. }
  132. $('#wormName').html(html);
  133. } else {
  134. html = '<option value="0">请添加种类</option>'
  135. $('#wormName').html(html);
  136. }
  137. },
  138. error: function(xhr, type, errorThrown) {
  139. console.log(type)
  140. mui('.mui-content')[0].appendChild(netStyle('../images/netBlocked.png'));
  141. }
  142. });
  143. //保存害虫详情
  144. document.getElementById('sendBtn').addEventListener('tap', function() {
  145. var describe = {
  146. "pest_name":document.getElementById('wormName').value,
  147. "crop_name":document.getElementById('cropArea').value,
  148. "pest_num":document.getElementById('wormnum').value,
  149. "pest_case":document.getElementById('worstage').value
  150. }
  151. mui.ajax('http://120.27.222.26/cbd_describe_img', {
  152. data: {
  153. req: 'add_save',
  154. addr: addr,
  155. describe: JSON.stringify(describe)
  156. },
  157. dataType: 'json', //服务器返回json格式数据
  158. type: 'post', //HTTP请求类型
  159. timeout: 10000, //超时时间设置为10秒;
  160. success: function(data) {
  161. console.log(data)
  162. if(data == 0){
  163. mui.alert("数据保存成功","添加描述","确定",function () {
  164. mui.back();
  165. });
  166. }else if(data == 1){
  167. mui.alert("添加描述失败!","提示");
  168. }else if(data == 2){
  169. mui.alert("该害虫描述已存在!","提示");
  170. }
  171. },
  172. error: function(xhr, type, errorThrown) {
  173. console.log(type)
  174. }
  175. });
  176. })
  177. //添加害虫种类
  178. document.getElementById('categoryBtn').addEventListener('tap', function() {
  179. mui.openWindow({
  180. url: 'addwormCategory.html',
  181. id: 'addwormCategory',
  182. extras: {
  183. equipId: equipId,
  184. addr: addr
  185. }
  186. })
  187. })
  188. })
  189. </script>
  190. </body>
  191. </html>