video.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <div class="page">
  3. <van-list
  4. v-model="isLoadingMore"
  5. :finished="finished"
  6. :immediate-check="false"
  7. :finished-text="total ? '没有更多了' : ''"
  8. @load="onLoadMore"
  9. >
  10. <div class="page-top flex flex-col justify-center items-center">
  11. <!-- <img class="logo" :src="supplierInfo.logo" /> -->
  12. <span
  13. class="name mt-2"
  14. v-text="supplierInfo.shopName + '资料库'"
  15. ></span>
  16. </div>
  17. <div class="page-content">
  18. <!-- 搜索区域 -->
  19. <div class="search">
  20. <simple-search
  21. v-model="listQuery.videoTitle"
  22. @search="onSearch"
  23. placeholder="搜索视频"
  24. />
  25. </div>
  26. <div class="divider"></div>
  27. <!-- tabbar -->
  28. <simple-tabs
  29. :tabs="tabs"
  30. :current="current"
  31. @change="onTabChange"
  32. @search="onSearch"
  33. ></simple-tabs>
  34. <div class="list">
  35. <div
  36. class="section md:flex md:justify-between md:items-center"
  37. v-for="item in list"
  38. :key="item.videoId"
  39. >
  40. <div class="info">
  41. <div class="name" v-text="item.videoTitle"></div>
  42. <div class="date">{{ item.createTime | dateFormat }}</div>
  43. <div class="download" @click="download(item, $event)">
  44. 保存视频
  45. </div>
  46. </div>
  47. <div class="cover">
  48. <video class="cover" :src="item.videoPreviewUrl" :poster="item.videoImage"></video>
  49. <span @click="onPlayer(item)"></span>
  50. </div>
  51. </div>
  52. </div>
  53. <!-- 列表为空 -->
  54. <SimpleEmpty
  55. v-if="!total && !isRequest"
  56. description="敬请期待~"
  57. ></SimpleEmpty>
  58. </div>
  59. </van-list>
  60. <SimpleVideoPlayer ref="player" :videoSrc="videoUrl"></SimpleVideoPlayer>
  61. </div>
  62. </template>
  63. <script>
  64. import { mapGetters } from 'vuex'
  65. import { tabs } from '@/configs/tabs'
  66. import downloadFile from '~/utils/donwload-tools'
  67. import { debounce } from '~/utils'
  68. export default {
  69. layout: 'app',
  70. data() {
  71. return {
  72. isLoadingMore: true,
  73. finished: false,
  74. isRequest: true,
  75. tabs: tabs(),
  76. current: 2,
  77. listQuery: {
  78. videoTitle: '',
  79. authUserId: '102',
  80. pageNum: 1,
  81. pageSize: 10,
  82. },
  83. list: [],
  84. total: 0,
  85. videoUrl: '',
  86. }
  87. },
  88. computed: {
  89. ...mapGetters(['routePrefix', 'supplierInfo', 'authUserId']),
  90. },
  91. mounted() {
  92. this.fetchList()
  93. },
  94. methods: {
  95. // 视频在线播放
  96. onPlayer(item) {
  97. this.videoUrl = item.videoPreviewUrl
  98. this.$refs.player.open()
  99. },
  100. // 下载方法
  101. download(item, $event) {
  102. const url = `${process.env.BASE_URL}/download/file?ossName=${item.videoDownloadUrl}&fileName=${item.videoName}`
  103. downloadFile(url, item.videoName, this, $event)
  104. },
  105. // 获取列表
  106. fetchList: debounce(async function () {
  107. try {
  108. this.isLoadingMore = true
  109. this.listQuery.authUserId = this.authUserId
  110. const res = await this.$http.api.getVideoList(this.listQuery)
  111. this.list = [...this.list, ...res.data.list]
  112. this.finished = !res.data.hasNextPage
  113. this.listQuery.pageNum += 1
  114. this.isLoadingMore = false
  115. this.total = res.data.total
  116. } catch (error) {
  117. console.log(error)
  118. } finally {
  119. this.isRequest = false
  120. }
  121. }, 400),
  122. // tab切换
  123. onTabChange(item) {
  124. this.$router.push(`${this.routePrefix}${item.path}`)
  125. },
  126. // 搜索
  127. onSearch(keyword) {
  128. this.list = []
  129. this.listQuery.videoTitle = keyword
  130. this.listQuery.pageNum = 1
  131. this.fetchList()
  132. },
  133. // 页码变化
  134. onPagiantionChange(index) {
  135. this.listQuery.pageNum = index
  136. this.fetchList()
  137. },
  138. // 加载更多
  139. onLoadMore() {
  140. this.fetchList()
  141. },
  142. },
  143. }
  144. </script>
  145. <style scoped lang="scss">
  146. /* scss中可以用mixin来扩展 */
  147. @mixin ellipsis($line: 1) {
  148. overflow: hidden;
  149. text-overflow: ellipsis;
  150. display: -webkit-box;
  151. -webkit-line-clamp: $line;
  152. -webkit-box-orient: vertical;
  153. }
  154. // pc 端
  155. @media screen and (min-width: 768px) {
  156. .page-top {
  157. height: 360px;
  158. @include themify($themes) {
  159. background: themed('pc-banner-doc');
  160. }
  161. background-size: auto 360px;
  162. .logo {
  163. display: block;
  164. width: 120px;
  165. height: 120px;
  166. border-radius: 50%;
  167. background: #fff;
  168. }
  169. .name {
  170. font-size: 30px;
  171. color: #fff;
  172. }
  173. }
  174. .page-content {
  175. width: 1200px;
  176. margin: 0 auto;
  177. background-color: #fff;
  178. .divider {
  179. height: 16px;
  180. background: #f7f7f7;
  181. }
  182. .search {
  183. display: none;
  184. }
  185. }
  186. .list {
  187. border-top: 16px solid #f7f7f7;
  188. border-bottom: 16px solid #f7f7f7;
  189. .section {
  190. padding: 32px 0;
  191. margin: 0 24px;
  192. background: #fff;
  193. border-bottom: 1px solid #d8d8d8;
  194. transition: all 0.4s;
  195. &:last-child {
  196. border-bottom: 0;
  197. }
  198. .info {
  199. width: 880px;
  200. height: 100%;
  201. .name {
  202. height: 56px;
  203. font-size: 18px;
  204. color: #404040;
  205. line-height: 1.6;
  206. margin-bottom: 18px;
  207. @include ellipsis(2);
  208. text-align: justify;
  209. }
  210. .date {
  211. font-size: 18px;
  212. color: #b2b2b2;
  213. line-height: 1.4;
  214. }
  215. .download {
  216. font-size: 16px;
  217. color: #1890ff;
  218. cursor: pointer;
  219. margin-top: 8px;
  220. }
  221. }
  222. .cover {
  223. position: relative;
  224. width: 216px;
  225. height: 132px;
  226. background: #333;
  227. span {
  228. position: absolute;
  229. width: 36px;
  230. height: 36px;
  231. top: 50%;
  232. left: 50%;
  233. transform: translate(-50%, -50%);
  234. background: url(~assets/theme-images/common/h5-icon-play.png)
  235. no-repeat center;
  236. background-size: 36px;
  237. border-radius: 50%;
  238. cursor: pointer;
  239. box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
  240. }
  241. }
  242. }
  243. }
  244. }
  245. // 移动 端
  246. @media screen and (max-width: 768px) {
  247. .page-top {
  248. height: 46vw;
  249. @include themify($themes) {
  250. background: themed('h5-banner-doc');
  251. }
  252. background-size: auto 46vw;
  253. .logo {
  254. display: block;
  255. width: 14.8vw;
  256. height: 14.8vw;
  257. border-radius: 50%;
  258. background: #fff;
  259. }
  260. .name {
  261. font-size: 4vw;
  262. color: #fff;
  263. }
  264. }
  265. .page-content {
  266. position: relative;
  267. .divider {
  268. border-bottom: 3.2vw solid #f7f7f7;
  269. height: 12.4vw;
  270. }
  271. }
  272. .search {
  273. position: absolute;
  274. left: 50%;
  275. top: 0;
  276. transform: translate(-50%, -50%);
  277. }
  278. .list {
  279. .section {
  280. position: relative;
  281. padding: 2.4vw 0;
  282. margin: 0 4vw;
  283. padding-bottom: 9.8vw;
  284. background: #fff;
  285. border-bottom: 0.1vw solid #d8d8d8;
  286. &:first-child {
  287. border-top: 0.1vw solid #d8d8d8;
  288. }
  289. .info {
  290. .name {
  291. font-size: 3.6vw;
  292. color: #404040;
  293. line-height: 1.5;
  294. margin-bottom: 2.4vw;
  295. @include ellipsis(2);
  296. text-align: justify;
  297. }
  298. .date {
  299. position: absolute;
  300. left: 0;
  301. bottom: 2.4vw;
  302. font-size: 3.2vw;
  303. color: #b2b2b2;
  304. line-height: 1.4;
  305. }
  306. .download {
  307. position: absolute;
  308. right: 0;
  309. bottom: 2.4vw;
  310. font-size: 3.2vw;
  311. @include themify($themes) {
  312. color: themed('color');
  313. }
  314. cursor: pointer;
  315. margin-top: 1.2vw;
  316. }
  317. }
  318. .cover {
  319. position: relative;
  320. width: 92vw;
  321. height: 56vw;
  322. border-bottom: 0.1vw solid #d8d8d8;
  323. background: #333;
  324. span {
  325. position: absolute;
  326. width: 12vw;
  327. height: 12vw;
  328. top: 50%;
  329. left: 50%;
  330. transform: translate(-50%, -50%);
  331. background: url(~assets/theme-images/common/h5-icon-play.png)
  332. no-repeat center;
  333. background-size: 12vw;
  334. border-radius: 50%;
  335. cursor: pointer;
  336. box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
  337. }
  338. }
  339. }
  340. }
  341. }
  342. </style>