index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <page-layout class="news-index">
  3. <nav-bar title="新闻" @init="onInitNavbar"></nav-bar>
  4. <u-scroll-view :tabbar-conflict="false" @scroll-near-lower="onScrollToLower">
  5. <view class="main-container">
  6. <u-tabs :active.sync="tabActive" :tabs="tabs" tab-style="default" @change="tabChange"/>
  7. <van-empty v-if="newsList.length === 0" description="暂无数据" />
  8. <view v-else class="news-list">
  9. <template v-for="(item, index) in newsList">
  10. <news-item :item="item" :key="index" :type="tabActive" />
  11. </template>
  12. </view>
  13. <disclaimer-text></disclaimer-text>
  14. </view>
  15. </u-scroll-view>
  16. <contact-us :show.sync="showContactUs" :qrcode_url="q_url" />
  17. <float-button @custom-event="updateContactStatus()"></float-button>
  18. <van-dialog id="van-dialog" />
  19. </page-layout>
  20. </template>
  21. <script>
  22. import NavBar from '@/components/layout/nav-bar'
  23. import UTabs from '@/components/common/u-tabs'
  24. import UScrollView from '@/components/common/u-scroll-view'
  25. import NewsItem from '@/pages/news/components/news-item.vue'
  26. import { exhibitorsNewsList, newsList } from '@/api/exhibitor'
  27. import DisclaimerText from '@/components/disclaimer-text/index.vue'
  28. import floatButton from "@/components/layout/float-button"
  29. import ContactUs from '@/pages/index/components/contact-us.vue'
  30. import PageLayout from "@/components/layout/page-layout";
  31. export default {
  32. options: {
  33. styleIsolation: 'shared'
  34. },
  35. components: {
  36. PageLayout,
  37. NavBar,
  38. UTabs,
  39. UScrollView,
  40. NewsItem,
  41. DisclaimerText,
  42. floatButton,
  43. ContactUs
  44. },
  45. data() {
  46. return {
  47. tabActive: 'exhibition',
  48. tabs: [{
  49. label: '展会新闻',
  50. value: 'exhibition'
  51. }, {
  52. label: '展商新闻',
  53. value: 'exhibitor'
  54. }],
  55. newsList: [],
  56. newsParams: {
  57. page: 1,
  58. page_size: 10,
  59. keyword: '',
  60. },
  61. newsListLoading: false,
  62. newsListLastPage: 1,
  63. showContactUs: false,
  64. q_url: ''
  65. }
  66. },
  67. onLoad(options) {
  68. if (options.type) {
  69. this.tabActive = options.type
  70. }
  71. },
  72. mounted() {
  73. this.getNewsList()
  74. },
  75. methods: {
  76. getList() {
  77. if (this.tabActive === 'exhibitor') {
  78. this.getExhibitorsNewsList()
  79. }
  80. if (this.tabActive === 'exhibition') {
  81. this.getNewsList()
  82. }
  83. },
  84. getNewsList() {
  85. this.newsListLoading = true
  86. newsList(this.newsParams).then(res => {
  87. if (res.data.data) {
  88. if (this.newsParams.page > 1) {
  89. this.newsList = [...this.newsList, ...res.data.data]
  90. } else {
  91. this.newsList = res.data.data
  92. this.newsListLastPage = res.data.last_page
  93. }
  94. } else {
  95. this.showToast('系统繁忙,稍候再试')
  96. }
  97. this.newsListLoading = false
  98. })
  99. },
  100. getExhibitorsNewsList() {
  101. this.newsListLoading = true
  102. exhibitorsNewsList(this.newsParams).then(res => {
  103. if (res.data.data) {
  104. if (this.newsParams.page > 1) {
  105. this.newsList = [...this.newsList, ...res.data.data]
  106. } else {
  107. this.newsList = res.data.data
  108. this.newsListLastPage = res.data.last_page
  109. }
  110. } else {
  111. this.showToast('系统繁忙,稍候再试')
  112. }
  113. this.newsListLoading = false
  114. })
  115. },
  116. onScrollToLower(e) {
  117. if (this.newsListLastPage === this.newsParams.page) {
  118. return
  119. }
  120. if (this.newsListLoading === true) {
  121. return
  122. }
  123. this.newsListLoading = true
  124. this.newsParams.page = this.newsParams.page+1
  125. this.getList()
  126. },
  127. tabChange(e) {
  128. this.tabActive = e.detail.value
  129. this.newsParams.page = 1
  130. this.getList()
  131. },
  132. updateContactStatus(data) {
  133. this.showContactUs = data.showContactUs
  134. this.q_url = data.q_url
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss">
  140. .news-list{
  141. display: grid;
  142. grid-template-columns: 1fr;
  143. grid-row-gap: 18rpx;
  144. margin-top: 28rpx;
  145. }
  146. </style>