123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- <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.articleTitle"
- @search="onSearch"
- placeholder="搜索文章标题"
- />
- </div>
- <div class="divider"></div>
- <!-- tabbar -->
- <simple-tabs
- :tabs="tabs"
- :current="current"
- @change="onTabChange"
- @search="onSearch"
- ></simple-tabs>
- <div class="list">
- <div
- class="section flex justify-between items-center"
- v-for="item in list"
- :key="item.articleId"
- @click="toDetail(item)"
- >
- <div class="info">
- <div class="name" v-text="item.articleTitle"></div>
- <div class="date">{{ item.createTime | dateFormat }}</div>
- </div>
- <img class="cover" :src="item.articleImage" />
- </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 { debounce } from '~/utils'
- export default {
- layout: 'app-ross',
- data() {
- return {
- isLoadingMore: true,
- finished: false,
- isRequest: true,
- tabs: tabs(),
- current: 0,
- listQuery: {
- articleTitle: '',
- authUserId: '102',
- pageNum: 1,
- pageSize: 10,
- },
- list: [],
- total: 0,
- }
- },
- computed: {
- ...mapGetters(['supplierInfo', 'authUserId', 'routePrefix']),
- },
- mounted() {
- this.fetchList()
- },
- methods: {
- fetchList: debounce(async function () {
- try {
- this.isLoadingMore = true
- this.listQuery.authUserId = this.authUserId
- const res = await this.$http.api.getArticleList(this.listQuery)
- this.list = [...this.list, ...res.data.list]
- this.finished = !res.data.hasNextPage
- this.total = res.data.total
- this.isLoadingMore = false
- this.listQuery.pageNum += 1
- } catch (error) {
- console.log(error)
- } finally {
- this.isRequest = false
- }
- }, 400),
- // 详情
- toDetail(item) {
- const url = `${this.routePrefix}/database/article-detail?id=${item.articleId}`
- this.$router.push(url)
- },
- // tab切换
- onTabChange(item) {
- this.$router.push(`${this.routePrefix}${item.path}`)
- },
- // 搜索
- onSearch(keyword) {
- this.list = []
- this.listQuery.articleTitle = keyword
- this.listQuery.pageNum = 1
- this.fetchList()
- },
- // 页码变化
- onPagiantionChange(index) {
- this.listQuery.pageNum = index
- this.fetchList()
- },
- // 加载更多
- onLoadMore() {
- 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;
- @include themify($themes) {
- background: themed('pc-banner-doc');
- }
- background-size: auto 360px;
- .logo {
- display: block;
- width: 120px;
- height: 120px;
- border-radius: 50%;
- background: #fff;
- }
- .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;
- &:hover {
- .name {
- @include themify($themes) {
- color: themed('color') !important;
- }
- }
- }
- &:last-child {
- border-bottom: 0;
- }
- .info {
- width: 1000px;
- height: 100%;
- .name {
- font-size: 18px;
- color: #404040;
- line-height: 1.6;
- margin-bottom: 18px;
- text-align: justify;
- @include ellipsis(2);
- }
- .date {
- font-size: 18px;
- color: #b2b2b2;
- line-height: 1.4;
- }
- }
- .cover {
- width: 106px;
- height: 106px;
- border-bottom: 1px solid #d8d8d8;
- }
- }
- }
- }
- // 移动 端
- @media screen and (max-width: 768px) {
- .page-top {
- height: 46vw;
- @include themify($themes) {
- background: themed('h5-banner-doc');
- }
- background-size: auto 46vw;
- .logo {
- display: block;
- width: 14.8vw;
- height: 14.8vw;
- border-radius: 50%;
- background: #fff;
- }
- .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 {
- padding: 2.4vw 0;
- margin: 0 4vw;
- background: #fff;
- border-bottom: 0.1vw solid #d8d8d8;
- &:first-child {
- border-top: 0.1vw solid #d8d8d8;
- }
- .info {
- width: 67.3vw;
- height: 100%;
- .name {
- font-size: 3.6vw;
- color: #404040;
- line-height: 1.5;
- text-align: justify;
- margin-bottom: 2.4vw;
- @include ellipsis(2);
- }
- .date {
- font-size: 3.2vw;
- color: #b2b2b2;
- line-height: 1.4;
- }
- }
- .cover {
- width: 18vw;
- height: 18vw;
- border-bottom: 0.1vw solid #d8d8d8;
- }
- }
- }
- }
- </style>
|