video_1.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div id="video_1">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <van-col span="24" class="video">
  6. <video
  7. autoplay="autoplay"
  8. controls="controls"
  9. preload="meta"
  10. x-webkit-airplay="true"
  11. webkit-playsinline="true"
  12. playsinline="true"
  13. x5-video-player-type="h5"
  14. x5-video-player-fullscreen="true"
  15. :src="videoPath"
  16. v-if="videoData.length > 0"
  17. loop="loop"
  18. >
  19. <source src="movie.ogg" type="video/ogg" />
  20. <source src="movie.mp4" type="video/mp4" />
  21. </video>
  22. <p v-else>{{ form.title }}</p>
  23. </van-col>
  24. <van-col span="24" class="btn">
  25. <el-button type="primary" size="mini" @click="back()">返回列表</el-button>
  26. <el-button type="primary" size="mini" @click="showPopup()">选择视频</el-button>
  27. </van-col>
  28. </el-col>
  29. </el-row>
  30. <van-popup v-model="show" position="bottom">
  31. <van-picker
  32. title="视频信息"
  33. v-model="show"
  34. show-toolbar
  35. :columns="videoData"
  36. @confirm="onConfirm"
  37. @cancel="onCancel"
  38. @change="onChange"
  39. value-key="videointro"
  40. />
  41. </van-popup>
  42. </div>
  43. </template>
  44. <script>
  45. import { mapState, createNamespacedHelpers } from 'vuex';
  46. const _ = require('lodash');
  47. export default {
  48. name: 'video_1',
  49. props: {
  50. form: { type: Object },
  51. },
  52. components: {},
  53. data: function() {
  54. return {
  55. videoData: [],
  56. videoPath: '',
  57. show: false,
  58. };
  59. },
  60. created() {},
  61. methods: {
  62. searchVideo(data) {
  63. let videoData = data.video_data.map(i => i.video_title);
  64. if (videoData) {
  65. this.$set(this, `videoData`, videoData);
  66. this.$set(this, `videoPath`, _.get(_.head(data.video_data), 'video_url'));
  67. }
  68. },
  69. back() {
  70. this.$router.push({ path: '/live/trainInter/index' });
  71. },
  72. showPopup() {
  73. this.show = true;
  74. },
  75. // 选择视频
  76. changeMenu(index, value) {
  77. const item = this.form.video_data[index];
  78. if (item) {
  79. this.$set(this, `videoPath`, item.video_url);
  80. }
  81. },
  82. // 确定选择
  83. onConfirm(value, index) {
  84. this.changeMenu(index, value);
  85. this.onCancel();
  86. },
  87. onChange(value, index) {
  88. this.changeMenu(index, value);
  89. },
  90. // 取消
  91. onCancel() {
  92. this.show = false;
  93. },
  94. },
  95. computed: {
  96. ...mapState(['user']),
  97. },
  98. metaInfo() {
  99. return { title: this.$route.meta.title };
  100. },
  101. watch: {
  102. form: {
  103. deep: true,
  104. immediate: true,
  105. handler(val) {
  106. if (val) {
  107. this.searchVideo(val);
  108. }
  109. },
  110. },
  111. },
  112. };
  113. </script>
  114. <style lang="less" scoped>
  115. .main {
  116. .video {
  117. height: 210px;
  118. overflow: hidden;
  119. .h5video {
  120. width: 100%;
  121. height: 210px;
  122. }
  123. p {
  124. font-size: 18px;
  125. }
  126. }
  127. .btn {
  128. text-align: center;
  129. height: 40px;
  130. padding: 5px 0;
  131. }
  132. }
  133. </style>