news.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="news">
  3. <view class="first-box u-flex u-row-between u-col-top">
  4. <view class="first-item" v-for="(item,index) in list" v-if="index < 2" :key="index" @click="toinfo(item)">
  5. <image :src="item.logo" class="image" mode=""></image>
  6. <view class="name u-line-2">
  7. {{item.title}}
  8. </view>
  9. <view class="user u-flex">
  10. <image :src="item.head_image" class="head" mode=""></image>
  11. <text class="user-name">{{item.source}}</text>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="news-item u-flex u-row-between" v-for="(item,index) in list" v-if="index >= 2" :key="index" @click="toinfo(item)">
  16. <image :src="item.logo" class="image" mode=""></image>
  17. <view class="item-right">
  18. <view class="name u-line-2">
  19. {{item.title}}
  20. </view>
  21. <view class="u-flex u-row-between">
  22. <view class="time u-flex">
  23. <u-icon name="eye-fill" color="#CCCCCC" size="26"></u-icon>
  24. <text class="look">{{item.page_view}}人浏览</text>
  25. <text class="time-text">{{item.create_at}}</text>
  26. </view>
  27. <view class="user u-flex">
  28. <image :src="item.head_image" class="head" mode=""></image>
  29. <text class="user-name">{{item.source}}</text>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import { mapState } from "vuex"
  38. export default {
  39. data() {
  40. return {
  41. page: 1,
  42. list: [],
  43. title: ''
  44. }
  45. },
  46. computed: {
  47. ...mapState(['defaultcity'])
  48. },
  49. onLoad(option) {
  50. this.title = option.title
  51. this.getlist()
  52. },
  53. onShow() {
  54. if (this.title) {
  55. uni.setNavigationBarTitle({
  56. title: this.title
  57. })
  58. }
  59. },
  60. onReachBottom() {
  61. if (this.list.length % 20 == 0) {
  62. this.page++
  63. this.getlist()
  64. }
  65. },
  66. methods: {
  67. getlist() {
  68. this.$u.post('/api/Headline/headline_list', {
  69. page: this.page,
  70. page_num: 20,
  71. city_id: this.defaultcity.city_id
  72. }).then(res => {
  73. this.list = this.list.concat(res.data || [])
  74. })
  75. },
  76. toinfo(item) {
  77. uni.navigateTo({
  78. url: "./news-info?id=" + item.id
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss">
  85. .news {
  86. padding: 0 44rpx;
  87. .news-item {
  88. padding: 32rpx 0;
  89. border-bottom: 2rpx solid #CCCCCC;
  90. .image {
  91. width: 140rpx;
  92. height: 110rpx;
  93. border-radius: 10rpx;
  94. }
  95. .item-right {
  96. flex: 1;
  97. margin-left: 14rpx;
  98. .name {
  99. font-size: 24rpx;
  100. font-family: PingFangSC-Regular, PingFang SC;
  101. font-weight: 400;
  102. color: #333333;
  103. margin-bottom: 16rpx;
  104. }
  105. .user {
  106. .user-name {
  107. font-size: 18rpx;
  108. font-family: PingFangSC-Regular, PingFang SC;
  109. font-weight: 400;
  110. color: #999999;
  111. }
  112. .head {
  113. width: 24rpx;
  114. height: 24rpx;
  115. border-radius: 100rpx;
  116. margin-right: 10rpx;
  117. }
  118. }
  119. .time {
  120. font-size: 18rpx;
  121. font-weight: 400;
  122. color: #999999;
  123. .look {
  124. margin: 0 10rpx;
  125. }
  126. }
  127. }
  128. }
  129. .first-box {
  130. padding: 24rpx 0;
  131. border-bottom: 2rpx solid #CCCCCC;
  132. .first-item {
  133. width: 320rpx;
  134. .user {
  135. margin-top: 10rpx;
  136. .user-name {
  137. font-size: 18rpx;
  138. font-family: PingFangSC-Regular, PingFang SC;
  139. font-weight: 400;
  140. color: #999999;
  141. }
  142. .head {
  143. width: 24rpx;
  144. height: 24rpx;
  145. border-radius: 100rpx;
  146. margin-right: 10rpx;
  147. }
  148. }
  149. .image {
  150. width: 320rpx;
  151. height: 220rpx;
  152. border-radius: 10rpx;
  153. }
  154. .name {
  155. margin-top: 14rpx;
  156. font-size: 24rpx;
  157. font-family: PingFangSC-Medium, PingFang SC;
  158. font-weight: 500;
  159. color: #333333;
  160. }
  161. }
  162. }
  163. }
  164. </style>