123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- <template>
- <div class="page">
- <van-list
- v-model="isLoadingMore"
- :finished="finished"
- :immediate-check="false"
- :finished-text="total ? '没有更多了' : ''"
- @load="onLoadMore"
- >
- <div class="page-top flex flex-col justify-center items-center">
- <img class="logo" :src="supplierInfo.logo" />
- <span
- class="name mt-2"
- v-text="supplierInfo.shopName + '资料库'"
- ></span>
- </div>
- <div class="page-content">
- <!-- 搜索区域 -->
- <div class="search">
- <simple-search v-model="listQuery.fileTitle" @search="onSearch" />
- </div>
- <div class="divider"></div>
- <!-- tabbar -->
- <simple-tabs
- :tabs="tabs"
- :current="current"
- @change="onTabChange"
- @search="onSearch"
- ></simple-tabs>
- <div class="list">
- <div
- class="section md:flex md:justify-between md:items-center"
- v-for="item in list"
- :key="item.fileId"
- @click="previewFile(item)"
- >
- <div class="info">
- <div class="name" v-text="item.fileName"></div>
- <div class="date">{{ item.createTime | dateFormat }}</div>
- <div class="download" @click.stop="downloadLink(item)">下载</div>
- </div>
- </div>
- </div>
- <!-- 列表为空 -->
- <SimpleEmpty
- v-if="!total && !isRequest"
- description="敬请期待~"
- ></SimpleEmpty>
- </div>
- </van-list>
- </div>
- </template>
- <script>
- import { mapGetters } from 'vuex'
- import { tabs } from '@/configs/tabs'
- import downloadLink from '@/utils/download-link'
- import { debounce } from '~/utils'
- export default {
- layout: 'app',
- data() {
- return {
- isLoadingMore: true,
- finished: false,
- isRequest: true,
- tabs: tabs(),
- current: 3,
- listQuery: {
- fileType: 1,
- fileTitle: '',
- authUserId: '',
- pageNum: 1,
- pageSize: 4,
- },
- list: [],
- total: 0,
- }
- },
- computed: {
- ...mapGetters(['userInfo', 'supplierInfo']),
- },
- mounted() {
- this.fetchList()
- },
- methods: {
- // 下载方法
- downloadLink(item) {
- const url = `${process.env.BASE_URL}/download/file?ossName=${item.fileDownloadUrl}&fileName=${item.fileName}`
- downloadLink(url)
- },
- // 预览文件
- previewFile(item) {
- window.open(item.filePreviewUrl)
- },
- // 获取列表
- fetchList: debounce(async function () {
- try {
- this.isLoadingMore = true
- this.listQuery.authUserId = this.userInfo.authUserId
- const res = await this.$http.api.getFileList(this.listQuery)
- this.list = [...this.list, ...res.data.list]
- this.finished = !res.data.hasNextPage
- this.total = res.data.total
- } catch (error) {
- console.log(error)
- } finally {
- this.isRequest = false
- this.isLoadingMore = false
- }
- }, 400),
- // tab切换
- onTabChange(item) {
- console.log(item)
- this.$router.push(`/ph${item.path}`)
- },
- // 搜索
- onSearch(keyword) {
- this.listQuery.fileTitle = keyword
- this.listQuery.pageNum = 1
- this.fetchList()
- },
- // 页码变化
- onPagiantionChange(index) {
- this.listQuery.pageNum = index
- this.fetchList()
- },
- // 加载更多
- onLoadMore() {
- this.listQuery.pageNum += 1
- this.fetchList()
- },
- },
- }
- </script>
- <style scoped lang="scss">
- /* scss中可以用mixin来扩展 */
- @mixin ellipsis($line: 1) {
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: $line;
- -webkit-box-orient: vertical;
- }
- // pc 端
- @media screen and (min-width: 768px) {
- .page-top {
- height: 360px;
- background: url(https://static.caimei365.com/www/authentic/pc/bg-doc.png);
- background-size: auto 360px;
- .logo {
- display: block;
- width: 120px;
- height: 120px;
- border-radius: 50%;
- }
- .name {
- font-size: 30px;
- color: #fff;
- }
- }
- .page-content {
- width: 1200px;
- margin: 0 auto;
- background-color: #fff;
- .divider {
- height: 16px;
- background: #f7f7f7;
- }
- .search {
- display: none;
- }
- }
- .list {
- border-top: 16px solid #f7f7f7;
- border-bottom: 16px solid #f7f7f7;
- .section {
- padding: 32px 0;
- margin: 0 24px;
- background: #fff;
- border-bottom: 1px solid #d8d8d8;
- transition: all 0.4s;
- cursor: pointer;
- &:last-child {
- border-bottom: 0;
- }
- &:hover {
- .name {
- color: #bc1724 !important;
- }
- }
- .info {
- width: 100%;
- position: relative;
- .name {
- width: 1050px;
- height: 56px;
- font-size: 18px;
- color: #404040;
- line-height: 1.6;
- margin-bottom: 18px;
- text-align: justify;
- @include ellipsis(2);
- transition: all 0.4s;
- }
- .date {
- font-size: 18px;
- color: #b2b2b2;
- line-height: 1.4;
- }
- .download {
- position: absolute;
- text-align: center;
- right: 0;
- top: 50%;
- transform: translateY(-50%);
- font-size: 16px;
- color: #bc1724;
- cursor: pointer;
- &::before {
- content: '';
- display: block;
- width: 54px;
- height: 59px;
- background: url(https://static.caimei365.com/www/authentic/pc/icon-pdf-download.png)
- no-repeat center;
- background-size: 54px;
- }
- }
- }
- }
- }
- }
- // 移动 端
- @media screen and (max-width: 768px) {
- .page-top {
- height: 46vw;
- background: url(https://static.caimei365.com/www/authentic/h5/bg-club.png);
- background-size: auto 46vw;
- .logo {
- display: block;
- width: 14.8vw;
- height: 14.8vw;
- border-radius: 50%;
- }
- .name {
- font-size: 4vw;
- color: #fff;
- }
- }
- .page-content {
- position: relative;
- .divider {
- border-bottom: 3.2vw solid #f7f7f7;
- height: 12.4vw;
- }
- }
- .search {
- position: absolute;
- left: 50%;
- top: 0;
- transform: translate(-50%, -50%);
- }
- .list {
- .section {
- position: relative;
- padding: 2.4vw 0;
- margin: 0 4vw;
- padding-bottom: 6.8vw;
- background: #fff;
- border-bottom: 0.1vw solid #d8d8d8;
- &:first-child {
- border-top: 0.1vw solid #d8d8d8;
- }
- .info {
- .name {
- font-size: 3.6vw;
- color: #404040;
- line-height: 1.5;
- margin-bottom: 2.4vw;
- text-align: justify;
- @include ellipsis(2);
- }
- .date {
- position: absolute;
- left: 0;
- bottom: 2.4vw;
- font-size: 3.2vw;
- color: #b2b2b2;
- line-height: 1.4;
- }
- .download {
- position: absolute;
- right: 0;
- bottom: 2.4vw;
- font-size: 3.2vw;
- color: #bc1724;
- cursor: pointer;
- margin-top: 1.2vw;
- }
- }
- }
- }
- }
- </style>
|