main.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
  6. <meta name="apple-mobile-web-app-capable" content="yes">
  7. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  8. <title></title>
  9. <link href="css/mui.min.css" rel="stylesheet" />
  10. <link href="css/main.css" rel="stylesheet" />
  11. <link href="css/index.css" rel="stylesheet" />
  12. <link href="css/reset-mobile.css" rel="stylesheet" />
  13. <style>
  14. html,
  15. body {
  16. background-color: #efeff4;
  17. }
  18. p {
  19. text-indent: 22px;
  20. }
  21. span.mui-icon {
  22. font-size: 14px;
  23. color: #007aff;
  24. margin-left: -15px;
  25. padding-right: 10px;
  26. }
  27. .mui-off-canvas-left {
  28. color: #fff;
  29. }
  30. .title {
  31. margin: 35px 15px 10px;
  32. }
  33. .title+.content {
  34. margin: 10px 15px 35px;
  35. color: #bbb;
  36. text-indent: 1em;
  37. font-size: 14px;
  38. line-height: 24px;
  39. }
  40. input {
  41. color: #000;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. <div id="offCanvasWrapper" class="mui-off-canvas-wrap mui-draggable">
  47. <div class="mui-inner-wrap">
  48. <header class="mui-bar mui-bar-nav">
  49. <a id="code" href="javascript:;" class="mui-icon mui-icon-camera mui-pull-left"></a>
  50. <a id="info" class="ico-msg has-msgs"></a>
  51. <h1 class="mui-title">新农宝盒V2</h1>
  52. </header>
  53. <div id="offCanvasContentScroll" class="mui-content mui-scroll-wrapper">
  54. <div class="mui-content" id="content">
  55. </div>
  56. </div>
  57. <!-- off-canvas backdrop -->
  58. <div class="mui-off-canvas-backdrop"></div>
  59. </div>
  60. </div>
  61. <script src="js/mui.min.js"></script>
  62. <script src="js/main.js"></script>
  63. <script type="text/javascript" charset="utf-8">
  64. function scaned( t, r, f ) {
  65. //alert(t)
  66. //alert(r)
  67. //alert(f)
  68. mui.ajax(r);
  69. alert('绑定成功!');
  70. location.reload();
  71. }
  72. (function($, self) {
  73. /*
  74. $.init
  75. ({
  76. beforeback: function(){
  77. //获得登录界面的webview
  78. var login = plus.webview.getWebviewById('login');
  79. //触发登录界面的自定义事件(refresh),从而进行数据刷新
  80. mui.fire(login,'refresh');
  81. //返回true,继续页面关闭逻辑
  82. return true;
  83. }
  84. });
  85. */
  86. $.plusReady(function() {
  87. //localStorage.setItem('$state', false);
  88. var stateText = localStorage.getItem('$statev5');
  89. var state = JSON.parse(stateText);
  90. if(!state || stateText == '{}')
  91. {
  92. var page = 'login';
  93. $.openWindow({
  94. id: page,
  95. url: page + '.html'
  96. });
  97. return;
  98. }
  99. //获取页面
  100. $.ajax('http://v2.xinnongbaohe.com/web/application/front/?home?&header=false', {
  101. dataType: 'text', //服务器返回json格式数据
  102. timeout: 10000, //超时时间设置为10秒;
  103. type: 'get', //HTTP请求类型
  104. success: function(r) {
  105. //var t = JSON.parse(r);
  106. var html = r;
  107. document.getElementById("content").innerHTML = html;
  108. mui('.product').each(function() {
  109. document.getElementById(this.id).addEventListener('tap', function(e) {
  110. var vid = this.getAttribute('vid');
  111. var name = this.getAttribute('name');
  112. var live_url = this.getAttribute('live_url');
  113. var page = 'product';
  114. //打开详情页面
  115. $.openWindow({
  116. id: page,
  117. url: page + '.html',
  118. extras: {
  119. vid: vid,
  120. name: name,
  121. live_url:live_url
  122. }
  123. });
  124. });
  125. document.getElementById(this.id+'_a').addEventListener('tap', function(e) {
  126. var id = this.getAttribute('vid');
  127. var name = this.getAttribute('name');
  128. var live_url = this.getAttribute('live_url');
  129. var page = 'product';
  130. //打开详情页面
  131. $.openWindow({
  132. id: page,
  133. url: page + '.html',
  134. extras: {
  135. vid: id,
  136. name: name,
  137. live_url:live_url
  138. }
  139. });
  140. });
  141. });
  142. document.getElementById('setting').addEventListener('tap', function(e) {
  143. var page = 'set';
  144. //打开详情页面
  145. $.openWindow({
  146. id: page,
  147. url: page + '.html'
  148. });
  149. });
  150. document.getElementById('setting_a').addEventListener('tap', function(e) {
  151. var page = 'set';
  152. //打开详情页面
  153. $.openWindow({
  154. id: page,
  155. url: page + '.html'
  156. });
  157. });
  158. document.getElementById('info').addEventListener('tap', function(e) {
  159. var page = 'message';
  160. //打开详情页面
  161. $.openWindow({
  162. id: page,
  163. url: page + '.html'
  164. });
  165. });
  166. document.getElementById('code').addEventListener('tap', function(e) {
  167. var page = 'scan';
  168. //打开详情页面
  169. $.openWindow({
  170. id: page,
  171. url: page + '.html'
  172. });
  173. });
  174. document.getElementById('quit').addEventListener('tap', function(e) {
  175. var page = 'login';
  176. localStorage.setItem('$statev5', '{}');
  177. $.ajax('http://v2.xinnongbaohe.com/web/application/passport/?login.quit');
  178. //打开详情页面
  179. $.openWindow({
  180. id: page,
  181. url: page + '.html'
  182. });
  183. });
  184. }
  185. });
  186. var func = function()
  187. {
  188. $.ajax('http://v2.xinnongbaohe.com/web/application/service/?user.msgnum?json=1', {
  189. dataType: 'text', //服务器返回json格式数据
  190. timeout: 10000, //超时时间设置为10秒;
  191. type: 'get', //HTTP请求类型
  192. success: function(r) {
  193. var t = JSON.parse(r);
  194. if(t.status == 1)
  195. {
  196. document.getElementById('info').setAttribute('class', 'ico-msg has-msg');
  197. }
  198. else
  199. {
  200. document.getElementById('info').setAttribute('class', 'ico-msg');
  201. }
  202. }
  203. });
  204. };
  205. setInterval(func, 1000);
  206. /*
  207. function getDevice() {
  208. // 获取设备
  209. $.ajax('http://company.xinnongbaohe.com/info.park?json=1', {
  210. dataType: 'text', //服务器返回json格式数据
  211. timeout: 10000, //超时时间设置为10秒;
  212. type: 'get', //HTTP请求类型
  213. success: function(r) {
  214. //alert(t);
  215. var t = JSON.parse(r);
  216. //console.info(t);
  217. //var html = '<div class="item"><div class="device-list"><a href="#/tab/news" class="device-item index-news">消息通知</a><a href="#/tab/question" class="device-item index-questions">常见问题</a></div></div>';
  218. var html = '';
  219. html += '<div class="device-list">';
  220. var data = [];
  221. //t.reverse();
  222. for (var a in t) {
  223. //alert(t[a].name);
  224. if (t[a].type == 4) {
  225. data.push('<a page="business" name="' + t[a].name + '" tid="' + t[a].id + '" fid="' + t[a].farm_id + '" id="page_' + t[a].id + '" class="device-item index-two">' + t[a].name + '</a>');
  226. } else if (t[a].type == 3) {
  227. data.push('<a page="greenhouse" name="' + t[a].name + '" tid="' + t[a].id + '" fid="' + t[a].farm_id + '" id="page_' + t[a].id + '" class="device-item index-three">' + t[a].name + '</a>');
  228. }
  229. }
  230. //alert(data);
  231. //data.reverse();
  232. for (var a in data) {
  233. html += data[a];
  234. }
  235. html += '</div>';
  236. //window.localStorage['device'] = html;
  237. //alert(html);
  238. document.getElementById("device").innerHTML = html;
  239. var detailPage = null;
  240. mui('.device-item').each(function() {
  241. document.getElementById(this.id).addEventListener('tap', function(e) {
  242. var tid = this.getAttribute('tid');
  243. var fid = this.getAttribute('fid');
  244. var name = this.getAttribute('name');
  245. var page = this.getAttribute('page');
  246. //打开详情页面
  247. $.openWindow({
  248. id: page,
  249. url: page + '.html',
  250. extras: {
  251. tid: tid,
  252. fid: fid,
  253. name: name
  254. }
  255. });
  256. });
  257. })
  258. },
  259. error: function(xhr, type, errorThrown) {
  260. //异常处理;
  261. alert(type);
  262. console.log(type);
  263. }
  264. });
  265. }
  266. getDevice();
  267. */
  268. window.addEventListener('resize', function() {
  269. oauthArea.style.display = document.body.clientHeight > 400 ? 'block' : 'none';
  270. }, false);
  271. // Android处理返回键
  272. plus.key.addEventListener('backbutton',function(){
  273. if(confirm('确认退出?')){
  274. plus.runtime.quit();
  275. }
  276. },false);
  277. /*
  278. var backButtonPress = 0;
  279. $.back = function(event) {
  280. backButtonPress++;
  281. if (backButtonPress > 1) {
  282. plus.runtime.quit();
  283. } else {
  284. plus.nativeUI.toast('再按一次退出应用');
  285. }
  286. setTimeout(function() {
  287. backButtonPress = 0;
  288. }, 1000);
  289. return false;
  290. };*/
  291. });
  292. }(mui, document));
  293. </script>
  294. </body>
  295. </html>