123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- <!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" />
- <link href="css/reset-mobile.css" rel="stylesheet" />
-
- <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">
- <div class="mui-inner-wrap">
- <header class="mui-bar mui-bar-nav">
- <a id="code" href="javascript:;" class="mui-icon mui-icon-camera mui-pull-left"></a>
- <a id="info" class="ico-msg has-msgs"></a>
- <h1 class="mui-title">新农宝盒V2</h1>
- </header>
- <div id="offCanvasContentScroll" class="mui-content mui-scroll-wrapper">
- <div class="mui-content" id="content">
-
- </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 scaned( t, r, f ) {
- //alert(t)
- //alert(r)
- //alert(f)
- mui.ajax(r);
- alert('绑定成功!');
- location.reload();
- }
- (function($, self) {
- /*
- $.init
- ({
- beforeback: function(){
- //获得登录界面的webview
- var login = plus.webview.getWebviewById('login');
- //触发登录界面的自定义事件(refresh),从而进行数据刷新
- mui.fire(login,'refresh');
- //返回true,继续页面关闭逻辑
- return true;
- }
- });
- */
- $.plusReady(function() {
-
- //localStorage.setItem('$state', false);
- var stateText = localStorage.getItem('$statev5');
- var state = JSON.parse(stateText);
- if(!state || stateText == '{}')
- {
- var page = 'login';
- $.openWindow({
- id: page,
- url: page + '.html'
- });
- return;
- }
-
-
- //获取页面
- $.ajax('http://v2.xinnongbaohe.com/web/application/front/?home?&header=false', {
- dataType: 'text', //服务器返回json格式数据
- timeout: 10000, //超时时间设置为10秒;
- type: 'get', //HTTP请求类型
- success: function(r) {
- //var t = JSON.parse(r);
- var html = r;
-
- document.getElementById("content").innerHTML = html;
- mui('.product').each(function() {
- document.getElementById(this.id).addEventListener('tap', function(e) {
- var vid = this.getAttribute('vid');
- var name = this.getAttribute('name');
- var live_url = this.getAttribute('live_url');
- var page = 'product';
- //打开详情页面
- $.openWindow({
- id: page,
- url: page + '.html',
- extras: {
- vid: vid,
- name: name,
- live_url:live_url
- }
- });
- });
-
- document.getElementById(this.id+'_a').addEventListener('tap', function(e) {
- var id = this.getAttribute('vid');
- var name = this.getAttribute('name');
- var live_url = this.getAttribute('live_url');
- var page = 'product';
- //打开详情页面
- $.openWindow({
- id: page,
- url: page + '.html',
- extras: {
- vid: id,
- name: name,
- live_url:live_url
- }
- });
- });
- });
- document.getElementById('setting').addEventListener('tap', function(e) {
- var page = 'set';
- //打开详情页面
- $.openWindow({
- id: page,
- url: page + '.html'
- });
- });
-
- document.getElementById('setting_a').addEventListener('tap', function(e) {
- var page = 'set';
- //打开详情页面
- $.openWindow({
- id: page,
- url: page + '.html'
- });
- });
-
- document.getElementById('info').addEventListener('tap', function(e) {
- var page = 'message';
- //打开详情页面
- $.openWindow({
- id: page,
- url: page + '.html'
- });
- });
-
- document.getElementById('code').addEventListener('tap', function(e) {
- var page = 'scan';
- //打开详情页面
- $.openWindow({
- id: page,
- url: page + '.html'
- });
- });
-
-
- document.getElementById('quit').addEventListener('tap', function(e) {
- var page = 'login';
- localStorage.setItem('$statev5', '{}');
- $.ajax('http://v2.xinnongbaohe.com/web/application/passport/?login.quit');
- //打开详情页面
- $.openWindow({
- id: page,
- url: page + '.html'
- });
- });
- }
- });
-
- var func = function()
- {
- $.ajax('http://v2.xinnongbaohe.com/web/application/service/?user.msgnum?json=1', {
- dataType: 'text', //服务器返回json格式数据
- timeout: 10000, //超时时间设置为10秒;
- type: 'get', //HTTP请求类型
- success: function(r) {
- var t = JSON.parse(r);
- if(t.status == 1)
- {
- document.getElementById('info').setAttribute('class', 'ico-msg has-msg');
- }
- else
- {
- document.getElementById('info').setAttribute('class', 'ico-msg');
- }
- }
- });
- };
-
-
- setInterval(func, 1000);
- /*
- 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();
- */
- window.addEventListener('resize', function() {
- oauthArea.style.display = document.body.clientHeight > 400 ? 'block' : 'none';
- }, false);
-
- // Android处理返回键
- plus.key.addEventListener('backbutton',function(){
- if(confirm('确认退出?')){
- plus.runtime.quit();
- }
- },false);
- /*
- var backButtonPress = 0;
- $.back = function(event) {
- backButtonPress++;
- if (backButtonPress > 1) {
- plus.runtime.quit();
- } else {
- plus.nativeUI.toast('再按一次退出应用');
- }
- setTimeout(function() {
- backButtonPress = 0;
- }, 1000);
- return false;
- };*/
- });
- }(mui, document));
- </script>
- </body>
- </html>
|