videoList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <view class="video-list-page">
  3. <van-sticky style="background: #fff">
  4. <view class="flex search-wrap">
  5. <view @click="goSearchPage" style="flex:1;margin-right:30rpx" >
  6. <searchBox
  7. placeholder="关键字搜索"
  8. :hasRightBtn="false"
  9. :disabled="true"
  10. ></searchBox>
  11. </view>
  12. <view class="flex" @click="showFilter=true">
  13. <image style="width:50rpx;height:50rpx" src="@/static/filter-icon.png" mode="aspectFill"/>
  14. <text style="color:#E3B377;font-size:32rpx">筛选</text>
  15. </view>
  16. </view>
  17. </van-sticky>
  18. <view class="empty-box" v-if="list.length==0&&finished">
  19. <image
  20. :src="globalImgUrls.activityNoAuth"
  21. mode="widthFix"
  22. />
  23. <view>暂无数据</view>
  24. </view>
  25. <view class="list-wrap">
  26. <view class="item" v-for="item in list" :key="item.community_video_id">
  27. <view class="title-box">
  28. <text class="tag">{{item.chart_permission_name}}</text>
  29. <text class="title">{{item.title}}</text>
  30. </view>
  31. <button
  32. class="share-btn"
  33. open-type="share"
  34. :data-item="item">
  35. <image class="share-img" src="@/static/share-icon.png" mode="aspectFill"/>
  36. </button>
  37. <video
  38. autoplay
  39. object-fit="contain"
  40. show-mute-btn
  41. :poster="item.cover_img_url"
  42. :src="item.video_url"
  43. enable-play-gesture
  44. :id="item.community_video_id"
  45. @ended="curVideoId=0"
  46. v-if="item.community_video_id==curVideoId"
  47. ></video>
  48. <image @click="handelClickPlay(item)" v-else class="poster" :src="item.cover_img_url" mode="aspectFill" lazy-load/>
  49. <view class="time">发布时间:{{item.publish_time}}</view>
  50. </view>
  51. </view>
  52. <!-- 筛选 -->
  53. <van-popup
  54. :show="showFilter"
  55. position="bottom"
  56. :safe-area-inset-bottom="true"
  57. round
  58. @close="showFilter=false"
  59. >
  60. <view class="filter-wrap">
  61. <view class="flex top">
  62. <text style="color:#000">全部筛选</text>
  63. <text style="color:#E3B377" @click="showFilter=false">取消</text>
  64. </view>
  65. <view class="list-box">
  66. <van-collapse accordion @change="change" :value="active" :border="false">
  67. <van-collapse-item
  68. :title="item.ClassifyName"
  69. :name='item.ClassifyName'
  70. :border="false"
  71. v-for="item in options"
  72. :key="item.ClassifyName"
  73. >
  74. <van-row gutter="5">
  75. <van-col
  76. :span="_item.PermissionName.length>7?16:8"
  77. v-for="_item in item.Items"
  78. :key="_item.PermissionId"
  79. >
  80. <text
  81. :class="['list-item',_item.PermissionId==selectPerId&&'list-item-active']"
  82. @click="handleSelectPerItem(_item)"
  83. >{{_item.PermissionName}}</text>
  84. </van-col>
  85. </van-row>
  86. </van-collapse-item>
  87. </van-collapse>
  88. </view>
  89. </view>
  90. </van-popup>
  91. </view>
  92. </template>
  93. <script>
  94. import {apiVideoList,apiVideoPlayLog} from '@/api/video'
  95. import {apiOptionList} from '@/api/question'
  96. import {apiGetSceneToParams} from '@/api/common'
  97. export default {
  98. data() {
  99. return {
  100. showFilter:false,
  101. active:'',
  102. options:[],
  103. selectPerId:0,
  104. videoId:0,
  105. page:1,
  106. pageSize:10,
  107. finished:false,
  108. list:[],
  109. curVideoId:0,
  110. }
  111. },
  112. onLoad(options){
  113. this.init(options)
  114. this.getPermissionList()
  115. },
  116. onHide(){
  117. this.showFilter=false
  118. this.curVideoId=0
  119. },
  120. onShareAppMessage({from,target}) {
  121. console.log(from,target);
  122. let path='/pages/video/videoList?videoId=0'
  123. let title='FICC视频社区'
  124. let imageUrl=''
  125. if(from=='button'){
  126. title=`${target.dataset.item.chart_permission_name}:${target.dataset.item.title}`
  127. path=`/pages/video/videoList?videoId=${target.dataset.item.community_video_id}`
  128. imageUrl=target.dataset.item.cover_img_url
  129. }
  130. return {
  131. title:title,
  132. path:path,
  133. imageUrl:imageUrl
  134. }
  135. },
  136. onPullDownRefresh(){
  137. this.videoId=0
  138. this.selectPerId=0
  139. this.page=1
  140. this.list=[]
  141. this.finished=false
  142. this.getList()
  143. setTimeout(() => {
  144. uni.stopPullDownRefresh()
  145. }, 1500)
  146. },
  147. methods: {
  148. async init(options){
  149. if(options.scene){
  150. const resScene=await apiGetSceneToParams({scene_key:options.scene})
  151. if(resScene.code===200){
  152. const obj=JSON.parse(resScene.data)
  153. this.videoId=obj.videoId||0
  154. }
  155. }else{
  156. this.videoId=options.videoId||0
  157. }
  158. this.getList()
  159. },
  160. goSearchPage(){
  161. uni.navigateTo({
  162. url: '/pages/video/videoSearch',
  163. });
  164. },
  165. change(e){
  166. this.active=e.detail
  167. },
  168. //点击分类某项
  169. handleSelectPerItem(item){
  170. if(this.selectPerId==item.PermissionId){
  171. this.selectPerId=0
  172. }else{
  173. this.selectPerId=item.PermissionId
  174. }
  175. this.videoId=0//重置掉分享进入的状态
  176. this.curVideoId=0
  177. this.page=1
  178. this.list=[]
  179. this.finished=false
  180. this.getList()
  181. this.showFilter=false
  182. },
  183. async getList(){
  184. const res=await apiVideoList({
  185. page_index:Number(this.page),
  186. page_size:Number(this.pageSize),
  187. video_id:Number(this.videoId),
  188. chart_permission_id:Number(this.selectPerId)
  189. })
  190. if(res.code===200){
  191. let arr=res.data||[]
  192. this.list=[...this.list,...arr]
  193. if(arr.length===0){
  194. this.finished=true
  195. }
  196. }
  197. },
  198. //获取筛选项
  199. async getPermissionList(){
  200. const res=await apiOptionList()
  201. if(res.code===200){
  202. this.options=res.data
  203. }
  204. },
  205. handelClickPlay(item){
  206. this.curVideoId=item.community_video_id
  207. // 记录播放
  208. apiVideoPlayLog({video_id:Number(item.community_video_id)}).then(res=>{
  209. if(res.code===200){
  210. console.log('视频埋点成功');
  211. }
  212. })
  213. }
  214. },
  215. }
  216. </script>
  217. <style lang='scss'>
  218. .search-wrap .van-search{
  219. padding: 0 !important;
  220. }
  221. .video-list-page{
  222. .filter-wrap{
  223. .van-cell__title, .van-cell__value{
  224. flex: none !important;
  225. }
  226. .van-cell:after{
  227. border: none !important;
  228. }
  229. .van-cell__title{
  230. font-size: 14px;
  231. }
  232. .van-hairline--top:after{
  233. border-top-width: 0 !important;
  234. }
  235. }
  236. }
  237. </style>
  238. <style lang="scss" scoped>
  239. .video-list-page{
  240. .search-wrap {
  241. background-color: #fff;
  242. padding: 30rpx 34rpx;
  243. align-items: center;
  244. .menu-icon{
  245. width: 52rpx;
  246. height: 40rpx;
  247. display: block;
  248. flex-shrink: 0;
  249. margin-left: 30rpx;
  250. }
  251. }
  252. .list-wrap{
  253. .item{
  254. border-top: 10rpx solid #f9f9f9;
  255. padding: 30rpx 34rpx;
  256. position: relative;
  257. .title-box{
  258. padding-right: 40rpx;
  259. }
  260. .share-btn{
  261. position: absolute;
  262. top: 34rpx;
  263. right: 34rpx;
  264. background-color: transparent;
  265. width: 36rpx;
  266. height: 36rpx;
  267. line-height: 1;
  268. padding: 0;
  269. &::after{
  270. border: none;
  271. }
  272. }
  273. .share-img{
  274. width: 32.5rpx;
  275. height: 32rpx;
  276. }
  277. .tag{
  278. color: #E4B478;
  279. background-color: #333;
  280. padding: 5rpx 20rpx;
  281. border-radius: 20rpx;
  282. font-size: 24rpx;
  283. margin-right: 26rpx;
  284. }
  285. .title{
  286. font-size: 32rpx;
  287. color: #000;
  288. }
  289. video{
  290. width: 100%;
  291. height: 400rpx;
  292. margin: 30rpx 0 20rpx 0;
  293. border-radius: 20rpx;
  294. }
  295. .poster{
  296. width: 100%;
  297. height: 400rpx;
  298. margin: 30rpx 0 20rpx 0;
  299. border-radius: 20rpx;
  300. position: relative;
  301. &::after{
  302. content:'';
  303. display: block;
  304. position: absolute;
  305. width: 120rpx;
  306. height: 120rpx;
  307. top: 50%;
  308. left: 50%;
  309. transform: translate(-50%,-50%);
  310. background-image: url('@/static/video-play-btn.png');
  311. background-size: cover;
  312. }
  313. }
  314. .time{
  315. font-size: 28rpx;
  316. color: #999;
  317. }
  318. }
  319. }
  320. .empty-box{
  321. text-align: center;
  322. font-size: 32rpx;
  323. color: #999;
  324. padding-top: 150rpx;
  325. image{
  326. width: 80vw;
  327. margin-bottom: 57rpx;
  328. }
  329. }
  330. }
  331. .filter-wrap{
  332. background-color: #fff;
  333. padding-top: 53rpx;
  334. padding-bottom: 100rpx;
  335. .top{
  336. font-size: 32rpx;
  337. justify-content: space-between;
  338. margin-bottom: 40rpx;
  339. padding: 0 34rpx;
  340. }
  341. .list-box{
  342. min-height: 30vh;
  343. max-height: 60vh;
  344. .list-item{
  345. display: block;
  346. margin: 10rpx;
  347. height: 76rpx;
  348. line-height: 76rpx;
  349. color: #000;
  350. background: #F6F6F6;
  351. border-radius: 4px 4px 4px 4px;
  352. text-align: center;
  353. }
  354. .list-item-active{
  355. background-color: #FAEEDE;
  356. }
  357. }
  358. }
  359. </style>