search.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view class="video-search-page">
  3. <van-sticky style="background: #fff">
  4. <view style="padding:30rpx 34rpx">
  5. <searchBox
  6. :focus="focus"
  7. placeholder="关键字搜索"
  8. @change="onChange"
  9. @search="onSearch"
  10. ></searchBox>
  11. </view>
  12. </van-sticky>
  13. <view class="empty-box" v-if="list.length==0&&finished">
  14. <image
  15. :src="globalImgUrls.activityNoAuth"
  16. mode="widthFix"
  17. />
  18. <view>暂无数据,试试别的搜索词吧~</view>
  19. </view>
  20. <view class="list-wrap">
  21. <view class="item" v-for="item in list" :key="item.road_video_id">
  22. <view class="title-box">
  23. <text class="tag">{{item.chart_permission_name}}</text>
  24. <text class="title">{{item.title}}</text>
  25. </view>
  26. <button
  27. class="share-btn"
  28. open-type="share"
  29. :data-item="item">
  30. <image class="share-img" src="@/static/share-icon.png" mode="aspectFill"/>
  31. </button>
  32. <video
  33. autoplay
  34. object-fit="contain"
  35. show-mute-btn
  36. :poster="item.cover_img_url"
  37. :src="item.video_url"
  38. enable-play-gesture
  39. :id="item.road_video_id"
  40. @ended="handleVideoEnd"
  41. v-if="item.road_video_id==curVideoId"
  42. ></video>
  43. <image @click="handelClickPlay(item)" v-else class="poster" :src="item.cover_img_url" mode="aspectFill" lazy-load/>
  44. <view class="time">发布时间:{{item.publish_time}}</view>
  45. <view class="user-name">{{item.admin_real_name}}</view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import searchBox from '@/components/searchBox/searchBox.vue'
  52. import {apiRoadShowVideoList,apiRoadShowVideoPlayLog} from '@/api/roadShow'
  53. export default {
  54. components: {
  55. searchBox
  56. },
  57. data() {
  58. return {
  59. searchVal:'',
  60. focus:true,
  61. list:[],
  62. finished:false,
  63. page:1,
  64. pageSize:10,
  65. curVideoId:0,
  66. curVideoIns:null
  67. }
  68. },
  69. onReachBottom() {
  70. if(this.finished) return
  71. this.page++
  72. this.getList()
  73. },
  74. onShareAppMessage({from,target}) {
  75. console.log(from,target);
  76. let path='/pages-roadShow/video/list?videoId=0'
  77. let title='FICC线上路演'
  78. let imageUrl=''
  79. if(from=='button'){
  80. title=target.dataset.item.title
  81. path=`/pages-roadShow/video/list?videoId=${target.dataset.item.road_video_id}`
  82. imageUrl=target.dataset.item.cover_img_url
  83. }
  84. return {
  85. title:title,
  86. path:path,
  87. imageUrl:imageUrl
  88. }
  89. },
  90. methods: {
  91. onChange(e){
  92. this.searchVal=e
  93. },
  94. async onSearch(){
  95. this.finished=false
  96. this.page=1
  97. this.list=[]
  98. if(!this.searchVal){
  99. this.finished=true
  100. return
  101. }
  102. this.getList()
  103. },
  104. async getList(){
  105. this.curVideoId=0
  106. const res=await apiRoadShowVideoList({
  107. page_index:Number(this.page),
  108. page_size:Number(this.pageSize),
  109. keywords:this.searchVal
  110. })
  111. if(res.code===200){
  112. let arr=res.data.list||[]
  113. this.list=[...this.list,...arr]
  114. if(res.data.paging.is_end){
  115. this.finished=true
  116. }
  117. }
  118. },
  119. handelClickPlay(item){
  120. this.curVideoId=item.road_video_id
  121. setTimeout(() => {
  122. this.curVideoIns=uni.createVideoContext(this.curVideoId.toString())
  123. }, 300);
  124. // 记录播放
  125. apiRoadShowVideoPlayLog({video_id:Number(item.road_video_id)}).then(res=>{
  126. if(res.code===200){
  127. console.log('视频埋点成功');
  128. }
  129. })
  130. },
  131. //视频播放结束
  132. handleVideoEnd(){
  133. // 此处因为如果不调用退出全屏方法 安卓和ios页面均会表现异常,安卓横屏不恢复竖屏,ios底部tabbar渲染异常
  134. this.curVideoIns.exitFullScreen()
  135. setTimeout(() => {
  136. this.curVideoId=0
  137. this.curVideoIns=null
  138. }, 200);
  139. }
  140. },
  141. }
  142. </script>
  143. <style>
  144. .van-sticky-wrap--fixed{
  145. background-color: #fff;
  146. }
  147. page{
  148. padding-bottom: 0;
  149. }
  150. </style>
  151. <style lang="scss" scoped>
  152. .video-search-page{
  153. .search-wrap {
  154. background-color: #fff;
  155. padding: 30rpx 34rpx;
  156. align-items: center;
  157. .menu-icon{
  158. width: 52rpx;
  159. height: 40rpx;
  160. display: block;
  161. flex-shrink: 0;
  162. margin-left: 30rpx;
  163. }
  164. }
  165. .list-wrap{
  166. .item{
  167. border-top: 10rpx solid #f9f9f9;
  168. padding: 30rpx 34rpx;
  169. position: relative;
  170. .title-box{
  171. padding-right: 40rpx;
  172. }
  173. .share-btn{
  174. position: absolute;
  175. top: 34rpx;
  176. right: 34rpx;
  177. background-color: transparent;
  178. width: 36rpx;
  179. height: 36rpx;
  180. line-height: 1;
  181. padding: 0;
  182. &::after{
  183. border: none;
  184. }
  185. }
  186. .share-img{
  187. width: 32.5rpx;
  188. height: 32rpx;
  189. }
  190. .tag{
  191. color: #E4B478;
  192. background-color: #333;
  193. padding: 5rpx 20rpx;
  194. border-radius: 20rpx;
  195. font-size: 24rpx;
  196. margin-right: 26rpx;
  197. max-width: 250rpx;
  198. overflow: hidden;
  199. text-overflow: ellipsis;
  200. white-space: nowrap;
  201. display: inline-block;
  202. vertical-align: middle;
  203. }
  204. .title{
  205. font-size: 32rpx;
  206. color: #000;
  207. vertical-align: middle;
  208. }
  209. video{
  210. width: 100%;
  211. height: 400rpx;
  212. margin: 30rpx 0 20rpx 0;
  213. border-radius: 20rpx;
  214. }
  215. .poster{
  216. width: 100%;
  217. height: 400rpx;
  218. margin: 30rpx 0 20rpx 0;
  219. border-radius: 20rpx;
  220. position: relative;
  221. &::after{
  222. content:'';
  223. display: block;
  224. position: absolute;
  225. width: 120rpx;
  226. height: 120rpx;
  227. top: 50%;
  228. left: 50%;
  229. transform: translate(-50%,-50%);
  230. background-image: url('@/static/video-play-btn.png');
  231. background-size: cover;
  232. }
  233. }
  234. .time{
  235. font-size: 28rpx;
  236. color: #999;
  237. display: inline-block;
  238. }
  239. .user-name{
  240. float: right;
  241. font-size: 28rpx;
  242. color: #999;
  243. }
  244. }
  245. }
  246. .empty-box{
  247. text-align: center;
  248. font-size: 32rpx;
  249. color: #999;
  250. padding-top: 150rpx;
  251. image{
  252. width: 80vw;
  253. margin-bottom: 57rpx;
  254. }
  255. }
  256. }
  257. </style>