index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <page-layout class="video-container">
  3. <nav-bar title="精彩视频" @init="onInitNavbar"></nav-bar>
  4. <u-scroll-view :tabbar-conflict="true">
  5. <view class="main-container">
  6. <view class="video-list">
  7. <view class="video-item" v-for="(item, index) in videoList" :key="index">
  8. <view class="video-box">
  9. <image :mode="imageMode" :src="item.cover_url" class="cover-img" />
  10. <view class="video-play" @tap="videoPlay(item)">
  11. <view class="iconfont icon-playcircle"></view>
  12. </view>
  13. </view>
  14. <view class="video-title" v-if="item.title">
  15. {{item.title}}
  16. </view>
  17. <view class="video-title" v-else>
  18. 视频标题
  19. </view>
  20. </view>
  21. </view>
  22. <van-overlay :show="showOverlay" @tap="onClickHideOverlay">
  23. <view class="overlay-wrapper" v-if="showOverlay">
  24. <view class="iconfont icon-Cancel"></view>
  25. <video v-if="videoUrl" :src="videoUrl" controls autoplay loop @tap.stop></video>
  26. </view>
  27. </van-overlay>
  28. </view>
  29. </u-scroll-view>
  30. <float-button></float-button>
  31. <van-dialog id="van-dialog" />
  32. </page-layout>
  33. </template>
  34. <script>
  35. import NavBar from '@/components/layout/nav-bar'
  36. import UScrollView from '@/components/common/u-scroll-view'
  37. import VanOverlay from '@/wxcomponents/vant/overlay/index'
  38. import floatButton from "@/components/layout/float-button"
  39. import {
  40. getDashboardInfo
  41. } from '@/api'
  42. import PageLayout from "@/components/layout/page-layout";
  43. export default {
  44. components: {
  45. PageLayout,
  46. NavBar,
  47. UScrollView,
  48. VanOverlay,
  49. floatButton
  50. },
  51. data() {
  52. return {
  53. showOverlay: false,
  54. videoList: [],
  55. videoUrl: ''
  56. }
  57. },
  58. props: {
  59. imageMode: {
  60. type: String,
  61. default: 'aspectFill' // 参考https://zh.uniapp.dcloud.io/component/image.html
  62. }
  63. },
  64. mounted() {
  65. this.getVideoData()
  66. },
  67. methods: {
  68. onClickHideOverlay() {
  69. this.showOverlay = false
  70. },
  71. getVideoData() {
  72. getDashboardInfo('', process.env.CONFERENCE_WEBSITE).then(res => {
  73. this.videoList = res.data.module3.video
  74. console.log(this.videoList);
  75. })
  76. },
  77. videoPlay(item) {
  78. this.videoUrl = item.url
  79. this.showOverlay = true
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss">
  85. .video-container {
  86. .video-list {
  87. display: grid;
  88. grid-template-columns: 1fr;
  89. grid-gap: 40rpx;
  90. .video-item {
  91. display: flex;
  92. flex-direction: column;
  93. align-items: center;
  94. grid-gap: 20rpx;
  95. padding: 40rpx;
  96. background: #ffffff;
  97. box-shadow: 5rpx 5rpx 10rpx #cccccc;
  98. //border: 1px dashed #eeeeee;
  99. border-radius: 10rpx;
  100. .video-box {
  101. width: 100%;
  102. aspect-ratio: 5/3;
  103. position: relative;
  104. border-radius: 14rpx;
  105. overflow: hidden;
  106. .cover-img {
  107. position: absolute;
  108. width: 100%;
  109. height: 100%;
  110. top: 0;
  111. left: 0;
  112. z-index: 1;
  113. }
  114. .video-play {
  115. @include display-flex-center;
  116. position: absolute;
  117. top: 0;
  118. bottom: 0;
  119. right: 0;
  120. left: 0;
  121. width: 70rpx;
  122. height: 70rpx;
  123. border-radius: 50%;
  124. margin: auto;
  125. background-color: rgba(229, 117, 25, 0.5);
  126. z-index: 1;
  127. .iconfont {
  128. color: #FFFFFF;
  129. font-size: 50rpx;
  130. }
  131. }
  132. }
  133. }
  134. }
  135. .overlay-wrapper {
  136. @include display-flex-center;
  137. height: 100%;
  138. .iconfont {
  139. color: #ffffff;
  140. font-size: 86rpx;
  141. position: absolute;
  142. right: 20rpx;
  143. top: 30%;
  144. z-index: 9;
  145. }
  146. video {
  147. width: 100%;
  148. }
  149. }
  150. }
  151. </style>