video.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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="downloadLink(item, $event)">
  44. 保存视频
  45. </div>
  46. </div>
  47. <div class="cover">
  48. <video class="cover" src="123"></video>
  49. <span @click="onPlayer"></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"></SimpleVideoPlayer>
  61. </div>
  62. </template>
  63. <script>
  64. import { mapGetters } from 'vuex'
  65. import { tabs } from '@/configs/tabs'
  66. import downloadLink from '@/utils/download-link'
  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: 4,
  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. downloadLink(item, $event) {
  102. const url = `${process.env.BASE_URL}/download/file?ossName=${item.videoDownloadUrl}&fileName=${item.videoName}`
  103. downloadLink(url, $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.listQuery.videoTitle = keyword
  129. this.listQuery.pageNum = 1
  130. this.fetchList()
  131. },
  132. // 页码变化
  133. onPagiantionChange(index) {
  134. this.listQuery.pageNum = index
  135. this.fetchList()
  136. },
  137. // 加载更多
  138. onLoadMore() {
  139. this.fetchList()
  140. },
  141. },
  142. }
  143. </script>
  144. <style scoped lang="scss">
  145. /* scss中可以用mixin来扩展 */
  146. @mixin ellipsis($line: 1) {
  147. overflow: hidden;
  148. text-overflow: ellipsis;
  149. display: -webkit-box;
  150. -webkit-line-clamp: $line;
  151. -webkit-box-orient: vertical;
  152. }
  153. // pc 端
  154. @media screen and (min-width: 768px) {
  155. .page-top {
  156. height: 360px;
  157. background: url(https://static.caimei365.com/www/authentic/pc/bg-doc.png);
  158. background-size: auto 360px;
  159. .logo {
  160. display: block;
  161. width: 120px;
  162. height: 120px;
  163. border-radius: 50%;
  164. }
  165. .name {
  166. font-size: 30px;
  167. color: #fff;
  168. }
  169. }
  170. .page-content {
  171. width: 1200px;
  172. margin: 0 auto;
  173. background-color: #fff;
  174. .divider {
  175. height: 16px;
  176. background: #f7f7f7;
  177. }
  178. .search {
  179. display: none;
  180. }
  181. }
  182. .list {
  183. border-top: 16px solid #f7f7f7;
  184. border-bottom: 16px solid #f7f7f7;
  185. .section {
  186. padding: 32px 0;
  187. margin: 0 24px;
  188. background: #fff;
  189. border-bottom: 1px solid #d8d8d8;
  190. transition: all 0.4s;
  191. &:last-child {
  192. border-bottom: 0;
  193. }
  194. .info {
  195. width: 880px;
  196. height: 100%;
  197. .name {
  198. height: 56px;
  199. font-size: 18px;
  200. color: #404040;
  201. line-height: 1.6;
  202. margin-bottom: 18px;
  203. @include ellipsis(2);
  204. text-align: justify;
  205. }
  206. .date {
  207. font-size: 18px;
  208. color: #b2b2b2;
  209. line-height: 1.4;
  210. }
  211. .download {
  212. font-size: 16px;
  213. color: #bc1724;
  214. cursor: pointer;
  215. margin-top: 8px;
  216. }
  217. }
  218. .cover {
  219. position: relative;
  220. width: 216px;
  221. height: 132px;
  222. background: #333;
  223. span {
  224. position: absolute;
  225. width: 36px;
  226. height: 36px;
  227. top: 50%;
  228. left: 50%;
  229. transform: translate(-50%, -50%);
  230. background: url(https://static.caimei365.com/www/authentic/h5/icon-play.png)
  231. no-repeat center;
  232. background-size: 36px;
  233. border-radius: 50%;
  234. cursor: pointer;
  235. box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
  236. }
  237. }
  238. }
  239. }
  240. }
  241. // 移动 端
  242. @media screen and (max-width: 768px) {
  243. .page-top {
  244. height: 46vw;
  245. background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
  246. background-size: auto 46vw;
  247. .logo {
  248. display: block;
  249. width: 14.8vw;
  250. height: 14.8vw;
  251. border-radius: 50%;
  252. }
  253. .name {
  254. font-size: 4vw;
  255. color: #fff;
  256. }
  257. }
  258. .page-content {
  259. position: relative;
  260. .divider {
  261. border-bottom: 3.2vw solid #f7f7f7;
  262. height: 12.4vw;
  263. }
  264. }
  265. .search {
  266. position: absolute;
  267. left: 50%;
  268. top: 0;
  269. transform: translate(-50%, -50%);
  270. }
  271. .list {
  272. .section {
  273. position: relative;
  274. padding: 2.4vw 0;
  275. margin: 0 4vw;
  276. padding-bottom: 9.8vw;
  277. background: #fff;
  278. border-bottom: 0.1vw solid #d8d8d8;
  279. &:first-child {
  280. border-top: 0.1vw solid #d8d8d8;
  281. }
  282. .info {
  283. .name {
  284. font-size: 3.6vw;
  285. color: #404040;
  286. line-height: 1.5;
  287. margin-bottom: 2.4vw;
  288. @include ellipsis(2);
  289. text-align: justify;
  290. }
  291. .date {
  292. position: absolute;
  293. left: 0;
  294. bottom: 2.4vw;
  295. font-size: 3.2vw;
  296. color: #b2b2b2;
  297. line-height: 1.4;
  298. }
  299. .download {
  300. position: absolute;
  301. right: 0;
  302. bottom: 2.4vw;
  303. font-size: 3.2vw;
  304. color: #bc1724;
  305. cursor: pointer;
  306. margin-top: 1.2vw;
  307. }
  308. }
  309. .cover {
  310. position: relative;
  311. width: 92vw;
  312. height: 56vw;
  313. border-bottom: 0.1vw solid #d8d8d8;
  314. background: #333;
  315. span {
  316. position: absolute;
  317. width: 12vw;
  318. height: 12vw;
  319. top: 50%;
  320. left: 50%;
  321. transform: translate(-50%, -50%);
  322. background: url(https://static.caimei365.com/www/authentic/h5/icon-play.png)
  323. no-repeat center;
  324. background-size: 12vw;
  325. border-radius: 50%;
  326. cursor: pointer;
  327. box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
  328. }
  329. }
  330. }
  331. }
  332. }
  333. </style>