index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <el-col :span="8" class="list" v-for="(item, index) in list" :key="index">
  6. <el-col :span="24" class="title">
  7. <span>[{{ item.room_id }}]</span>{{ item.title }}
  8. </el-col>
  9. <el-col :span="24" class="video">
  10. <div class="h5video" :id="item.room_id"></div>
  11. </el-col>
  12. <el-col :span="24" class="btn">
  13. <el-button type="danger" size="mini">强制关闭直播</el-button>
  14. </el-col>
  15. </el-col>
  16. </el-col>
  17. </el-row>
  18. </div>
  19. </template>
  20. <script>
  21. import { mapState, createNamespacedHelpers } from 'vuex';
  22. const { mapActions: dock } = createNamespacedHelpers('dock');
  23. export default {
  24. metaInfo() {
  25. return { title: this.$route.meta.title };
  26. },
  27. name: 'index',
  28. props: {},
  29. components: {},
  30. data: function() {
  31. return {
  32. list: [],
  33. };
  34. },
  35. async created() {
  36. await this.search();
  37. this.$nextTick(() => {
  38. this.searchLive();
  39. });
  40. },
  41. methods: {
  42. ...dock(['query']),
  43. async search() {
  44. let res = await this.query({ status: '1' });
  45. let arr = await this.query({ status: '2' });
  46. var newData = res.data.concat(arr.data);
  47. if (this.$checkRes(newData)) {
  48. this.$set(this, `list`, newData);
  49. }
  50. },
  51. searchLive() {
  52. var envUrl = process.env.VUE_APP_LIVE_URL;
  53. var swfStr = '/platlive/swf/flowplayer-3.2.18.swf';
  54. var obj_1 = {
  55. clip: {
  56. provider: 'rtmp',
  57. bufferLength: 0,
  58. bufferTime: 0,
  59. autoPlay: true,
  60. live: true,
  61. },
  62. plugins: {
  63. rtmp: {
  64. url: 'flowplayer.rtmp-3.2.13.swf',
  65. },
  66. },
  67. };
  68. for (const val of this.list) {
  69. val.url = envUrl + val.room_id;
  70. var videoRoom = document.getElementById(val.room_id);
  71. videoRoom.setAttribute('data-rtmp', val.url);
  72. videoRoom.setAttribute('href', val.url);
  73. const obj_2 = JSON.parse(JSON.stringify(obj_1));
  74. obj_2.plugins.rtmp.netConnectionUrl = val.url;
  75. flowplayer(val.room_id, swfStr, obj_2);
  76. }
  77. },
  78. },
  79. computed: {
  80. ...mapState(['user']),
  81. },
  82. watch: {},
  83. };
  84. </script>
  85. <style lang="less" scoped>
  86. .main {
  87. .list {
  88. width: 32%;
  89. height: 295px;
  90. margin: 0 10px 10px 0;
  91. border-radius: 5px;
  92. padding: 10px;
  93. box-shadow: 0 0 5px #ccc;
  94. .title {
  95. text-align: center;
  96. font-size: 18px;
  97. overflow: hidden;
  98. text-overflow: ellipsis;
  99. -webkit-line-clamp: 2;
  100. word-break: break-all;
  101. display: -webkit-box;
  102. -webkit-box-orient: vertical;
  103. font-weight: bold;
  104. height: 54px;
  105. line-height: 25px;
  106. span {
  107. font-size: 16px;
  108. color: #ff0000;
  109. }
  110. }
  111. .video {
  112. height: 180px;
  113. overflow: hidden;
  114. margin: 0 0 10px 0;
  115. text-align: center;
  116. border: 1px solid #f1f1f1;
  117. .h5video {
  118. width: 100%;
  119. height: 180px;
  120. overflow: hidden;
  121. }
  122. }
  123. .btn {
  124. text-align: center;
  125. }
  126. }
  127. .list:nth-child(3n) {
  128. margin: 0 0 10px 0;
  129. }
  130. .list:hover {
  131. cursor: pointer;
  132. box-shadow: 0 0 5px #666;
  133. .title {
  134. color: #409eff;
  135. }
  136. }
  137. }
  138. </style>