t-i-news.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view class="content">
  3. <view class="title">
  4. <view class="text">宁煤新闻</view>
  5. <view class="more">查看全部 <uni-icons type="arrowright" color="#999" size="11"></uni-icons>
  6. </view>
  7. </view>
  8. <view class="list">
  9. <view class="item" v-for="(item,index) in list" :key="index" @click="go_detail(item.id)">
  10. <view class="left">
  11. <image :src="item.main_img"></image>
  12. </view>
  13. <view class="right">
  14. <view class="title">{{item.title}}</view>
  15. <view class="time">{{item.created_at}}</view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. name: "t-i-news",
  24. props: [
  25. "base_url"
  26. ],
  27. data() {
  28. return {
  29. list: []
  30. };
  31. },
  32. created() {
  33. console.log(this.base_url)
  34. // 获取首页新闻列表
  35. this.getNews()
  36. },
  37. methods: {
  38. // 请求新闻动态
  39. getNews() {
  40. uni.request({
  41. url: this.base_url + "/article/list",
  42. method: "GET",
  43. data: {
  44. pageSize: 4
  45. },
  46. success: (res) => {
  47. // console.log(res.data.data.data)
  48. this.list = res.data.data.data
  49. }
  50. })
  51. },
  52. // 打开详情页
  53. go_detail(id) {
  54. uni.navigateTo({
  55. url: "../../index/news/news?id=" + id
  56. })
  57. },
  58. }
  59. }
  60. </script>
  61. <style lang="scss">
  62. .content {
  63. background-color: #FFFFFF;
  64. box-sizing: border-box;
  65. padding: 50rpx 25rpx;
  66. }
  67. .title {
  68. display: flex;
  69. align-items: baseline;
  70. justify-content: space-between;
  71. .text {
  72. font-size: 36rpx;
  73. }
  74. .more {
  75. font-size: 26rpx;
  76. color: #999;
  77. }
  78. }
  79. .list {
  80. margin-top: 20rpx;
  81. width: 700rpx;
  82. .item {
  83. box-sizing: border-box;
  84. padding-top: 20rpx;
  85. padding-bottom: 12rpx;
  86. display: flex;
  87. .left {
  88. width: 240rpx;
  89. height: 136rpx;
  90. image {
  91. width: 240rpx;
  92. height: 136rpx;
  93. border-radius: 8rpx;
  94. overflow: hidden;
  95. }
  96. }
  97. .right {
  98. margin-left: 22rpx;
  99. display: flex;
  100. flex-flow: column;
  101. justify-content: space-around;
  102. .title {
  103. overflow: hidden;
  104. -webkit-line-clamp: 2;
  105. text-overflow: ellipsis;
  106. display: -webkit-box;
  107. -webkit-box-orient: vertical;
  108. font-size: 32rpx;
  109. font-weight: 400;
  110. color: #121212;
  111. line-height: 40rpx;
  112. }
  113. .time {
  114. font-size: 26rpx;
  115. font-weight: 400;
  116. color: #999;
  117. line-height: 40rpx;
  118. }
  119. }
  120. }
  121. }
  122. </style>