package.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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.list = []
  118. this.listQuery.fileTitle = keyword
  119. this.listQuery.pageNum = 1
  120. this.fetchList()
  121. },
  122. // 页码变化
  123. onPagiantionChange(index) {
  124. this.listQuery.pageNum = index
  125. this.fetchList()
  126. },
  127. // 加载更多
  128. onLoadMore() {
  129. this.fetchList()
  130. },
  131. },
  132. }
  133. </script>
  134. <style scoped lang="scss">
  135. /* scss中可以用mixin来扩展 */
  136. @mixin ellipsis($line: 1) {
  137. overflow: hidden;
  138. text-overflow: ellipsis;
  139. display: -webkit-box;
  140. -webkit-line-clamp: $line;
  141. -webkit-box-orient: vertical;
  142. }
  143. // pc 端
  144. @media screen and (min-width: 768px) {
  145. .page-top {
  146. height: 360px;
  147. background: url(https://static.caimei365.com/www/authentic/pc/bg-doc.png);
  148. background-size: auto 360px;
  149. .logo {
  150. display: block;
  151. width: 120px;
  152. height: 120px;
  153. border-radius: 50%;
  154. background: #fff;
  155. }
  156. .name {
  157. font-size: 30px;
  158. color: #fff;
  159. }
  160. }
  161. .page-content {
  162. width: 1200px;
  163. margin: 0 auto;
  164. background-color: #fff;
  165. .divider {
  166. height: 16px;
  167. background: #f7f7f7;
  168. }
  169. .search {
  170. display: none;
  171. }
  172. }
  173. .list {
  174. border-top: 16px solid #f7f7f7;
  175. border-bottom: 16px solid #f7f7f7;
  176. .section {
  177. padding: 32px 0;
  178. margin: 0 24px;
  179. background: #fff;
  180. border-bottom: 1px solid #d8d8d8;
  181. transition: all 0.4s;
  182. &:last-child {
  183. border-bottom: 0;
  184. }
  185. .info {
  186. width: 100%;
  187. position: relative;
  188. .name {
  189. width: 1050px;
  190. font-size: 18px;
  191. color: #404040;
  192. line-height: 1.6;
  193. text-align: justify;
  194. @include ellipsis(2);
  195. }
  196. .download {
  197. position: absolute;
  198. right: 0;
  199. top: 50%;
  200. transform: translateY(-50%);
  201. font-size: 16px;
  202. @include themify($themes) {
  203. color: themed('color');
  204. }
  205. cursor: pointer;
  206. &::after {
  207. content: '>';
  208. margin-left: 8px;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. // 移动 端
  216. @media screen and (max-width: 768px) {
  217. .page-top {
  218. height: 46vw;
  219. background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
  220. background-size: auto 46vw;
  221. .logo {
  222. display: block;
  223. width: 14.8vw;
  224. height: 14.8vw;
  225. border-radius: 50%;
  226. background: #fff;
  227. }
  228. .name {
  229. font-size: 4vw;
  230. color: #fff;
  231. }
  232. }
  233. .page-content {
  234. position: relative;
  235. .divider {
  236. border-bottom: 3.2vw solid #f7f7f7;
  237. height: 12.4vw;
  238. }
  239. }
  240. .search {
  241. position: absolute;
  242. left: 50%;
  243. top: 0;
  244. transform: translate(-50%, -50%);
  245. }
  246. .list {
  247. .section {
  248. position: relative;
  249. padding: 4.8vw 0;
  250. margin: 0 4vw;
  251. background: #fff;
  252. border-bottom: 0.1vw solid #d8d8d8;
  253. &:first-child {
  254. border-top: 0.1vw solid #d8d8d8;
  255. }
  256. .info {
  257. .name {
  258. width: 66vw;
  259. font-size: 3.6vw;
  260. color: #404040;
  261. line-height: 1.5;
  262. text-align: justify;
  263. @include ellipsis(2);
  264. }
  265. .download {
  266. position: absolute;
  267. right: 0;
  268. bottom: 50%;
  269. transform: translateY(50%);
  270. font-size: 3.2vw;
  271. @include themify($themes) {
  272. color: themed('color');
  273. }
  274. cursor: pointer;
  275. &::after {
  276. content: '>';
  277. margin-left: 8px;
  278. }
  279. }
  280. }
  281. }
  282. }
  283. }
  284. </style>