zengh
2021-01-30 3cc9194000c02ffad5080ed97d8379d9976e01c5
src/views/realTimePolice/real.vue
@@ -217,7 +217,9 @@
          </el-col>
          <el-col span="12">
            <el-form-item label="历史视频">
              <el-button type="primary">查看视频</el-button>
              <el-button type="primary" @click.stop="queryOldVideo(form)"
                >查看视频</el-button
              >
            </el-form-item>
          </el-col>
        </el-row>
@@ -251,7 +253,12 @@
        <el-row :align="center">
          <el-col :offset="4">
            <el-form-item>
              <el-button type="success">一键呼叫</el-button>
              <el-button
                :class="{ active: isActive }"
                type="success"
                @click.stop="aKeyToCall($event, form)"
                >一键呼叫</el-button
              >
              <el-button type="success">视频对讲</el-button>
              <el-button type="primary" @click.stop="generate(form)"
                >生成警单</el-button
@@ -289,6 +296,8 @@
import Hls from "hls.js";
import axios from "axios";
import Recorder from "js-audio-recorder";
export default {
  data() {
@@ -471,7 +480,8 @@
          }
        ]
      },
      data: []
      data: [],
      isActive: false
    };
  },
  computed: {
@@ -831,7 +841,7 @@
    beginTimeOrEndTime(time) {
      var beginTime = new Date(time);
      var endTime = new Date(new Date(time).valueOf() - 1000 * 30);
      var endTime = new Date(new Date(time).valueOf() - 1000 * 60 * 60 * 3);
      var beginY = beginTime.getFullYear();
@@ -882,7 +892,6 @@
        endTime.getSeconds() < 10
          ? "0" + endTime.getSeconds()
          : endTime.getSeconds();
      return {
        begin: beginY + beginM + beginD + beginH + beginm + begins,
        end: endY + endM + endD + endH + endm + ends
@@ -897,8 +906,6 @@
          "Content-type": "application/x-www-form-urlencoded"
        }
      });
      //s16s652780.51mypc.cn/api_control
      var time = this.beginTimeOrEndTime(data.alarmTime);
@@ -925,30 +932,30 @@
              this.videoSource = result.data.data.m3u8;
            });
          // newAxios
          //   .post(
          //     "/api_control",
          //     {},
          //     {
          //       params: {
          //         param: JSON.stringify({
          //           PktType: "RemotePlayback",
          //           accessToken: res.data.data.accessToken,
          //           deviceCode: data.channelNumber,
          //           startTime: time.end,
          //           endTime: time.begin,
          //           chl: data.serialNumber
          //         })
          //   newAxios
          //     .post(
          //       "/api_control",
          //       {},
          //       {
          //         params: {
          //           param: JSON.stringify({
          //             PktType: "RemotePlayback",
          //             accessToken: res.data.data.accessToken,
          //             deviceCode: "001231409472",
          //             startTime: "20210130150000",
          //             endTime: "20210130160000",
          //             chl: data.serialNumber
          //           })
          //         }
          //       }
          //     }
          //   )
          //   .then(result => {
          //     )
          //     .then(result => {
          //     this.videoSource = result.data.data.m3u8
          //       this.innerVisibleVideo = true;
          //     this.innerVisibleVideo = true
          //       this.videoSource = result.data.data.m3u8;
          //   });
          //     });
        });
    },
    openOldVideoBox() {
@@ -959,7 +966,11 @@
        this.hls = new Hls();
        console.log(this.videoSource, "19028321321r073");
        var m3u8Url = decodeURIComponent(this.videoSource);
        console.log(m3u8Url);
        this.hls.loadSource(m3u8Url);
@@ -977,6 +988,44 @@
        dom.pause();
        dom.setAttribute("");
      }
    },
    aKeyToCall(e, form) {
      // 一键呼叫相关函数
      if (this.isActive == true) {
        this.isActive = false;
      } else {
        this.isActive = true;
        let recorder = new Recorder({
          sampleBits: 16, // 采样位数,支持 8 或 16,默认是16
          sampleRate: 16000, // 采样率,支持 11025、16000、22050、24000、44100、48000,根据浏览器默认值,我的chrome是48000
          numChannels: 1 // 声道,支持 1 或 2, 默认是1
          // compiling: false,(0.x版本中生效,1.x增加中)  // 是否边录边转换,默认是false
        });
        var newAxios = axios.create({
          baseURL: "http://s16s652780.51mypc.cn",
          withCredentials: false,
          headers: {
            "Content-type": "application/x-www-form-urlencoded"
          }
        });
        //    newAxios
        //       .post(
        //         `/talk?deviceCode=${form.channelNumber}`,
        //         '12345',
        //       )
        //       .then(result => {
        //           console.log(result)
        //       });
      }
    }
  }
@@ -1031,4 +1080,8 @@
  height: calc(100% - 54px);
  box-sizing: border-box;
}
.el-button.active {
  background: red;
}
</style>