index.html 5.09 KB
<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>罗电物联网APP</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
</head>

<body>
  <footer>
  </footer>
</body>

</html>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
    var NVTabBar;
    apiready = function() {
      initHeaderH();
      var footer = $api.dom('footer'); // 获取 footer 标签元素
      var footerH = $api.fixTabBar(footer);
      // $api.clearStorage();
      if (!check()) {
        return false;
      }

      api.addEventListener({
          name:'keyback'
      },function(ret,err){
        api.confirm({
            title:'提示',
            msg:'是否退出罗电?',
            buttons:['确定','取消']
        },function(ret,err){
          if(ret.buttonIndex==1){
            api.closeWidget({
              silent: true
            });
          }
        });
      });
      initPush();//推送相关
      NVTabBar = api.require('NVTabBar');
      initTabBar(footerH); //底部导航
      $api.setStorage('curIndex', 0);     //默认显示首页
    }

    function initTabBar(footerH) {
      NVTabBar.open({
          styles: {
            bg: '#FFFFFF',
            h: 49,
            dividingLine: {     //(可选项)JSON对象;模块顶部的分割线配置
               width: 0.5,      //(可选项)数字类型;分割线粗细;默认:0.5
               color: '#000'    //(可选项)字符串类型;分割线颜色;默认:#000
            },
            badge: {
                bgColor: '#E55741',
                numColor: '#FFFFFF',
                size: 6,
            }
          },
          items: [{
              w: api.winWidth / 3.0,
              bg: {
                  marginB: 0,
                  image: '#FFFFFF'
              },
              iconRect: {
                  w: 21.5,
                  h: 21,
              },
              icon: {
                  normal: 'widget://image/tabar-home-normal.png',
                  highlight: 'widget://image/tabar-home-actived.png',
                  selected: 'widget://image/tabar-home-actived.png'
              },
              title: {
                  text: '首页',
                  size: 11.0,
                  normal: '#9EA9B6',
                  selected: '#1D2229',
                  marginB: 3.0
              }
          }, {
              w: api.winWidth / 3.0,
              bg: {
                  marginB: 0,
                  image: '#FFFFFF'
              },
              iconRect: {
                  w: 21.5,
                  h: 21,
              },
              icon: {
                  normal: 'widget://image/tabar-alarm-normal.png',
                  highlight: 'widget://image/tabar-alarm-actived.png',
                  selected: 'widget://image/tabar-alarm-actived.png'
              },
              title: {
                  text: '所有报警',
                  size: 11.0,
                  normal: '#9EA9B6',
                  selected: '#1D2229',
                  marginB: 3.0
              }
          }, {
              w: api.winWidth / 3.0,
              bg: {
                  marginB: 0,
                  image: '#FFFFFF'
              },
              iconRect: {
                  w: 21.5,
                  h: 21,
              },
              icon: {
                  normal: 'widget://image/tabar-mine-normal.png',
                  highlight: 'widget://image/tabar-mine-actived.png',
                  selected: 'widget://image/tabar-mine-actived.png'
              },
              title: {
                  text: '我的',
                  size: 11.0,
                  normal: '#9EA9B6',
                  selected: '#1D2229',
                  marginB: 3
              }
          }],
          selectedIndex: 0
      }, function(ret, err) {
          var goIndex = '';
          var currentIndex = $api.getStorage('curIndex');
          if (ret.index == currentIndex) {
            return;
          }
          switch (ret.index) {
            case 0:
              goIndex = 'home';
            break;
            case 1:
              goIndex = 'alarm';
            break;
            case 2:
              goIndex = 'mine';
            break;
            default:
              goIndex = 'home';
          }
          $api.setStorage('curIndex', ret.index);

          api.openFrame({
              name: goIndex + 'Index',
              url: './' + goIndex + '/' + goIndex + '.html',
              reload: true,
              rect: {
                  x: 0,
                  y: 0,
                  w: api.winWidth,
                  h: api.winHeight-49-footerH
              },
              bgColor: '#f4f6f9',
              reload: true
          });
      });
    }
</script>