123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
- <title></title>
- <link href="css/mui.min.css" rel="stylesheet" />
- <link href="css/main.css" rel="stylesheet" />
- <link href="css/index.css" rel="stylesheet" />
- <script>
- ! function() {
- var e;
- e = function(e) {
- return function(e, t) {
- function i() {
- var t = r.getBoundingClientRect().width;
- t / m > 540 && (t = 540 * m);
- var i = t / 16;
- r.style.fontSize = i + "px", d.rem = e.rem = i
- }
- var a, n = e.document,
- r = n.documentElement,
- o = n.querySelector('meta[name="viewport"]'),
- l = n.querySelector('meta[name="flexible"]'),
- m = 0,
- s = 0,
- d = t.flexible || (t.flexible = {});
- if (o) {
- console.warn("将根据已有的meta标签来设置缩放比例");
- var c = o.getAttribute("content").match(/initial\-scale=([\d\.]+)/);
- c && (s = parseFloat(c[1]), m = parseInt(1 / s))
- } else if (l) {
- var p = l.getAttribute("content");
- if (p) {
- var u = p.match(/initial\-dpr=([\d\.]+)/),
- f = p.match(/maximum\-dpr=([\d\.]+)/);
- u && (m = parseFloat(u[1]), s = parseFloat((1 / m).toFixed(2))), f && (m = parseFloat(f[1]), s = parseFloat((1 / m).toFixed(2)))
- }
- }
- if (!m && !s) {
- var v = (e.navigator.appVersion.match(/android/gi), e.navigator.appVersion.match(/iphone/gi)),
- h = e.devicePixelRatio;
- m = v ? h >= 3 && (!m || m >= 3) ? 3 : h >= 2 && (!m || m >= 2) ? 2 : 1 : 1, s = 1 / m
- }
- if (r.setAttribute("data-dpr", m), !o)
- if (o = n.createElement("meta"), o.setAttribute("name", "viewport"), o.setAttribute("content", "initial-scale=" + s + ", maximum-scale=" + s + ", minimum-scale=" + s + ", user-scalable=no"), r.firstElementChild) r.firstElementChild.appendChild(o);
- else {
- var x = n.createElement("div");
- x.appendChild(o), n.write(x.innerHTML)
- }
- e.addEventListener("resize", function() {
- clearTimeout(a), a = setTimeout(i, 300)
- }, !1), e.addEventListener("pageshow", function(e) {
- e.persisted && (clearTimeout(a), a = setTimeout(i, 300))
- }, !1), "complete" === n.readyState ? n.body.style.fontSize = 12 * m + "px" : n.addEventListener("DOMContentLoaded", function(e) {
- n.body.style.fontSize = 12 * m + "px"
- }, !1), i(), d.dpr = e.dpr = m, d.refreshRem = i, d.rem2px = function(e) {
- var t = parseFloat(e) * this.rem;
- return "string" == typeof e && e.match(/rem$/) && (t += "px"), t
- }, d.px2rem = function(e) {
- var t = parseFloat(e) / this.rem;
- return "string" == typeof e && e.match(/px$/) && (t += "rem"), t
- }
- }(window, window.lib || (window.lib = {})), e
- }()
- }();
- </script>
- <style>
- html,
- body {
- background-color: #efeff4;
- }
-
- p {
- text-indent: 22px;
- }
-
- span.mui-icon {
- font-size: 14px;
- color: #007aff;
- margin-left: -15px;
- padding-right: 10px;
- }
-
- .mui-off-canvas-left {
- color: #fff;
- }
-
- .title {
- margin: 35px 15px 10px;
- }
-
- .title+.content {
- margin: 10px 15px 35px;
- color: #bbb;
- text-indent: 1em;
- font-size: 14px;
- line-height: 24px;
- }
-
- input {
- color: #000;
- }
- </style>
- </head>
- <body>
- <div id="offCanvasWrapper" class="mui-off-canvas-wrap mui-draggable">
- <!--侧滑菜单部分-->
- <aside id="offCanvasSide" class="mui-off-canvas-left">
- <div id="offCanvasSideScroll" class="mui-scroll-wrapper">
- <div class="mui-scroll">
- <div class="title" id="title_user">你好,XXX</div>
- <div class="title">设备选择</div>
- <ul class="mui-table-view mui-table-view-chevron mui-table-view-inverted" id="park">
- <li class="mui-table-view-cell">
- <a class="mui-navigate-right">
- Item 1
- </a>
- </li>
- <li class="mui-table-view-cell">
- <a class="mui-navigate-right">
- Item 2
- </a>
- </li>
-
- </ul>
- <div style="margin-top: 70%;">
- <div class="title" style="text-align: center;">新农宝盒 V2.0</div>
- <div style="text-align: center;">[退出账号]</div>
- </div>
- </div>
- </div>
- </aside>
- <div class="mui-inner-wrap">
- <header class="mui-bar mui-bar-nav">
- <a href="#offCanvasSide" class="mui-icon mui-action-menu mui-icon-bars mui-pull-left maze_menu" style="display:none;"></a>
- <a id="info" href="#" class="ico-msg has-msg"></a>
- <h1 class="mui-title">新农宝盒V2</h1>
- </header>
- <div id="offCanvasContentScroll" class="mui-content mui-scroll-wrapper">
- <div class="mui-content">
- <div class="index" id="device">
- </div>
- </div>
- </div>
-
- <!-- off-canvas backdrop -->
- <div class="mui-off-canvas-backdrop"></div>
- </div>
-
- </div>
- <script src="js/mui.min.js"></script>
- <script src="js/main.js"></script>
- <script type="text/javascript" charset="utf-8">
- (function($, self) {
- $.init
- ({
- beforeback: function(){
- //获得登录界面的webview
- var login = plus.webview.getWebviewById('login');
- //触发登录界面的自定义事件(refresh),从而进行数据刷新
- mui.fire(login,'refresh');
- //返回true,继续页面关闭逻辑
- return true;
- }
- });
- $.plusReady(function() {
-
- var state = app.getState();
- if(state.token)
- {
- self.getElementById('title_user').innerText = '你好,' + state.account;
- }
- //获取设备
- $.ajax('http://company.xinnongbaohe.com/info.farm_list?json=1', {
- dataType: 'text', //服务器返回json格式数据
- timeout: 10000, //超时时间设置为10秒;
- type: 'get', //HTTP请求类型
- success: function(r) {
- var t = JSON.parse(r);
- var html = '';
- var data = [];
- //t.reverse();
- for (var a in t) {
- data.push('<li class="mui-table-view-cell"><a class="mui-navigate-right park-list" vid="' + t[a].id + '" id="park_' + t[a].id + '">' + t[a].name + '</a></li>')
- }
- for (var a in data) {
- html += data[a];
- }
- document.getElementById("park").innerHTML = html;
- mui('.park-list').each(function() {
- document.getElementById(this.id).addEventListener('tap', function(e) {
- $.ajax('http://www.xinnongbaohe.com/index?farm=' + this.getAttribute('vid'), {
- dataType: 'text', //服务器返回json格式数据
- timeout: 10000, //超时时间设置为10秒;
- type: 'get', //HTTP请求类型
- success: function(r) {
- mui('#offCanvasWrapper').offCanvas('close');
-
- getDevice();
- }
- });
- });
- })
- }
- });
- function getDevice() {
- // 获取设备
- $.ajax('http://company.xinnongbaohe.com/info.park?json=1', {
- dataType: 'text', //服务器返回json格式数据
- timeout: 10000, //超时时间设置为10秒;
- type: 'get', //HTTP请求类型
- success: function(r) {
- //alert(t);
- var t = JSON.parse(r);
- //console.info(t);
- //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>';
- var html = '';
- html += '<div class="device-list">';
- var data = [];
- //t.reverse();
- for (var a in t) {
- //alert(t[a].name);
- if (t[a].type == 4) {
- 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>');
- } else if (t[a].type == 3) {
- 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>');
- }
- }
- //alert(data);
- //data.reverse();
- for (var a in data) {
- html += data[a];
- }
- html += '</div>';
- //window.localStorage['device'] = html;
- //alert(html);
- document.getElementById("device").innerHTML = html;
- var detailPage = null;
- mui('.device-item').each(function() {
- document.getElementById(this.id).addEventListener('tap', function(e) {
- var tid = this.getAttribute('tid');
- var fid = this.getAttribute('fid');
- var name = this.getAttribute('name');
- var page = this.getAttribute('page');
- //打开详情页面
- $.openWindow({
- id: page,
- url: page + '.html',
- extras: {
- tid: tid,
- fid: fid,
- name: name
- }
- });
- });
- })
- },
- error: function(xhr, type, errorThrown) {
- //异常处理;
- alert(type);
- console.log(type);
- }
- });
- }
-
- getDevice();
- });
- }(mui, document));
- </script>
- </body>
- </html>
|