VideoList.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <div class="video-list">
  3. <div class="tab-bar">
  4. <button
  5. v-for="(item) in typeList"
  6. :key="item"
  7. class="tab-item"
  8. :class="{
  9. active: item === activeType
  10. }"
  11. @click="activeType = item"
  12. >
  13. {{ item }}
  14. </button>
  15. </div>
  16. <ul>
  17. <li
  18. v-for="(item, index) in activeTypeObj.titleList"
  19. :key="index"
  20. @click="onClickVideoTitle(index)"
  21. >
  22. {{ item }}
  23. </li>
  24. </ul>
  25. <div
  26. v-if="isShowVideo"
  27. class="video-wrap"
  28. >
  29. <button
  30. class="close"
  31. @click="onClickClose"
  32. >
  33. <img
  34. src="@/assets/images/close.png"
  35. alt="关闭"
  36. draggable="false"
  37. >
  38. </button>
  39. <video
  40. :src="videoSrc"
  41. controls
  42. autoplay
  43. />
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. import videoList from "@/components/videoList.js"
  49. export default {
  50. data() {
  51. return {
  52. videoList,
  53. activeType: videoList[0].type,
  54. videoSrc: '',
  55. isShowVideo: false,
  56. }
  57. },
  58. computed: {
  59. typeList() {
  60. return videoList.map((item) => {
  61. return item.type
  62. })
  63. },
  64. activeTypeObj() {
  65. return videoList.find((item) => {
  66. return item.type === this.activeType
  67. })
  68. }
  69. },
  70. methods: {
  71. onClickVideoTitle(index) {
  72. this.videoSrc = this.activeTypeObj.urlList[index]
  73. this.isShowVideo = true
  74. },
  75. onClickClose() {
  76. this.isShowVideo = false
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="less" scoped>
  82. .video-list {
  83. display: flex;
  84. flex-direction: column;
  85. > .tab-bar {
  86. flex: 0 0 auto;
  87. text-align: center;
  88. margin-bottom: 1em;
  89. > button {
  90. font-size: 24px;
  91. color: #494140;
  92. width: 120px;
  93. height: 1.6em;
  94. background: #ccc;
  95. &.active {
  96. background: #A10E0C;
  97. color: #fff;
  98. }
  99. }
  100. }
  101. > ul {
  102. flex: 1 0 1px;
  103. list-style-type: disc;
  104. padding-left: 2em;
  105. overflow: auto;
  106. > li {
  107. font-size: 16px;
  108. display: list-item;
  109. cursor: pointer;
  110. margin-bottom: 0.3em;
  111. color: #494140;
  112. position: relative;
  113. &:hover {
  114. color: #A10E0C;
  115. }
  116. }
  117. }
  118. > .video-wrap {
  119. background: black;
  120. position: absolute;
  121. z-index: 0;
  122. left: 0;
  123. top: -8px;
  124. width: 100%;
  125. height: calc(100% + 8px * 2);
  126. > button.close {
  127. position: absolute;
  128. top: 29px;
  129. right: 37px;
  130. width: 28px;
  131. height: 28px;
  132. z-index: 1;
  133. > img {
  134. width: 100%;
  135. height: 100%;
  136. }
  137. }
  138. > video {
  139. background: black;
  140. width: 100%;
  141. height: 100%;
  142. }
  143. }
  144. }
  145. ::-webkit-scrollbar { width: 5px; height: 5px;} /*宽度是对垂直滚动条而言,高度是对水平滚动条而言*/
  146. ::-webkit-scrollbar-thumb { background: #930909; border-radius: 2.5px; }
  147. ::-webkit-scrollbar-button { display: none; }
  148. ::-webkit-scrollbar-track { background: transparent; background: #ccc; border-radius: 2.5px; }
  149. // 横竖滚动条轨道交汇处
  150. ::-webkit-scrollbar-corner { background: transparent; }
  151. // 有必要给resizer设置border_radius吗?
  152. ::-webkit-scrollbar-resizer { background: transparent; }
  153. </style>