index.vue 3.1 KB

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