news-module.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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(index)">
  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.slice(0,3)" :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. <!-- <u-empty icon="https://ship.shipcc.cn/common/zhan.png" text="暂时没有数据哦"> -->
  54. </view>
  55. </template>
  56. <script>
  57. import $api from '@/static/js/api.js'
  58. var that = ""
  59. export default {
  60. name:"news-module",
  61. props: {
  62. pageList: {
  63. type: Array,
  64. value: []
  65. }
  66. },
  67. data() {
  68. return {
  69. }
  70. },
  71. onLoad() {
  72. that = this
  73. },
  74. methods: {
  75. // 打开详情
  76. toDetail(index) {
  77. this.$emit('toDetail',index);
  78. },
  79. // 查看图片
  80. priveImg(index,index1,index2) {
  81. var that = this
  82. console.log(index,index2);
  83. uni.previewImage({
  84. urls: that.pageList[index].images,
  85. current: that.pageList[index].images[index2]
  86. });
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="scss">
  92. .news_module {
  93. width: 100%;
  94. .news_box {
  95. // margin-top: 20rpx;
  96. padding-bottom: 20rpx;
  97. border-bottom: 1rpx solid #f3f3f3;
  98. .news_title {
  99. font-size: 36rpx;
  100. color: #333;
  101. line-height: 50rpx;
  102. padding: 20rpx 0;
  103. }
  104. .user {
  105. padding: 14rpx 0 0;
  106. .avatar_box {
  107. margin-right: 8rpx;
  108. .avatar {
  109. width: 32rpx;
  110. height: 32rpx;
  111. border-radius: 50%;
  112. }
  113. }
  114. .user_text {
  115. font-size: 24rpx;
  116. font-weight: 400;
  117. color: #666666;
  118. line-height: 34rpx;
  119. }
  120. .blue_v {
  121. background: #506DFF;
  122. border-radius: 12rpx 4rpx 12rpx 4rpx;
  123. margin-left: 8rpx;
  124. text-align: center;
  125. line-height: 28rpx;
  126. // padding: 6rpx;
  127. width: 28rpx;
  128. height: 28rpx;
  129. color: #fff;
  130. font-size: 14rpx;
  131. }
  132. }
  133. .imgList {
  134. margin: 16rpx 0;
  135. .img {
  136. width: 224rpx;
  137. height: 148rpx;
  138. border-radius: 8rpx 0px 0px 8rpx;
  139. margin: 0 12rpx 20rpx 0;
  140. }
  141. .img2 {
  142. width: 100%;
  143. height: 360rpx;
  144. border-radius: 16px;
  145. }
  146. }
  147. .bottom {
  148. .bottom_text {
  149. font-size: 24rpx;
  150. color: #3261FF;
  151. }
  152. .bottom_text2 {
  153. color: #999999;
  154. font-size: 24rpx;
  155. margin-left: 20rpx;
  156. }
  157. .bottom_text3 {
  158. font-size: 24rpx;
  159. font-weight: 400;
  160. color: #EB0000;
  161. line-height: 34rpx;
  162. }
  163. }
  164. }
  165. }
  166. </style>