news-module.vue 4.0 KB

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