equipManage_qxz_manualCtrl.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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 rel="stylesheet" href="../css/reset.css" />
  9. <link href="../css/mui.min.css" rel="stylesheet" />
  10. <link rel="stylesheet" href="../css/iconfont.css" />
  11. <script src="../js/base.js" type="text/javascript" charset="utf-8"></script>
  12. <link href="../css/common.css" rel="stylesheet" />
  13. <style type="text/css">
  14. /*body,.mui-content {
  15. background: #fff;
  16. }*/
  17. .mui-icon-undo {
  18. display: none;
  19. }
  20. .qxMsg {
  21. margin: 10px 20px;
  22. /*background: pink;*/
  23. }
  24. .qxMsg>li {
  25. margin-bottom: .2rem;
  26. }
  27. .qxManualitem {
  28. padding: 6px;
  29. background: #fff;
  30. border-radius: 3px;
  31. /*line-height: 33px;*/
  32. }
  33. .currName {
  34. line-height: 33px;
  35. }
  36. .switchName {
  37. color: green;
  38. display: none;
  39. }
  40. /*switch*/
  41. .switchParent {
  42. float: right;
  43. margin-top: 2px;
  44. right: 3px;
  45. }
  46. .mui-switch.mui-active:before {
  47. content: '开启';
  48. left: 8px;
  49. }
  50. .mui-switch:before {
  51. content: '关闭';
  52. }
  53. .isonlineicon {
  54. display: inline-block;
  55. width: 8px;
  56. height: 8px;
  57. border-radius: 50%;
  58. background: green;
  59. margin-right: 3px;
  60. }
  61. .isonlineicon.active {
  62. background: green;
  63. animation: 1s ease 0s infinite normal none running myfirst01;
  64. }
  65. .isonlineicon {
  66. background: #909090;
  67. animation: 1s ease 0s infinite normal none running myfirst02;
  68. }
  69. @keyframes myfirst01 {
  70. 0% {
  71. -moz-box-shadow: 0px 0px 6px 1px green;
  72. box-shadow: 0px 0px 6px 1px green;
  73. }
  74. 100% {
  75. -moz-box-shadow: 0px 0px 6px 1px green;
  76. box-shadow: 0px 0px 6px 1px green;
  77. }
  78. }
  79. @keyframes myfirst02 {
  80. 0% {
  81. -moz-box-shadow: 0px 0px 6px 1px #909090;
  82. box-shadow: 0px 0px 6px 1px #909090;
  83. }
  84. 100% {
  85. -moz-box-shadow: 0px 0px 6px 1px #909090;
  86. box-shadow: 0px 0px 6px 1px #909090;
  87. }
  88. }
  89. </style>
  90. </head>
  91. <body>
  92. <header class="mui-bar mui-bar-nav">
  93. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  94. <h1 class="mui-title" id="title">手动控制</h1>
  95. <a id="setAstrict" class="mui-icon mui-icon-compose mui-pull-right" onclick="showEdit(this)"></a>
  96. <a id="setAstrict" class="mui-icon mui-icon-undo mui-pull-right" onclick="cantelEdit(this)"></a>
  97. </header>
  98. <div class="mui-content">
  99. <ul class="qxMsg">
  100. <!--<li class="qxitem">
  101. <div class="qxManualitem">
  102. <span class="isonlineicon"></span>
  103. <span class="currName">施肥机</span>
  104. <span class="mui-icon mui-icon-compose switchName" onclick="editName(this)"></span>
  105. <input type="hidden" name="" id="" value="1" />
  106. <div class="switchParent">
  107. <div class="mui-switch mui-switch-blue mui-active">
  108. <div class="mui-switch-handle"></div>
  109. </div>
  110. </div>
  111. </div>
  112. </li>-->
  113. </ul>
  114. </div>
  115. <script src="../js/jquery-2.1.0.js"></script>
  116. <script src="../js/mui.min.js"></script>
  117. <script src="../js/common.js"></script>
  118. <script type="text/javascript">
  119. var equipId;
  120. mui.init();
  121. var qxz_switch = [];
  122. var switch_name = [];
  123. mui.plusReady(function() {
  124. var self = plus.webview.currentWebview();
  125. equipId = self.equipId;
  126. qxz_switch = self.qxz_switch;
  127. switch_name = eval('('+self.switch_name+')');
  128. data = self.data
  129. $('#equipName').html('项目名称:' + qxz_switch);
  130. var html = '';
  131. for(var i = 0; i < qxz_switch.length; i++) {
  132. if(switch_name[i].name) {
  133. var name = switch_name[i].name;
  134. } else {
  135. var name = '开关' + qxz_switch[i].JK;
  136. }
  137. if(qxz_switch[i].status == 1) {
  138. var check = 'mui-active';
  139. } else {
  140. var check = '';
  141. }
  142. html += '<li class="qxitem"><div class="qxManualitem">' +
  143. '<span class="isonlineicon"></span><span class="currName">' + name + '</span>' +
  144. '<span class="mui-icon mui-icon-compose switchName" onclick="editName(this)"></span>' +
  145. '<input type="hidden" name="" id="" value="' + qxz_switch[i].JK + '" /><div class="switchParent">' +
  146. '<div class="mui-switch mui-switch-blue ' + check + '">' +
  147. '<div class="mui-switch-handle"></div></div></div></div></li>';
  148. if(i == qxz_switch.length - 1) {
  149. $('.qxMsg').html(html);
  150. mui('.mui-switch')['switch']();
  151. mui('.qxMsg').on('toggle', '.mui-switch', function(event) {
  152. if(event.detail.isActive) {
  153. console.log("你启动了开关");
  154. var currStutas = 1;
  155. } else {
  156. console.log("你关闭了开关");
  157. var currStutas = 0;
  158. }
  159. var currWay = $(this).parent().prev().val();
  160. var _this = this;
  161. $.ajax({
  162. url: 'http://120.27.222.26/qxz_switch',
  163. type: 'post',
  164. data: {
  165. 'req': 'set',
  166. 'imei': equipId,
  167. 'way': currWay,
  168. 'switch': currStutas
  169. },
  170. success: function(data) {
  171. if(currStutas == 1) {
  172. $(_this).parents('.qxManualitem').find('.isonlineicon').addClass('active');
  173. } else {
  174. $(_this).parents('.qxManualitem').find('.isonlineicon').removeClass('active');
  175. }
  176. mui.toast('设置成功');
  177. },
  178. error: function(type) {
  179. mui.toast('设置失败')
  180. }
  181. })
  182. })
  183. }
  184. }
  185. })
  186. $('body').on('tap', '.aisleName', function() {
  187. var _this = this;
  188. $(_this).next().slideToggle(function() {
  189. if($(this).is(":visible")) {
  190. $(_this).children().addClass('mui-navigate-top')
  191. } else {
  192. $(_this).children().removeClass('mui-navigate-top')
  193. }
  194. });
  195. })
  196. function showEdit(obj) {
  197. $(obj).hide();
  198. $(obj).next().show();
  199. $('.switchName').show();
  200. }
  201. function cantelEdit(obj) {
  202. $(obj).hide();
  203. $(obj).prev().show();
  204. $('.switchName').hide();
  205. }
  206. function editName(obj) {
  207. var title = $(obj).prev().html();
  208. var currWay = $(obj).next().val();
  209. mui.prompt('修改开关名称', '输入开关名称', title, ['取消', '确定'], function(e) {
  210. if(e.index == 1) {
  211. var text = e.value
  212. if(text) {
  213. $.ajax({
  214. url: 'http://120.27.222.26/qxz_switch_name',
  215. type: 'post',
  216. data: {
  217. 'imei': equipId,
  218. 'way': currWay,
  219. 'sw_name': text
  220. },
  221. success: function(data) {
  222. console.log(111111)
  223. if(data == 0) {
  224. $(obj).prev().html(text)
  225. }
  226. },
  227. error: function(type) {
  228. }
  229. })
  230. }else{
  231. return false;
  232. }
  233. }
  234. }, 'div')
  235. }
  236. </script>
  237. </body>
  238. </html>