luobisheng
2022-12-09 8561be6f266768316a7866a71d891000e758db32
src/views/systemSetting/device/point/index.vue
@@ -46,14 +46,16 @@
            {{ item.name }}{{ item.community }}
          </div>
          <video
            id="my-video"
            :src="item.urlAddress"
            class="video-js"
            :id="item.id"
            class="video-js vjs-default-skin"
            controls
            preload="auto"
            width="210px"
            height="150px"
          ></video>
            width="300px"
            height="300px"
            type="video/mp4"
            :src="item.urlAddress"
          >
          </video>
        </div>
      </el-main>
      <el-footer>
@@ -71,6 +73,73 @@
    </el-container>
  </el-container>
</template>
<script>
import departmentAside from "@/views/operate/fivepack/threepack/components/aside";
import videoPoint from "@/api/system/videoPoint";
export default {
  name: 'point',
  components: { departmentAside },
   created() {
    this.hls = new Hls();
    this.getVideoPointList();
  },
  data() {
    return {
      currentPage: 1,
      totalNum: 10,
      pageSize: 10,
      videoData: [],
      searchData: null,
      hls: null
    };
  },
  methods: {
    async getVideoPointList(data) {
      let communityId, streetId;
      if (data) {
        communityId = data.parentId;
        streetId = data.id;
      }
      await videoPoint.getVideoPointList({
            current: this.currentPage,
            size: this.pageSize,
            communityId,
            streetId,
          })
          .then(({ records, total }) => {
            this.videoData = records;
            this.totalNum = total;
          })
          .catch((err) => this.$message.error(err));
      this.setVideo();
    },
    setVideo() {
      if (Hls.isSupported()) {
        this.videoData.forEach(video => {
          const videoPlayer = document.getElementById(video.id);
          this.hls.loadSource(video.urlAddress);
          this.hls.attachMedia(videoPlayer);
        })
      }
    },
    selectedDepartment(data) {
      this.currentPage = 1;
      data.parentId = data.id;
      data.id = null;
      this.searchData = data;
      this.getVideoPointList(data);
    },
    current_change(e) {
      this.currentPage = e;
      this.getVideoPointList(this.searchData);
    },
  },
  beforeDestroy() {
    this.hls = null;
  }
};
</script>
<style lang="scss" scoped>
.button-one {
  height: 40px;
@@ -180,56 +249,4 @@
  line-height: 30px;
  font-size: 14px;
}
</style>
<script>
import departmentAside from "@/views/operate/fivepack/threepack/components/aside";
import videoPoint from "@/api/system/videoPoint";
export default {
  components: { departmentAside },
  created() {
    this.getVideoPointList();
  },
  data() {
    return {
      currentPage: 1,
      totalNum: 10,
      pageSize: 10,
      videoData: [],
      searchData: null,
    };
  },
  methods: {
    getVideoPointList(data) {
      let communityId, streetId;
      if (data) {
        communityId = data.parentId;
        streetId = data.id;
      }
      videoPoint
        .getVideoPointList({
          current: this.currentPage,
          size: this.pageSize,
          communityId,
          streetId,
        })
        .then(({ records, total }) => {
          this.videoData = records;
          this.totalNum = total;
        })
        .catch((err) => this.$message.error(err));
    },
    selectedDepartment(data) {
      this.currentPage = 1;
      data.parentId = data.id;
      data.id = null;
      this.searchData = data;
      this.getVideoPointList(data);
    },
    current_change(e) {
      this.currentPage = e;
      this.getVideoPointList(this.searchData);
    },
  },
};
</script>
</style>