<!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></title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/style.css" />
    <link rel="stylesheet" href="../../css/aui.css" />
    <link rel="stylesheet" href="../../css/projeck.css" />
    <style>
      body,
      html {
        background: #fff;
        overflow: hidden;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        position: relative;
      }
      .api_layout {
        height: 100%;
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
      }
      .monitorList {
        padding: 14px;
      }
      .monitorList li {
        display: flex;
        display: -webkit-flex;
        justify-content: flex-start;
        -webkit-justify-content: flex-start;
        height: 56px;
        line-height: 56px;
        align-items: center;
        color: #5a5a5a;
        font-size: 14px;
        position: relative;
      }
      .monitorList li:after {
        content: '';
        display: table;
        position: absolute;
        width: 100%;
        height: 1px;
        background: #e8e9ea;
        bottom: 0;
        left: 0;
      }
      .monitorList li img {
        width: 42px;
        height: 42px;
        display: block;
        -webkit-border-radius: 50%;
        -moz-border-radius: 50%;
        border-radius: 50%;
        margin-right: 19px;
      }
      .right_side {
        position: absolute;
        top: 0;
        right: -100%;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        transition: 0.5ms;
      }
      .list {
        position: absolute;
        top: 0;
        right: -75%;
        width: 75%;
        height: 100%;
        background: #fff;
        transition: 0.3s;
      }
      .titles {
        height: 38px;
        line-height: 38px;
        padding-left: 15px;
        font-size: 15px;
        color: #2c3e50;
        position: relative;
      }
      .titles:after {
        content: '';
        display: table;
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 1px;
        background: #009fe8;
      }
      .titles i {
        display: block;
        width: 19px;
        height: 19px;
        line-height: 19px;
        background: url('../../image/close.png') no-repeat;
        background-size: cover;
        text-align: center;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        position: absolute;
        top: 8px;
        right: 10px;
        color: #ced3d6;
        font-size: 8px;
      }
      .api_lists {
        padding: 0 14px;
        height: 100%;
        overflow-y: scroll;
        padding-bottom: 38px;
        -webkit-overflow-scrolling: touch;
      }
      .api_lists li {
        display: flex;
        display: -webkit-flex;
        justify-content: flex-start;
        -webkit-justify-content: flex-start;
        height: 90px;
        align-items: center;
        position: relative;
      }
      .info p {
        font-size: 15px;
      }
      .api_lists li:after {
        content: '';
        display: table;
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 1px;
        background: #e8e9ea;
      }
      .api_lists li p {
        color: #2c3e50;
        font-size: 13px;
      }
      .monitorImg {
        width: 75px;
        height: 56px;
        display: block;
        margin-right: 20px;
      }
      .SeeBtn {
        height: 24px;
        line-height: 24px;
        width: 71px;
        text-align: center;
        color: #fff;
        background: #009fe8;
        font-size: 10px;
        -webkit-border-radius: 50px;
        -moz-border-radius: 50px;
        border-radius: 50px;
        margin-top: 15px;
      }
      .api_lists #contetnNo {
        text-align: center;
        font-size: 14px;
        color: #bdc3c7;
        height: 50px;
        margin-top: 20px;
        /*justify-content: center;
          -webkit-justify-content: center;*/
        display: none;
      }
      .api_lists #contetnNo:after {
        content: '';
        display: table;
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 0;
        background: #e8e9ea;
      }
      #noJurisdiction {
        background: url('../../image/no.png') no-repeat;
        background-size: contain;
        position: absolute;
        top: -50%;
        left: 0;
        bottom: 0;
        right: 0;
        margin: auto;
        width: 125px;
        height: 142px;
        display: none;
      }
      .ico-loading {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        margin: auto;
        width: 35px;
        height: 35px;
        background: url('../../icon/loading.gif') no-repeat;
        background-size: cover;
        background-position: center;
      }
      .loading {
        position: absolute;
        width: 100%;
        height: 100%;
        background: rgba(255, 255, 255, 0.3);
        top: 0;
        left: 0;
      }
    </style>
  </head>
  <body>
    <div class="api_layout">
      <ul class="monitorList" id="monitorList"></ul>
      <div id="noJurisdiction"></div>
    </div>
    <!--侧滑 遮罩层-->
    <div class="right_side" onclick="recoveryFun()"></div>
    <!--视频列表-->
    <div class="list">
      <p class="titles">
        <span></span>
        <i onclick="recoveryFun()"></i>
      </p>
      <ul class="api_lists" id="api_lists">
        <li id="contetnNo">-暂无内容-</li>
      </ul>
      <div class="loading">
        <i class="ico-loading"></i>
      </div>
    </div>

    <script type="text/template" id="template">
      {{~it:value}}
        {{?value.indexCode!='root000000'}}
          <li onclick="seeMonitorList('{{=value.indexCode}}','{{=value.name}}','')">
              <img src="../../icon/video.png" alt="">
              <span>{{=value.name}}</span>
          </li>
        {{?}}
      {{~}}
    </script>
    <script type="text/template" id="template01">
      {{~it:value}}
      <li>
          <img src="http://jiewei-icon.oss-cn-beijing.aliyuncs.com/default-img-150x112.png" alt="" class="monitorImg">
          <div class="info">
              <p>{{=value.cameraName}}</p>
              <button type="button" class="SeeBtn" onclick="SeeVideo('{{=value.cameraIndexCode}}','{{=value.cameraName}}','{{=value.regionIndexCode}}')">查看监控</button>
          </div>
      </li>
      {{~}}
    </script>
    <script src="../../script/api.js"></script>
    <script src="../../script/doT.min.js"></script>
    <script src="../../script/config.js"></script>
    <script>
      var toast = new auiToast(),
        headers = '';
      apiready = function () {
        var info = $api.getStorage('data'),
          token = JSON.parse(info).data.access_token;
        headers = {
          Authorization: 'Bearer ' + token,
        };
        monitorListFun(headers);
      };
      function monitorListFun(header) {
        $http.fnReuestData(zaoquanUrlRouter.selectRootRequest,header,'get','',function (ret, err) {
            if (ret.code === '0') {
              $apis.html(monitorList, '#template', ret.data.list);
              toast.hide();
            }
          }
        );
      }
      function seeMonitorList(id, title, name) {
        $api.removeCls($api.dom('.loading'), 'hide');
        $api.html($api.dom('.titles>span'), title);
        var list = document.querySelector('.list'),
          right_side = document.querySelector('.right_side');
        list.style.right = '0';
        right_side.style.right = '0';
        var regionUuid = {
          indexCode: id,
          pageNum: 1,
          pageSize: 200,
        };
        $http.fnReuestDataNologing(
          zaoquanUrlRouter.selectResourceList,
          headers,
          'get',
          regionUuid,
          function (ret, err) {
            toast.hide();
            if (ret.code === '0') {
              if (ret.data.list.length > 0) {
                $apis.html(api_lists, '#template01', ret.data.list);
                $api.addCls($api.dom('.loading'), 'hide');
              } else {
                $api.addCls($api.dom('.loading'), 'hide');
                document.getElementById('contetnNo').style.display = 'block';
              }
            }
          }
        );
      }
      function recoveryFun() {
        var list = document.querySelector('.list'),
          right_side = document.querySelector('.right_side');
        list.style.right = '-75%';
        right_side.style.right = '-100%';
      }
      // 查看视频
      function SeeVideo(id, title, regionIndexCode1) {
        $http.fnReuestDataNologing(
          zaoquanUrlRouter.selectResourcePreviewURLs,
          headers,
          'get',
          {cameraIndexCode: id, regionIndexCode: regionIndexCode1},
          function (ret, err) {
            if (ret.code === '0') {
              var pageParam = {
                videoUrl: ret.data.url,
                title: title,
              };
              var video = api.require('modulehikvision');
              var param = {
                url:
                  'rtsp://120.253.43.7' +
                  ret.data.url.substring(ret.data.url.lastIndexOf(':')),
              };
              video.start2HikVisionLogin(param);
            }
          }
        );
      }
    </script>
  </body>
</html>
