|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<view class="news-index">
|
|
|
<nav-bar title="新闻" @init="onInitNavbar"></nav-bar>
|
|
|
- <u-scroll-view :tabbar-conflict="false">
|
|
|
+ <u-scroll-view :tabbar-conflict="false" @scroll-near-lower="onScrollToLower">
|
|
|
<view class="main-container">
|
|
|
<u-tabs :active.sync="tabActive" :tabs="tabs" tab-style="default" @change="tabChange"/>
|
|
|
<van-empty v-if="newsList.length === 0" description="暂无数据" />
|
|
@@ -20,6 +20,7 @@
|
|
|
import UTabs from '@/components/common/u-tabs'
|
|
|
import UScrollView from '@/components/common/u-scroll-view'
|
|
|
import NewsItem from '@/pages/news/components/news-item.vue'
|
|
|
+ import { exhibitorsNewsList, newsList } from '@/api/exhibitor'
|
|
|
|
|
|
export default {
|
|
|
options: {
|
|
@@ -41,18 +42,80 @@
|
|
|
label: '展商新闻',
|
|
|
value: 'exhibitor'
|
|
|
}],
|
|
|
- newsList: [{}, {}, {}, {}, {}, {}]
|
|
|
+ newsList: [],
|
|
|
+ newsParams: {
|
|
|
+ page: 1,
|
|
|
+ page_size: 10,
|
|
|
+ keyword: '',
|
|
|
+ },
|
|
|
+ newsListLoading: false,
|
|
|
+ newsListLastPage: 1,
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
if (options.type) {
|
|
|
this.tabActive = options.type
|
|
|
}
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ created() {
|
|
|
},
|
|
|
- created() {},
|
|
|
methods: {
|
|
|
- tabChange() {
|
|
|
-
|
|
|
+ getList() {
|
|
|
+ if (this.tabActive === 'exhibitor') {
|
|
|
+ this.getExhibitorsNewsList()
|
|
|
+ }
|
|
|
+ if (this.tabActive === 'exhibition') {
|
|
|
+ this.getNewsList()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getNewsList() {
|
|
|
+ this.newsListLoading = true
|
|
|
+ newsList(this.newsParams).then(res => {
|
|
|
+ if (res.data.data) {
|
|
|
+ if (this.newsParams.page > 1) {
|
|
|
+ this.newsList = [...this.newsList, ...res.data.data]
|
|
|
+ } else {
|
|
|
+ this.newsList = res.data.data
|
|
|
+ this.newsListLastPage = res.data.last_page
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.showToast('系统繁忙,稍候再试')
|
|
|
+ }
|
|
|
+ this.newsListLoading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getExhibitorsNewsList() {
|
|
|
+ this.newsListLoading = true
|
|
|
+ exhibitorsNewsList(this.newsParams).then(res => {
|
|
|
+ if (res.data.data) {
|
|
|
+ if (this.newsParams.page > 1) {
|
|
|
+ this.newsList = [...this.newsList, ...res.data.data]
|
|
|
+ } else {
|
|
|
+ this.newsList = res.data.data
|
|
|
+ this.newsListLastPage = res.data.last_page
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.showToast('系统繁忙,稍候再试')
|
|
|
+ }
|
|
|
+ this.newsListLoading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onScrollToLower(e) {
|
|
|
+ if (this.newsListLastPage === this.newsParams.page) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.newsListLoading === true) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.newsListLoading = true
|
|
|
+ this.newsParams.page = this.newsParams.page+1
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ tabChange(e) {
|
|
|
+ this.tabActive = e.detail.value
|
|
|
+ this.newsParams.page = 1
|
|
|
+ this.getList()
|
|
|
}
|
|
|
}
|
|
|
}
|