index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view 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. <image :mode="imageMode" :src="item.cover_url" class="cover-img" />
  9. <view class="video-play" @tap="videoPlay(item)">
  10. <view class="iconfont icon-playcircle"></view>
  11. </view>
  12. </view>
  13. </view>
  14. <van-overlay :show="showOverlay" @tap="onClickHideOverlay">
  15. <view class="overlay-wrapper">
  16. <video v-if="videoUrl" :src="videoUrl" controls autoplay loop @tap.stop></video>
  17. </view>
  18. </van-overlay>
  19. </view>
  20. </u-scroll-view>
  21. </view>
  22. </template>
  23. <script>
  24. import NavBar from '@/components/layout/nav-bar'
  25. import UScrollView from '@/components/common/u-scroll-view'
  26. import VanOverlay from '@/wxcomponents/vant/overlay/index'
  27. import {
  28. getDashboardInfo
  29. } from '@/api'
  30. export default {
  31. components: { NavBar, UScrollView, VanOverlay },
  32. data() {
  33. return {
  34. showOverlay: false,
  35. videoList: [],
  36. videoUrl: ''
  37. }
  38. },
  39. props: {
  40. imageMode: {
  41. type: String,
  42. default: 'aspectFill' // 参考https://zh.uniapp.dcloud.io/component/image.html
  43. }
  44. },
  45. mounted() {
  46. this.getVideoData()
  47. },
  48. methods: {
  49. onClickHideOverlay() {
  50. this.showOverlay = false
  51. },
  52. getVideoData() {
  53. getDashboardInfo('', process.env.CONFERENCE_WEBSITE).then(res => {
  54. this.videoList = res.data.module3.video
  55. })
  56. },
  57. videoPlay(item) {
  58. this.videoUrl = item.url
  59. this.showOverlay = true
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="scss">
  65. .video-container {
  66. .video-list {
  67. display: grid;
  68. grid-template-columns: 1fr 1fr;
  69. grid-gap: 30rpx;
  70. .video-item {
  71. width: 100%;
  72. aspect-ratio: 5/3;
  73. position: relative;
  74. border-radius: 14rpx;
  75. overflow: hidden;
  76. .cover-img {
  77. position: absolute;
  78. width: 100%;
  79. height: 100%;
  80. top: 0;
  81. left: 0;
  82. z-index: 1;
  83. }
  84. .video-play {
  85. @include display-flex-center;
  86. position: absolute;
  87. top: 0;
  88. bottom: 0;
  89. right: 0;
  90. left: 0;
  91. width: 70rpx;
  92. height: 70rpx;
  93. border-radius: 50%;
  94. margin: auto;
  95. background-color: rgba(229, 117, 25, 0.5);
  96. z-index: 1;
  97. .iconfont {
  98. color: #FFFFFF;
  99. font-size: 50rpx;
  100. }
  101. }
  102. }
  103. }
  104. .overlay-wrapper {
  105. @include display-flex-center;
  106. height: 100%;
  107. video {
  108. width: 100%;
  109. }
  110. }
  111. }
  112. </style>