package.vue 6.3 KB

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