index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view class="app-container">
  3. <navbar :config="config" backColor="#666"></navbar>
  4. <view class="topview" :style="{top:tabTop+'px'}">
  5. <u-tabs :list="list" :is-scroll="true" name="informationTypeName" active-color="#3CBACF"
  6. inactive-color="#999999" :current="current" @change="change"></u-tabs>
  7. </view>
  8. <view class="news-box" v-if="newsList.length > 0">
  9. <block v-for="(item, index) in newsList" :key="item.informationId">
  10. <template v-if="activeTypeName === '宜昌发布'">
  11. <view class="news-item" @click="openYiChangNewsDetail(item)">
  12. <view class="news-info">
  13. <view class="news-title">{{item.title}}</view>
  14. <view class="info-footer">
  15. <text class="news-time">{{item.published}}</text>
  16. <text>{{item.author}}</text>
  17. </view>
  18. </view>
  19. <view class="news-img lazy-img">
  20. <u-image class="service-img" :src="item.coverImgUrl" mode="aspectFill"
  21. :lazy-load="true"></u-image>
  22. </view>
  23. </view>
  24. </template>
  25. <template v-else>
  26. <view class="news-item" @click="toNewsDetail(item)">
  27. <view class="news-info">
  28. <view class="news-title">{{item.informationTitle}}</view>
  29. <view class="info-footer">
  30. <text class="news-time">{{item.createTime}}</text>
  31. <text>{{item.informationTypeName}}</text>
  32. </view>
  33. </view>
  34. <view class="news-img lazy-img">
  35. <u-image class="service-img" :src="$getImgPath(item.informationThumbnail)" mode="aspectFill"
  36. :lazy-load="true"></u-image>
  37. </view>
  38. </view>
  39. </template>
  40. </block>
  41. </view>
  42. <view v-else-if="status !== 'loading'" class="empty-box">
  43. <EmptyDate :top="200" />
  44. </view>
  45. <loadMore v-if="newsList.length > 0 || status === 'loading'" :status="status"></loadMore>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. newsClassify,
  51. newsList
  52. } from '@/api/government.js';
  53. import {
  54. getYiChangNews,
  55. openYiChangNews
  56. } from "../government/conmon.js"
  57. var app = getApp()
  58. export default {
  59. data() {
  60. return {
  61. config: {
  62. back: true,
  63. title: '资讯',
  64. color: '#1a1a1a',
  65. backgroundColor: [1, '#fff'],
  66. },
  67. list: [],
  68. current: 0,
  69. newsList: [],
  70. pageSize: 10,
  71. pageNum: 1,
  72. informationTypeId: null,
  73. activeTypeName: null,
  74. tabTop: 0,
  75. status: 'more', //more|loading|noMore
  76. noData: false,
  77. }
  78. },
  79. onLoad() {
  80. this.tabTop = uni.getSystemInfoSync().statusBarHeight + 44;
  81. this.getNewsClassify()
  82. },
  83. onReachBottom() {
  84. if (this.status == 'more') {
  85. this.pageNum++
  86. this.getNewsList(false)
  87. }
  88. },
  89. onPullDownRefresh() {
  90. this.pageNum = 1
  91. this.current = 0
  92. this.getNewsClassify()
  93. setTimeout(() => {
  94. uni.stopPullDownRefresh()
  95. }, 500)
  96. },
  97. methods: {
  98. change(index) {
  99. if (this.current == index) {
  100. return false
  101. }
  102. this.current = index;
  103. this.informationTypeId = this.list[index].informationTypeId
  104. this.$nextTick(() => {
  105. this.getNewsList()
  106. })
  107. },
  108. getNewsClassify() {
  109. newsClassify({
  110. informationChannel: this.$keys.information_home
  111. }).then(res => {
  112. if (res && res.code == 200) {
  113. this.list = res.data
  114. this.informationTypeId = res.data[0].informationTypeId
  115. this.$nextTick(() => {
  116. this.getNewsList()
  117. })
  118. }
  119. })
  120. },
  121. openYiChangNewsDetail(row) {
  122. openYiChangNews(row)
  123. },
  124. getNewsList(refresh = true) {
  125. if (refresh) this.pageNum = 1
  126. this.status = 'loading';
  127. const item = this.list.find(el => el.informationTypeId === this.informationTypeId)
  128. this.activeTypeName = item.informationTypeName;
  129. if (item.informationTypeName === "宜昌发布") {
  130. getYiChangNews(this.pageSize, this.pageNum, true).then(res => {
  131. this.newsList = refresh ? res.data : this.newsList.concat(res.data)
  132. this.total = res.total;
  133. this.pageNum = res.pageNum;
  134. this.status = this.$mUtil.pagination(res.total, this.pageNum, this.pageSize)
  135. })
  136. } else {
  137. newsList({
  138. pageSize: this.pageSize,
  139. pageNum: this.pageNum,
  140. informationTypeId: this.informationTypeId
  141. }).then(res => {
  142. if (res && res.code == 200) {
  143. this.newsList = refresh ? res.rows : this.newsList.concat(res.rows)
  144. this.total = res.total
  145. this.status = this.$mUtil.pagination(res.total, this.pageNum, this.pageSize)
  146. }
  147. })
  148. }
  149. },
  150. toNewsDetail(item) {
  151. uni.navigateTo({
  152. url: '/pages/news/news_detail?informationId=' + item.informationId
  153. })
  154. }
  155. }
  156. }
  157. </script>
  158. <style>
  159. page {
  160. background: #f9f9f9;
  161. }
  162. </style>
  163. <style lang="scss" scoped>
  164. .topview {
  165. background-color: #fff;
  166. height: 110rpx;
  167. width: 100%;
  168. position: fixed;
  169. left: 0;
  170. box-sizing: border-box;
  171. padding: 0 30rpx;
  172. z-index: 66;
  173. }
  174. .news-box {
  175. margin: 0 30rpx;
  176. padding: 0 30rpx;
  177. margin-top: 130rpx;
  178. background-color: #fff;
  179. border-radius: 20rpx;
  180. .news-item {
  181. display: flex;
  182. justify-content: space-between;
  183. padding: 20rpx 0;
  184. // border-bottom: 1rpx solid #ededed;
  185. &:last-child {
  186. border-bottom: none;
  187. }
  188. .news-img {
  189. width: 245rpx;
  190. height: 181rpx;
  191. flex-shrink: 0;
  192. vertical-align: middle;
  193. border-radius: 10rpx;
  194. }
  195. .news-info {
  196. margin-right: 20rpx;
  197. .news-title {
  198. height: 120rpx;
  199. font-size: 30rpx;
  200. color: #333333;
  201. margin-bottom: 20rpx;
  202. font-weight: bold;
  203. overflow: hidden;
  204. text-overflow: ellipsis;
  205. display: -webkit-box;
  206. -webkit-box-orient: vertical;
  207. -webkit-line-clamp: 3;
  208. }
  209. .info-footer {
  210. color: #999999;
  211. font-size: 26rpx;
  212. .news-time {
  213. margin-right: 20rpx;
  214. }
  215. }
  216. }
  217. }
  218. }
  219. </style>