videoList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <template>
  2. <view class="video-list-page" v-if="isAuth">
  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 v-if="videoId">
  24. <view>该视频不存在</view>
  25. <view>请刷新页面后重试</view>
  26. </view>
  27. <view v-else>暂无数据</view>
  28. </view>
  29. <view class="list-wrap">
  30. <view class="item" v-for="item in list" :key="item.community_video_id">
  31. <view class="title-box">
  32. <text class="tag">{{item.variety_tag_name}}</text>
  33. <text class="title">{{item.title}}</text>
  34. </view>
  35. <collectBox
  36. :type="2"
  37. :primaryId="item.community_video_id"
  38. :collectId="item.collection_id"
  39. class="share-btn collect-btn"
  40. />
  41. <button
  42. class="share-btn"
  43. open-type="share"
  44. :data-item="item">
  45. <image class="share-img" src="@/static/share-icon.png" mode="aspectFill"/>
  46. </button>
  47. <view class="time">发布时间:{{item.publish_time}}</view>
  48. <view class="video-content">
  49. <videoBox
  50. :videoInfo="getDanmuData(item)"
  51. :curVideoId="curVideoId"
  52. :showDanmu="showDanmu"
  53. @videoPlay="handelClickPlay"
  54. @ended="handleVideoEnd"
  55. @pause="handleVideoPause"
  56. @timeupdate="handleTimeUpdate"
  57. />
  58. </view>
  59. <comment :showDanmu="showDanmu" :videoInfo="getCommentData(item)"></comment>
  60. </view>
  61. </view>
  62. <!-- 筛选 -->
  63. <van-popup
  64. :show="showFilter"
  65. position="bottom"
  66. :safe-area-inset-bottom="true"
  67. round
  68. @close="showFilter=false"
  69. >
  70. <view class="filter-wrap" @touchmove.stop>
  71. <view class="flex top">
  72. <text style="color:#000">全部筛选</text>
  73. <text style="color:#E3B377" @click="showFilter=false">取消</text>
  74. </view>
  75. <view class="list-box">
  76. <van-collapse accordion @change="change" :value="active" :border="false">
  77. <van-collapse-item
  78. :title="item.ClassifyName"
  79. :name='item.ClassifyName'
  80. :border="false"
  81. v-for="item in options"
  82. :key="item.ClassifyName"
  83. >
  84. <van-row gutter="5">
  85. <van-col
  86. :span="_item.PermissionName.length>7?16:8"
  87. v-for="_item in item.Items"
  88. :key="_item.PermissionId"
  89. >
  90. <text
  91. :class="['list-item',_item.PermissionId==selectPerId&&'list-item-active']"
  92. @click="handleSelectPerItem(_item)"
  93. >{{_item.PermissionName}}</text>
  94. </van-col>
  95. </van-row>
  96. </van-collapse-item>
  97. </van-collapse>
  98. </view>
  99. </view>
  100. </van-popup>
  101. <!-- 跳转去提问悬浮按钮 -->
  102. <dragButton :existTabBar="true">
  103. <navigator url="/pages-question/hasQuestion">
  104. <view class="to-question-fixed-box">
  105. <image src="@/static/toquestion-icon.png" mode="widthFix" />
  106. <text>我要提问</text>
  107. </view>
  108. </navigator>
  109. </dragButton>
  110. </view>
  111. <noAuth :info="noAuthData" v-else/>
  112. </template>
  113. <script>
  114. import {apiVideoList,apiVideoPlayLog} from '@/api/video'
  115. import {apiOptionList} from '@/api/question'
  116. import {apiGetSceneToParams,apiGetTagTree,apiViewLogUpdate} from '@/api/common'
  117. import noAuth from './components/noAuth.vue'
  118. import dragButton from '@/components/dragButton/dragButton.vue'
  119. import comment from '@/components/videoComment/comment.vue'
  120. import collectBox from '@/components/collectBox/collectBox.vue'
  121. import videoBox from '@/components/videoBox/videoBox.vue'
  122. export default {
  123. components:{
  124. noAuth,
  125. comment,
  126. dragButton,
  127. collectBox,
  128. videoBox
  129. },
  130. data() {
  131. return {
  132. showFilter:false,
  133. active:'',
  134. options:[],
  135. selectPerId:0,
  136. videoId:0,
  137. page:1,
  138. pageSize:10,
  139. finished:false,
  140. list:[],
  141. curVideoId:0,
  142. curVideoTime:0,
  143. videoRecordId:0,
  144. isAuth:true,
  145. noAuthData:null,
  146. showDanmu:true,//控制整个模块是否显示弹幕功能(没用了本来后台有个开关功能的 后来不要了 但是还是留着吧)
  147. }
  148. },
  149. onLoad(options){
  150. this.init(options)
  151. this.getPermissionList()
  152. },
  153. onShow(){
  154. //无权限时刷新列表
  155. if(!this.isAuth){
  156. this.getList()
  157. }
  158. },
  159. onHide(){
  160. this.showFilter=false
  161. },
  162. onShareAppMessage({from,target}) {
  163. console.log(from,target);
  164. let path='/pages/video/videoList?videoId=0'
  165. let title='FICC视频社区'
  166. let imageUrl=''
  167. if(from=='button'){
  168. title=`${target.dataset.item.chart_permission_name}:${target.dataset.item.title}`
  169. path=`/pages/video/videoList?videoId=${target.dataset.item.community_video_id}`
  170. imageUrl=target.dataset.item.cover_img_url
  171. }
  172. return {
  173. title:title,
  174. path:path,
  175. imageUrl:imageUrl
  176. }
  177. },
  178. onPullDownRefresh(){
  179. this.videoId=0
  180. this.selectPerId=0
  181. this.page=1
  182. this.list=[]
  183. this.finished=false
  184. this.getList()
  185. setTimeout(() => {
  186. uni.stopPullDownRefresh()
  187. }, 1500)
  188. },
  189. onReachBottom() {
  190. if(this.finished) return
  191. this.page++
  192. this.getList()
  193. },
  194. methods: {
  195. // 处理弹幕模块需要的数据
  196. getDanmuData(item){
  197. return {
  198. source:1,
  199. id:item.community_video_id,
  200. ...item
  201. }
  202. },
  203. // 处理评论模块需要的数据
  204. getCommentData(item){
  205. return {
  206. source:2,
  207. id:item.community_video_id,
  208. ...item
  209. }
  210. },
  211. async init(options){
  212. if(options.scene){
  213. const resScene=await apiGetSceneToParams({scene_key:options.scene})
  214. if(resScene.code===200){
  215. const obj=JSON.parse(resScene.data)
  216. this.videoId=obj.videoId||0
  217. }
  218. }else{
  219. this.videoId=options.videoId||0
  220. }
  221. this.getList()
  222. },
  223. goSearchPage(){
  224. uni.navigateTo({
  225. url: '/pages/video/videoSearch',
  226. });
  227. },
  228. change(e){
  229. this.active=e.detail
  230. },
  231. //点击分类某项
  232. handleSelectPerItem(item){
  233. if(this.selectPerId==item.PermissionId){
  234. this.selectPerId=0
  235. }else{
  236. this.selectPerId=item.PermissionId
  237. }
  238. this.videoId=0//重置掉分享进入的状态
  239. this.curVideoId=0
  240. this.page=1
  241. this.list=[]
  242. this.finished=false
  243. this.getList()
  244. this.showFilter=false
  245. },
  246. async getList(){
  247. const res=await apiVideoList({
  248. page_index:Number(this.page),
  249. page_size:Number(this.pageSize),
  250. video_id:Number(this.videoId),
  251. variety_tag_id:Number(this.selectPerId)
  252. })
  253. if(res.code===200){
  254. let arr=res.data||[]
  255. this.list=[...this.list,...arr]
  256. if(arr.length===0){
  257. this.finished=true
  258. }
  259. this.isAuth=true
  260. }else if(res.code===403){
  261. //无权限用户
  262. this.isAuth=false
  263. this.noAuthData=res.data
  264. }
  265. },
  266. //获取筛选项
  267. async getPermissionList(){
  268. /* const res=await apiOptionList()
  269. if(res.code===200){
  270. this.options=res.data
  271. } */
  272. const res=await apiGetTagTree()
  273. if(res.code===200){
  274. const result = res.data||[];
  275. this.options = result.map(item=>{
  276. let obj = {};
  277. obj.ClassifyName = item.classify_name;
  278. obj.Items = item.tags.map(_item=>{
  279. return {PermissionId:_item.tag_id,PermissionName:_item.tag_name,PriceDrivenState:_item.price_driven_state};
  280. })
  281. return obj;
  282. })
  283. }
  284. },
  285. handelClickPlay(item){
  286. this.curVideoId=item.community_video_id
  287. // 记录播放
  288. apiVideoPlayLog({video_id:Number(item.community_video_id)}).then(res=>{
  289. if(res.code===200){
  290. console.log('视频埋点成功');
  291. this.videoRecordId=res.data
  292. }
  293. })
  294. },
  295. //视频播放结束
  296. handleVideoEnd(){
  297. setTimeout(() => {
  298. this.curVideoId=0
  299. }, 200);
  300. },
  301. //时长变化
  302. handleTimeUpdate(e){
  303. // console.log(this.curVideoId,e.detail.currentTime);
  304. this.curVideoTime=e.detail.currentTime
  305. },
  306. handleVideoPause(){
  307. // console.log(`视频 pause---${this.videoRecordId}----${this.curVideoTime}`);
  308. this.handleUpdateVideoPlayTime()
  309. },
  310. // 更新播放时长
  311. handleUpdateVideoPlayTime(){
  312. if(!this.videoRecordId) return
  313. apiViewLogUpdate({
  314. id:this.videoRecordId,
  315. stop_seconds:parseInt(this.curVideoTime),
  316. source:3
  317. }).then(res=>{
  318. console.log('更新播放时长成功');
  319. })
  320. }
  321. },
  322. }
  323. </script>
  324. <style lang='scss'>
  325. .search-wrap .van-search{
  326. padding: 0 !important;
  327. }
  328. .video-list-page{
  329. .filter-wrap{
  330. .van-cell__title, .van-cell__value{
  331. flex: none !important;
  332. }
  333. .van-cell:after{
  334. border: none !important;
  335. }
  336. .van-cell__title{
  337. font-size: 14px;
  338. }
  339. .van-hairline--top:after{
  340. border-top-width: 0 !important;
  341. }
  342. }
  343. }
  344. </style>
  345. <style lang="scss" scoped>
  346. .video-list-page{
  347. .search-wrap {
  348. background-color: #fff;
  349. padding: 30rpx 34rpx;
  350. align-items: center;
  351. .menu-icon{
  352. width: 52rpx;
  353. height: 40rpx;
  354. display: block;
  355. flex-shrink: 0;
  356. margin-left: 30rpx;
  357. }
  358. }
  359. .list-wrap{
  360. .item{
  361. padding: 30rpx 34rpx;
  362. position: relative;
  363. .title-box{
  364. margin-right: 110rpx;
  365. }
  366. .share-btn{
  367. position: absolute;
  368. top: 34rpx;
  369. right: 34rpx;
  370. background-color: transparent;
  371. width: 36rpx;
  372. height: 36rpx;
  373. line-height: 1;
  374. padding: 0;
  375. &::after{
  376. border: none;
  377. }
  378. }
  379. .share-img{
  380. width: 32.5rpx;
  381. height: 32rpx;
  382. }
  383. .collect-btn{
  384. right: 96rpx;
  385. }
  386. .tag{
  387. color: #E4B478;
  388. background-color: #333;
  389. padding: 5rpx 20rpx;
  390. border-radius: 20rpx;
  391. font-size: 24rpx;
  392. margin-right: 26rpx;
  393. }
  394. .title{
  395. font-size: 32rpx;
  396. color: #000;
  397. }
  398. .video-content{
  399. width: 100%;
  400. height: 400rpx;
  401. margin: 30rpx 0 20rpx 0;
  402. }
  403. .time{
  404. font-size: 28rpx;
  405. color: #999;
  406. margin-top: 20rpx;
  407. }
  408. }
  409. }
  410. .empty-box{
  411. text-align: center;
  412. font-size: 32rpx;
  413. color: #999;
  414. padding-top: 150rpx;
  415. image{
  416. width: 80vw;
  417. margin-bottom: 57rpx;
  418. }
  419. }
  420. }
  421. .filter-wrap{
  422. background-color: #fff;
  423. padding-top: 53rpx;
  424. padding-bottom: 100rpx;
  425. .top{
  426. font-size: 32rpx;
  427. justify-content: space-between;
  428. margin-bottom: 40rpx;
  429. padding: 0 34rpx;
  430. }
  431. .list-box{
  432. min-height: 30vh;
  433. max-height: 60vh;
  434. .list-item{
  435. display: block;
  436. margin: 10rpx;
  437. height: 76rpx;
  438. line-height: 76rpx;
  439. color: #000;
  440. background: #F6F6F6;
  441. border-radius: 4px 4px 4px 4px;
  442. text-align: center;
  443. }
  444. .list-item-active{
  445. background-color: #FAEEDE;
  446. }
  447. }
  448. }
  449. </style>