package.vue 5.8 KB

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