file.vue 6.7 KB

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