newsInformation.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!-- 新闻动态 -->
  2. <template>
  3. <view class="news">
  4. <z-paging ref="paging" v-model="newsList" @query="queryList">
  5. <view class="news-list">
  6. <view class="news-list-item" v-for="(item, index) in newsList" :key="index"
  7. @click="jumpPage('/pages/newsDetails/newsDetails', { artId: item.artId })">
  8. <view class="news-list-item-left">
  9. <u-image :src="item.artImage" width="128" height="120" border-radius="10"/>
  10. </view>
  11. <view class="news-list-item-right">
  12. <view class="title">{{ item.artTitle }}</view>
  13. <view class="date">
  14. <view>来源:{{ item.artAuthor }}</view>
  15. <view>{{ item.artPostTime }}</view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </z-paging>
  21. <u-toast ref="uToast" />
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. // 新闻列表
  29. newsList: []
  30. }
  31. },
  32. methods: {
  33. /**
  34. * 获取新闻列表
  35. */
  36. getList(pageNum, pageSize) {
  37. this.$u.api.indexApi.getIndexNewsListApi({
  38. pageNum: pageNum,
  39. pageSize: pageSize,
  40. artCategoryId: 2
  41. }).then(res => {
  42. if (res.code === 200) {
  43. this.$refs.paging.complete(res.rows)
  44. } else {
  45. this.$refs.uToast.show({
  46. title: err.msg,
  47. type: 'error'
  48. })
  49. this.$refs.paging.complete([])
  50. }
  51. }).catch((err) => {
  52. this.$refs.uToast.show({
  53. title: '系统异常!',
  54. type: 'error'
  55. })
  56. this.$refs.paging.complete([])
  57. })
  58. },
  59. /**
  60. * @param { Number } pageNo
  61. * @param { Number } pageSize
  62. */
  63. queryList(pageNo, pageSize) {
  64. this.getList(pageNo, pageSize);
  65. },
  66. /**
  67. * 跳转到指定页面
  68. */
  69. jumpPage(url, params) {
  70. this.$u.route({
  71. url: url,
  72. params: params
  73. })
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .news {
  80. background-color: #f2f2f2;
  81. min-height: calc(100vh - 44px);
  82. &-list {
  83. padding: 28rpx 30rpx;
  84. &-item {
  85. display: flex;
  86. align-items: center;
  87. background-color: #fff;
  88. padding: 34rpx 32rpx;
  89. margin-bottom: 20rpx;
  90. &-left {
  91. margin-right: 16rpx;
  92. image {
  93. width: 132rpx;
  94. height: 106rpx;
  95. }
  96. }
  97. &-right {
  98. .title {
  99. color: #000;
  100. font-size: 30rpx;
  101. }
  102. .date {
  103. margin-top: 12rpx;
  104. color: #6F6F6F;
  105. font-size: 24rpx;
  106. display: flex;
  107. justify-content: space-between;
  108. view {
  109. width: 50%;
  110. }
  111. }
  112. }
  113. }
  114. }
  115. }
  116. </style>