file.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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.fileTitle" @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.fileId"
  35. @click="previewFile(item)"
  36. >
  37. <div class="info">
  38. <div class="name" v-text="item.fileName"></div>
  39. <div class="date">{{ item.createTime | dateFormat }}</div>
  40. <div class="download" @click.stop="downloadLink(item)">下载</div>
  41. </div>
  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: 3,
  67. listQuery: {
  68. fileType: 1,
  69. fileTitle: '',
  70. authUserId: '',
  71. pageNum: 1,
  72. pageSize: 4,
  73. },
  74. list: [],
  75. total: 0,
  76. }
  77. },
  78. computed: {
  79. ...mapGetters(['userInfo', 'supplierInfo']),
  80. },
  81. mounted() {
  82. this.fetchList()
  83. },
  84. methods: {
  85. // 下载方法
  86. downloadLink(item) {
  87. const url = `${process.env.BASE_URL}/download/file?ossName=${item.fileDownloadUrl}&fileName=${item.fileName}`
  88. downloadLink(url)
  89. },
  90. // 预览文件
  91. previewFile(item) {
  92. window.open(item.filePreviewUrl)
  93. },
  94. // 获取列表
  95. fetchList: debounce(async function () {
  96. try {
  97. this.isLoadingMore = true
  98. this.listQuery.authUserId = this.userInfo.authUserId
  99. const res = await this.$http.api.getFileList(this.listQuery)
  100. this.list = [...this.list, ...res.data.list]
  101. this.finished = !res.data.hasNextPage
  102. this.total = res.data.total
  103. } catch (error) {
  104. console.log(error)
  105. } finally {
  106. this.isRequest = false
  107. this.isLoadingMore = false
  108. }
  109. }, 400),
  110. // tab切换
  111. onTabChange(item) {
  112. console.log(item)
  113. this.$router.push(`/ph${item.path}`)
  114. },
  115. // 搜索
  116. onSearch(keyword) {
  117. this.listQuery.fileTitle = keyword
  118. this.listQuery.pageNum = 1
  119. this.fetchList()
  120. },
  121. // 页码变化
  122. onPagiantionChange(index) {
  123. this.listQuery.pageNum = index
  124. this.fetchList()
  125. },
  126. // 加载更多
  127. onLoadMore() {
  128. this.listQuery.pageNum += 1
  129. this.fetchList()
  130. },
  131. },
  132. }
  133. </script>
  134. <style scoped lang="scss">
  135. /* scss中可以用mixin来扩展 */
  136. @mixin ellipsis($line: 1) {
  137. overflow: hidden;
  138. text-overflow: ellipsis;
  139. display: -webkit-box;
  140. -webkit-line-clamp: $line;
  141. -webkit-box-orient: vertical;
  142. }
  143. // pc 端
  144. @media screen and (min-width: 768px) {
  145. .page-top {
  146. height: 360px;
  147. background: url(https://static.caimei365.com/www/authentic/pc/bg-doc.png);
  148. background-size: auto 360px;
  149. .logo {
  150. display: block;
  151. width: 120px;
  152. height: 120px;
  153. border-radius: 50%;
  154. }
  155. .name {
  156. font-size: 30px;
  157. color: #fff;
  158. }
  159. }
  160. .page-content {
  161. width: 1200px;
  162. margin: 0 auto;
  163. background-color: #fff;
  164. .divider {
  165. height: 16px;
  166. background: #f7f7f7;
  167. }
  168. .search {
  169. display: none;
  170. }
  171. }
  172. .list {
  173. border-top: 16px solid #f7f7f7;
  174. border-bottom: 16px solid #f7f7f7;
  175. .section {
  176. padding: 32px 0;
  177. margin: 0 24px;
  178. background: #fff;
  179. border-bottom: 1px solid #d8d8d8;
  180. transition: all 0.4s;
  181. cursor: pointer;
  182. &:last-child {
  183. border-bottom: 0;
  184. }
  185. &:hover {
  186. .name {
  187. color: #bc1724 !important;
  188. }
  189. }
  190. .info {
  191. width: 100%;
  192. position: relative;
  193. .name {
  194. width: 1050px;
  195. height: 56px;
  196. font-size: 18px;
  197. color: #404040;
  198. line-height: 1.6;
  199. margin-bottom: 18px;
  200. text-align: justify;
  201. @include ellipsis(2);
  202. transition: all 0.4s;
  203. }
  204. .date {
  205. font-size: 18px;
  206. color: #b2b2b2;
  207. line-height: 1.4;
  208. }
  209. .download {
  210. position: absolute;
  211. text-align: center;
  212. right: 0;
  213. top: 50%;
  214. transform: translateY(-50%);
  215. font-size: 16px;
  216. color: #bc1724;
  217. cursor: pointer;
  218. &::before {
  219. content: '';
  220. display: block;
  221. width: 54px;
  222. height: 59px;
  223. background: url(https://static.caimei365.com/www/authentic/pc/icon-pdf-download.png)
  224. no-repeat center;
  225. background-size: 54px;
  226. }
  227. }
  228. }
  229. }
  230. }
  231. }
  232. // 移动 端
  233. @media screen and (max-width: 768px) {
  234. .page-top {
  235. height: 46vw;
  236. background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
  237. background-size: auto 46vw;
  238. .logo {
  239. display: block;
  240. width: 14.8vw;
  241. height: 14.8vw;
  242. border-radius: 50%;
  243. }
  244. .name {
  245. font-size: 4vw;
  246. color: #fff;
  247. }
  248. }
  249. .page-content {
  250. position: relative;
  251. .divider {
  252. border-bottom: 3.2vw solid #f7f7f7;
  253. height: 12.4vw;
  254. }
  255. }
  256. .search {
  257. position: absolute;
  258. left: 50%;
  259. top: 0;
  260. transform: translate(-50%, -50%);
  261. }
  262. .list {
  263. .section {
  264. position: relative;
  265. padding: 2.4vw 0;
  266. margin: 0 4vw;
  267. padding-bottom: 6.8vw;
  268. background: #fff;
  269. border-bottom: 0.1vw solid #d8d8d8;
  270. &:first-child {
  271. border-top: 0.1vw solid #d8d8d8;
  272. }
  273. .info {
  274. .name {
  275. font-size: 3.6vw;
  276. color: #404040;
  277. line-height: 1.5;
  278. margin-bottom: 2.4vw;
  279. text-align: justify;
  280. @include ellipsis(2);
  281. }
  282. .date {
  283. position: absolute;
  284. left: 0;
  285. bottom: 2.4vw;
  286. font-size: 3.2vw;
  287. color: #b2b2b2;
  288. line-height: 1.4;
  289. }
  290. .download {
  291. position: absolute;
  292. right: 0;
  293. bottom: 2.4vw;
  294. font-size: 3.2vw;
  295. color: #bc1724;
  296. cursor: pointer;
  297. margin-top: 1.2vw;
  298. }
  299. }
  300. }
  301. }
  302. }
  303. </style>