video.vue 6.3 KB

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