1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <template>
- <view class="news-recommend">
- <view v-if="recommendType === 'home'" class="news-tab">
- <u-tabs :active.sync="newsType" :tabs="tabs" tab-style="default" @change="tabChange"/>
- </view>
- <view class="news-list">
- <template v-for="(item, index) in newsList">
- <news-item :item="item" :key="index" :type="newsType" />
- </template>
- </view>
- </view>
- </template>
- <script>
- import UTabs from '@/components/common/u-tabs'
- import NewsItem from '@/pages/news/components/news-item.vue'
- import { exhibitorsNewsList } from '@/api/exhibitor'
-
- export default {
- components: {
- UTabs,
- NewsItem
- },
- props: {
-
- exhibitorId: Number,
- recommendType: {
- type: String,
- default: 'home'
- }
- },
- watch: {
- exhibitorId(val) {
- this.newsListParams.exhibitors_id = val
- this.getNewsList()
- }
- },
- data() {
- return {
- newsType: 'exhibition',
- tabs: [{
- label: '展会新闻',
- value: 'exhibition'
- }, {
- label: '展商新闻',
- value: 'exhibitor'
- }],
- newsList: [],
- newsListParams: {
- page: 1,
- page_size: 4,
- exhibitors_id: 0
- },
- newsListLoading: false
- }
- },
- created() {
- if (this.recommendType === 'detail') {
- this.newsType = 'exhibitor'
- }
- },
- methods: {
- getNewsList() {
- if (this.newsListLoading === true) {
- return
- }
- this.newsListLoading = true
- exhibitorsNewsList(this.newsListParams).then(res => {
- if (res.code === 0) {
- if (this.newsListParams.page > 1) {
- this.newsList = [...this.newsList, ...res.data.data]
- } else {
- this.newsList = res.data.data
- }
- }
- this.newsListLoading = false
- })
- },
- tabChange() {
-
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .news-list{
- display: grid;
- grid-template-columns: 1fr;
- grid-row-gap: 18rpx;
- margin-top: 28rpx;
- }
- </style>
|