video.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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 v-model="listQuery.videoTitle" @search="onSearch" />
  21. </div>
  22. <div class="divider"></div>
  23. <!-- tabbar -->
  24. <simple-tabs
  25. :tabs="tabs"
  26. :current="current"
  27. @change="onTabChange"
  28. @search="onSearch"
  29. ></simple-tabs>
  30. <div class="list">
  31. <div
  32. class="section md:flex md:justify-between md:items-center"
  33. v-for="item in list"
  34. :key="item.videoId"
  35. >
  36. <div class="info">
  37. <div class="name" v-text="item.videoTitle"></div>
  38. <div class="date">{{ item.createTime | dateFormat }}</div>
  39. <div class="download" @click="downloadLink(item)">保存视频</div>
  40. </div>
  41. <video class="cover" :src="item.videoPreviewUrl"></video>
  42. </div>
  43. </div>
  44. <!-- 列表为空 -->
  45. <SimpleEmpty
  46. v-if="!total && !isRequest"
  47. description="敬请期待~"
  48. ></SimpleEmpty>
  49. </div>
  50. </van-list>
  51. </div>
  52. </template>
  53. <script>
  54. import { mapGetters } from 'vuex'
  55. import { tabs } from '@/configs/tabs'
  56. import downloadLink from '@/utils/download-link'
  57. import { debounce } from '~/utils'
  58. export default {
  59. layout: 'app',
  60. data() {
  61. return {
  62. isLoadingMore: true,
  63. finished: false,
  64. isRequest: true,
  65. tabs: tabs(),
  66. current: 2,
  67. listQuery: {
  68. videoTitle: '',
  69. authUserId: '102',
  70. pageNum: 1,
  71. pageSize: 4,
  72. },
  73. list: [],
  74. total: 0,
  75. }
  76. },
  77. computed: {
  78. ...mapGetters(['userInfo', 'supplierInfo']),
  79. },
  80. mounted() {
  81. this.fetchList()
  82. },
  83. methods: {
  84. // 下载方法
  85. downloadLink(item) {
  86. const url = `${process.env.BASE_URL}/download/file?ossName=${item.videoDownloadUrl}&fileName=${item.videoName}`
  87. downloadLink(url)
  88. },
  89. // 获取列表
  90. fetchList: debounce(async function () {
  91. try {
  92. this.isLoadingMore = true
  93. this.listQuery.authUserId = this.userInfo.authUserId
  94. const res = await this.$http.api.getVideoList(this.listQuery)
  95. this.list = [...this.list, ...res.data.list]
  96. this.finished = !res.data.hasNextPage
  97. this.total = res.data.total
  98. } catch (error) {
  99. console.log(error)
  100. } finally {
  101. this.isRequest = false
  102. this.isLoadingMore = false
  103. }
  104. }, 400),
  105. // tab切换
  106. onTabChange(item) {
  107. console.log(item)
  108. this.$router.push(`/ph${item.path}`)
  109. },
  110. // 搜索
  111. onSearch(keyword) {
  112. this.listQuery.videoTitle = keyword
  113. this.listQuery.pageNum = 1
  114. this.fetchList()
  115. },
  116. // 页码变化
  117. onPagiantionChange(index) {
  118. this.listQuery.pageNum = index
  119. this.fetchList()
  120. },
  121. // 加载更多
  122. onLoadMore() {
  123. this.listQuery.pageNum += 1
  124. this.fetchList()
  125. },
  126. },
  127. }
  128. </script>
  129. <style scoped lang="scss">
  130. /* scss中可以用mixin来扩展 */
  131. @mixin ellipsis($line: 1) {
  132. overflow: hidden;
  133. text-overflow: ellipsis;
  134. display: -webkit-box;
  135. -webkit-line-clamp: $line;
  136. -webkit-box-orient: vertical;
  137. }
  138. // pc 端
  139. @media screen and (min-width: 768px) {
  140. .page-top {
  141. height: 360px;
  142. background: url(https://static.caimei365.com/www/authentic/pc/bg-doc.png);
  143. background-size: auto 360px;
  144. .logo {
  145. display: block;
  146. width: 120px;
  147. height: 120px;
  148. border-radius: 50%;
  149. }
  150. .name {
  151. font-size: 30px;
  152. color: #fff;
  153. }
  154. }
  155. .page-content {
  156. width: 1200px;
  157. margin: 0 auto;
  158. background-color: #fff;
  159. .divider {
  160. height: 16px;
  161. background: #f7f7f7;
  162. }
  163. .search {
  164. display: none;
  165. }
  166. }
  167. .list {
  168. border-top: 16px solid #f7f7f7;
  169. border-bottom: 16px solid #f7f7f7;
  170. .section {
  171. padding: 32px 0;
  172. margin: 0 24px;
  173. background: #fff;
  174. border-bottom: 1px solid #d8d8d8;
  175. transition: all 0.4s;
  176. &:last-child {
  177. border-bottom: 0;
  178. }
  179. .info {
  180. width: 880px;
  181. height: 100%;
  182. .name {
  183. height: 56px;
  184. font-size: 18px;
  185. color: #404040;
  186. line-height: 1.6;
  187. margin-bottom: 18px;
  188. @include ellipsis(2);
  189. text-align: justify;
  190. }
  191. .date {
  192. font-size: 18px;
  193. color: #b2b2b2;
  194. line-height: 1.4;
  195. }
  196. .download {
  197. font-size: 16px;
  198. color: #bc1724;
  199. cursor: pointer;
  200. margin-top: 8px;
  201. }
  202. }
  203. .cover {
  204. width: 216px;
  205. height: 132px;
  206. border-bottom: 1px solid #d8d8d8;
  207. }
  208. }
  209. }
  210. }
  211. // 移动 端
  212. @media screen and (max-width: 768px) {
  213. .page-top {
  214. height: 46vw;
  215. background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
  216. background-size: auto 46vw;
  217. .logo {
  218. display: block;
  219. width: 14.8vw;
  220. height: 14.8vw;
  221. border-radius: 50%;
  222. }
  223. .name {
  224. font-size: 4vw;
  225. color: #fff;
  226. }
  227. }
  228. .page-content {
  229. position: relative;
  230. .divider {
  231. border-bottom: 3.2vw solid #f7f7f7;
  232. height: 12.4vw;
  233. }
  234. }
  235. .search {
  236. position: absolute;
  237. left: 50%;
  238. top: 0;
  239. transform: translate(-50%, -50%);
  240. }
  241. .list {
  242. .section {
  243. position: relative;
  244. padding: 2.4vw 0;
  245. margin: 0 4vw;
  246. padding-bottom: 9.8vw;
  247. background: #fff;
  248. border-bottom: 0.1vw solid #d8d8d8;
  249. &:first-child {
  250. border-top: 0.1vw solid #d8d8d8;
  251. }
  252. .info {
  253. .name {
  254. font-size: 3.6vw;
  255. color: #404040;
  256. line-height: 1.5;
  257. margin-bottom: 2.4vw;
  258. @include ellipsis(2);
  259. text-align: justify;
  260. }
  261. .date {
  262. position: absolute;
  263. left: 0;
  264. bottom: 2.4vw;
  265. font-size: 3.2vw;
  266. color: #b2b2b2;
  267. line-height: 1.4;
  268. }
  269. .download {
  270. position: absolute;
  271. right: 0;
  272. bottom: 2.4vw;
  273. font-size: 3.2vw;
  274. color: #bc1724;
  275. cursor: pointer;
  276. margin-top: 1.2vw;
  277. }
  278. }
  279. .cover {
  280. width: 92vw;
  281. height: 56vw;
  282. border-bottom: 0.1vw solid #d8d8d8;
  283. }
  284. }
  285. }
  286. }
  287. </style>