package.vue 6.4 KB

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