<!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: space-between;
            -webkit-justify-content: space-between;
            height: 56px;
            align-items: center;
            color: #5a5a5a;
            font-size: 14px;
            position: relative;
        }
        .video-name{
          display: flex;
          display: -webkit-flex;
          justify-content: flex-start;
          -webkit-justify-content: flex-start;
          align-items: center;
          width: 80%;
        }
        .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;
        }

    </style>
</head>
<body>
<div class="api_layout">
   <ul class="monitorList" id="monitorList">

   </ul>
   <div id="noJurisdiction"> </div>
</div>
<script type="text/template" id="template">
  {{~it:value}}
      <li onclick="SeeVideo('{{=value.deviceSerial}}','{{=value.channelNo}}','{{=value.channelName}}')">
          <div class="video-name">
            <img src="../../icon/video.png" alt="">
            <span>{{=value.channelName}}</span>
          </div>
          <span style="text-align: right;width:20%;margin-left:15px;color:{{=value.status==1?'green':'#ccc'}}">{{=value.status==1?'在线':'不在线'}}</span>
      </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(),token = "";
    apiready = function () {
        var info = $api.getStorage('data'),
            token = JSON.parse(info).data.access_token;
            headers = {
            "Authorization": "Bearer " + token
           };
           getAccessToken()
    };
    // 获取AccessToken
    function getAccessToken() {
      var params = {
        appKey:'de05674f7915474ea9dcdade210636b3',
        appSecret:'7791659d81ad659d00b378718ee5d16f'
      }
      $http.fnReuestDataNologing(UrlRouter.getAccessToken,'','post',params,function (ret, err) {
        if (ret.code ===  '200') {
          token= ret.data.accessToken;
          monitorListFun(ret.data.accessToken)
        }
      })
    }
    function monitorListFun(token) {
      var params = {
        accessToken:token,
        deviceSerial:'C00693494'
      }
        $http.fnReuestData(UrlRouter.getVideoList,'','post',params,function (ret, err) {
          if (ret.data) {
            $apis.html(monitorList,'#template',ret.data);
            toast.hide()
          }
        })
    }
    // 查看视频
    function SeeVideo(deviceSerial,channelNo,name) {
      var params = {
        accessToken:token,
        source:deviceSerial+':'+channelNo
      }
        $http.fnReuestDataNologing(UrlRouter.getVideoUrl,'','post',params,function (ret, err) {
          if (ret.data) {
            if (ret.data[0].ret == '200') {
              $event.openWin('videoWin','videoWin',{url:ret.data[0].hls,title:name,token:token},'')
            }else {
              api.alert({
                  title: '提示',
                  msg: ret.data[0].desc,
              });
            }
          }
        })
    }
</script>
</body>
</html>
