newsInformation.vue 2.8 KB

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