EpisodePart.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view v-if="Object.keys(episode).length" class="episode-part">
  3. <view class="footer" :class="{episode: footerShow}">
  4. <view class="bar main-between cross-center" @click="footerShow = !footerShow">
  5. <view class="icon" />
  6. <view class="name">
  7. <u-text :text="episode.name" :color="$colors.infoColor" :lines="1" />
  8. </view>
  9. <view class="arrow">
  10. <u-icon name="arrow-up" :color="$colors.infoColor" size="32rpx" />
  11. </view>
  12. </view>
  13. <view class="episode-container dir-top-wrap">
  14. <!--分集 横向滚动-->
  15. <scroll-view
  16. class="header-box dir-left-nowrap cross-center"
  17. scroll-x
  18. scroll-with-animation
  19. >
  20. <view
  21. v-for="(item,index) in episodeTabData"
  22. :key="index"
  23. class="header-item"
  24. :class="{active: episodesTabIndex === index}"
  25. @click="episodesTabIndex = index"
  26. >{{ item.title }}</view>
  27. </scroll-view>
  28. <!--几集选择-->
  29. <view class="content dir-left-wrap main-left">
  30. <view
  31. v-for="(item, index) in episodeTabData[episodesTabIndex].lists"
  32. :key="index"
  33. class="episode-item"
  34. @click="handleSelectEpisode(item.index)"
  35. >
  36. <image :src="episode.cover_img" />
  37. <text>第{{ item.sort }}集</text>
  38. <view v-if="currentEpisode.sort === item.sort && isPlaying" class="playing" />
  39. <view
  40. v-if="!item.is_free && buyRecord.indexOf(item.id) === -1 && !(episode.is_vip_watch && userInfo.info.is_vip)"
  41. class="lock main-center cross-center"
  42. >
  43. <u-icon name="lock-fill" :color="$colors.defaultColor" size="46rpx" />
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import { mapState } from 'vuex'
  53. export default {
  54. name: 'EpisodePart',
  55. props: {
  56. episode: {
  57. type: Object,
  58. required: true,
  59. default() {
  60. return {}
  61. }
  62. },
  63. currentEpisode: {
  64. type: Object,
  65. required: true
  66. },
  67. isPlaying: {
  68. type: Boolean,
  69. required: true
  70. },
  71. buyRecord: {
  72. type: Array,
  73. required: true
  74. }
  75. },
  76. data() {
  77. return {
  78. footerShow: false, // 底部是否弹出
  79. episodesTabIndex: 0 // 分集 Tab 选中
  80. }
  81. },
  82. computed: {
  83. ...mapState({
  84. userInfo: seate => seate.user.info
  85. }),
  86. episodeTabData() {
  87. const list = []
  88. if (Object.keys(this.episode).length) {
  89. let temp = []
  90. this.episode.lists.forEach((obj, index) => {
  91. temp.push(obj)
  92. if (temp.length === 6 || index === (this.episode.lists.length - 1)) {
  93. const start = list.length ? (list.length * 6) + 1 : 1
  94. const end = (start - 1) + temp.length
  95. list.push({ title: `${start}集-${end}集`, lists: temp })
  96. temp = []
  97. }
  98. })
  99. }
  100. return list
  101. }
  102. },
  103. watch: {
  104. currentEpisode() {
  105. const index = this.episode.lists.findIndex(obj => {
  106. return obj.sort === this.currentEpisode.sort
  107. })
  108. console.log('-->data', index)
  109. }
  110. },
  111. methods: {
  112. handleSelectEpisode(index) {
  113. this.$emit('selectEpisode', index)
  114. this.footerShow = false
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .episode-part {
  121. .footer{
  122. position: fixed;
  123. width: 95vw;
  124. height: 76rpx;
  125. background: rgba(24, 28, 47, 0.8);
  126. bottom: 50rpx;
  127. left: 50%;
  128. transform: translateX(-50%);
  129. font-size: 26rpx;
  130. color: $info-color;
  131. border-radius: 20rpx;
  132. z-index: 999;
  133. transition: .3s;
  134. &.episode{
  135. bottom: 700rpx;
  136. margin-top: -4rpx;
  137. border-bottom-left-radius: 0;
  138. border-bottom-right-radius: 0;
  139. .episode-container{
  140. display: flex;
  141. margin-top: -4rpx;
  142. border-bottom-left-radius: 20px;
  143. border-bottom-right-radius: 20px;
  144. }
  145. .bar{
  146. .arrow{
  147. transform: rotate(180deg);
  148. }
  149. }
  150. }
  151. .bar{
  152. padding: 0 20rpx;
  153. .icon{
  154. background: url("/static/image/video.png") no-repeat center;
  155. background-size: 70%;
  156. width: 80rpx;
  157. height: 80rpx;
  158. }
  159. .name{
  160. text-align: left;
  161. flex: 1;
  162. padding: 0 30rpx;
  163. }
  164. .arrow{
  165. transition: .3s;
  166. }
  167. }
  168. .episode-container{
  169. display: none;
  170. background: inherit;
  171. min-height: 620rpx;
  172. .header-box{
  173. white-space: nowrap;
  174. margin: 20rpx 0;
  175. .header-item{
  176. margin-right: 20rpx;
  177. border-radius: 20rpx;
  178. display: inline-block;
  179. width: 200rpx;
  180. border: 1rpx solid $default-color;
  181. text-align: center;
  182. padding: 10rpx 0;
  183. color: $default-color;
  184. &.active{
  185. border-color: $primary-color;
  186. color: $primary-color;
  187. }
  188. }
  189. }
  190. .content{
  191. margin-top: 20rpx;
  192. .episode-item{
  193. position: relative;
  194. width: calc((100% - #{40rpx}) / 3);
  195. margin-right: 20rpx;
  196. margin-bottom: 20rpx;
  197. overflow: hidden;
  198. border-radius: 18rpx;
  199. &:nth-child(3n){
  200. margin-right: 0;
  201. }
  202. .playing{
  203. position: absolute;
  204. top: 0;
  205. left: 0;
  206. bottom: 0;
  207. right: 0;
  208. background: rgba(0,0,0,.5) url("/static/image/playing.png") no-repeat center;
  209. background-size: 40rpx;
  210. z-index: 2;
  211. }
  212. image{
  213. width: 100%;
  214. height: 260rpx;
  215. }
  216. text{
  217. position: absolute;
  218. left: 0;
  219. bottom: 0;
  220. right: 0;
  221. color: $default-color;
  222. padding: 20rpx 0;
  223. text-align: center;
  224. background: rgba(0,0,0,.3);
  225. z-index: 1;
  226. }
  227. .lock{
  228. position: absolute;
  229. top: 0;
  230. left: 0;
  231. bottom: 0;
  232. right: 0;
  233. background: rgba(0,0,0,.5);
  234. z-index: 2;
  235. }
  236. }
  237. }
  238. }
  239. }
  240. }
  241. </style>