news-module.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="news_module vflex">
  3. <block v-for="(item,index) in pageList" :key="index">
  4. <view class="news_box">
  5. <view class="news_title">
  6. {{item.ad.title}}
  7. </view>
  8. <view v-if="item.ad.images !== ''" class="imgList hflex acenter jbetween">
  9. <image :src="item.ad.images" mode="aspectFill" class="img2"></image>
  10. </view>
  11. <view class="hflex acenter bottom">
  12. <view class="bottom_text3">广告</view>
  13. <view class="bottom_text2" v-if="item.ad.source">{{item.ad.source}}</view>
  14. </view>
  15. </view>
  16. <view class="" >
  17. <block v-for="(item1,index1) in item.xw" :key="index1">
  18. <view class="news_box" @click="toDetail(item1.id)">
  19. <view class="news_title">
  20. {{item1.title}}
  21. </view>
  22. <!-- <view class="hflex acenter user" v-if="item2.user">
  23. <view class="avatar_box">
  24. <image :src="item.user.avatar" mode="aspectFill" class="avatar"></image>
  25. </view>
  26. <view class="user_text">{{item.user.name}}</view>
  27. <view v-if="item.user.is_blueV" class="blue_v">
  28. V
  29. </view>
  30. </view> -->
  31. <view v-if="item1.images.length > 2" class="imgList hflex acenter jbetween">
  32. <block v-for="(item2,index2) in item1.images" :key="index2">
  33. <image :src="item2" mode="aspectFill" class="img" @tap.stop="priveImg(index,index2)"></image>
  34. </block>
  35. </view>
  36. <view v-if="item1.images.length == 1 && !item1.has_img" class="imgList hflex acenter jcenter">
  37. <image :src="item1.images" mode="aspectFill" class="img2"></image>
  38. </view>
  39. <!-- <view v-if="item.video" class="imgList">
  40. <video :src="item.video" controls></video>
  41. </view> -->
  42. <view class="hflex acenter bottom">
  43. <view class="bottom_text">{{item1.category.name}}</view>
  44. <view class="bottom_text2">{{item1.source}}</view>
  45. <view class="bottom_text2" v-if="item1.comments_count > 0">{{item1.comments_count}}评论</view>
  46. </view>
  47. </view>
  48. </block>
  49. </view>
  50. </block>
  51. </view>
  52. </template>
  53. <script>
  54. import $api from '@/static/js/api.js'
  55. export default {
  56. name:"news-module",
  57. props: {
  58. pageList: {
  59. type: Array,
  60. value: []
  61. }
  62. },
  63. data() {
  64. return {
  65. }
  66. },
  67. methods: {
  68. // 打开详情
  69. toDetail(id) {
  70. $api.jump('/page_index/pages/index/newDetail?id=' + id)
  71. },
  72. // 查看图片
  73. priveImg(index,index2) {
  74. var that = this
  75. uni.previewImage({
  76. urls: that.pageList[index].imgs,
  77. current: that.pageList[index].imgs[index2]
  78. });
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. .news_module {
  85. width: 100%;
  86. .news_box {
  87. margin-top: 20rpx;
  88. padding-bottom: 20rpx;
  89. border-bottom: 1rpx solid #f3f3f3;
  90. .news_title {
  91. font-size: 36rpx;
  92. color: #333;
  93. line-height: 50rpx;
  94. padding: 20rpx 0;
  95. }
  96. .user {
  97. padding: 14rpx 0 0;
  98. .avatar_box {
  99. margin-right: 8rpx;
  100. .avatar {
  101. width: 32rpx;
  102. height: 32rpx;
  103. border-radius: 50%;
  104. }
  105. }
  106. .user_text {
  107. font-size: 24rpx;
  108. font-weight: 400;
  109. color: #666666;
  110. line-height: 34rpx;
  111. }
  112. .blue_v {
  113. background: #506DFF;
  114. border-radius: 12rpx 4rpx 12rpx 4rpx;
  115. margin-left: 8rpx;
  116. text-align: center;
  117. line-height: 28rpx;
  118. // padding: 6rpx;
  119. width: 28rpx;
  120. height: 28rpx;
  121. color: #fff;
  122. font-size: 14rpx;
  123. }
  124. }
  125. .imgList {
  126. margin: 16rpx 0;
  127. .img {
  128. width: 224rpx;
  129. height: 148rpx;
  130. border-radius: 8rpx 0px 0px 8rpx;
  131. margin: 0 12rpx 20rpx 0;
  132. }
  133. .img2 {
  134. width: 100%;
  135. height: 360rpx;
  136. border-radius: 16px;
  137. }
  138. }
  139. .bottom {
  140. .bottom_text {
  141. font-size: 24rpx;
  142. color: #3261FF;
  143. }
  144. .bottom_text2 {
  145. color: #999999;
  146. font-size: 24rpx;
  147. margin-left: 20rpx;
  148. }
  149. .bottom_text3 {
  150. font-size: 24rpx;
  151. font-weight: 400;
  152. color: #EB0000;
  153. line-height: 34rpx;
  154. }
  155. }
  156. }
  157. }
  158. </style>