package.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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: 4,
  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. }
  154. .name {
  155. font-size: 30px;
  156. color: #fff;
  157. }
  158. }
  159. .page-content {
  160. width: 1200px;
  161. margin: 0 auto;
  162. background-color: #fff;
  163. .divider {
  164. height: 16px;
  165. background: #f7f7f7;
  166. }
  167. .search {
  168. display: none;
  169. }
  170. }
  171. .list {
  172. border-top: 16px solid #f7f7f7;
  173. border-bottom: 16px solid #f7f7f7;
  174. .section {
  175. padding: 32px 0;
  176. margin: 0 24px;
  177. background: #fff;
  178. border-bottom: 1px solid #d8d8d8;
  179. transition: all 0.4s;
  180. &:last-child {
  181. border-bottom: 0;
  182. }
  183. .info {
  184. width: 100%;
  185. position: relative;
  186. .name {
  187. width: 1050px;
  188. font-size: 18px;
  189. color: #404040;
  190. line-height: 1.6;
  191. text-align: justify;
  192. @include ellipsis(2);
  193. }
  194. .download {
  195. position: absolute;
  196. right: 0;
  197. top: 50%;
  198. transform: translateY(-50%);
  199. font-size: 16px;
  200. color: #bc1724;
  201. cursor: pointer;
  202. &::after {
  203. content: '>';
  204. margin-left: 8px;
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. // 移动 端
  212. @media screen and (max-width: 768px) {
  213. .page-top {
  214. height: 46vw;
  215. background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
  216. background-size: auto 46vw;
  217. .logo {
  218. display: block;
  219. width: 14.8vw;
  220. height: 14.8vw;
  221. border-radius: 50%;
  222. }
  223. .name {
  224. font-size: 4vw;
  225. color: #fff;
  226. }
  227. }
  228. .page-content {
  229. position: relative;
  230. .divider {
  231. border-bottom: 3.2vw solid #f7f7f7;
  232. height: 12.4vw;
  233. }
  234. }
  235. .search {
  236. position: absolute;
  237. left: 50%;
  238. top: 0;
  239. transform: translate(-50%, -50%);
  240. }
  241. .list {
  242. .section {
  243. position: relative;
  244. padding: 4.8vw 0;
  245. margin: 0 4vw;
  246. background: #fff;
  247. border-bottom: 0.1vw solid #d8d8d8;
  248. &:first-child {
  249. border-top: 0.1vw solid #d8d8d8;
  250. }
  251. .info {
  252. .name {
  253. width: 66vw;
  254. font-size: 3.6vw;
  255. color: #404040;
  256. line-height: 1.5;
  257. text-align: justify;
  258. @include ellipsis(2);
  259. }
  260. .download {
  261. position: absolute;
  262. right: 0;
  263. bottom: 50%;
  264. transform: translateY(50%);
  265. font-size: 3.2vw;
  266. color: #bc1724;
  267. cursor: pointer;
  268. &::after {
  269. content: '>';
  270. margin-left: 8px;
  271. }
  272. }
  273. }
  274. }
  275. }
  276. }
  277. </style>