trends-list.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <view>
  3. <block v-for="(item,index) in list_data" :key="index" v-if="getMinToMax(index)">
  4. <view class="bg-white margin-top padding radius zaiui-trends">
  5. <!--用户信息-->
  6. <view class="cu-list menu-avatar">
  7. <view class="cu-item">
  8. <view class="cu-avatar round" :style="[{backgroundImage:'url('+ item.avatar +')'}]" @tap="listTap('userTap',item,index)"/>
  9. <view class="content" @tap="listTap('userTap',item,index)">
  10. <view class="text-black">
  11. <view class="text-cut">{{item.username}}</view>
  12. </view>
  13. <view class="text-sm flex">
  14. <text>{{item.time}}</text>
  15. </view>
  16. </view>
  17. <view class="action">
  18. <button class="cu-btn sm line-red" @tap="listTap('viewBtnTap',item,index)" v-if="viewBtn">
  19. <text class="cuIcon-goods"/>
  20. <text class="margin-left-xs">看TA</text>
  21. </button>
  22. <button class="cu-btn sm" :class="item.follow?'bg-red':'line-red'" @tap="listTap('followTap',item,index)" v-else>
  23. <text class="cuIcon-add" v-if="!item.follow"></text>
  24. <text class="margin-left-xs" v-if="!item.follow">关注</text>
  25. <text v-if="item.follow">已关注</text>
  26. </button>
  27. </view>
  28. </view>
  29. </view>
  30. <!--内容-->
  31. <view class="margin-tb text-black zaiui-text-content" @tap="listTap('contentTap',item,index)">
  32. <text v-html="item.text">{{item.text}}</text>
  33. <text class="text-blue margin-left-xs" v-if="item.text_btn">
  34. <text>查看全文</text>
  35. <text class="cuIcon-right"/>
  36. </text>
  37. </view>
  38. <!-- #ifndef APP-PLUS -->
  39. <view class="zaiui-video-box" v-if="item.video">
  40. <video class="video-view" :src="item.video" @error="videoErrorCallback"/>
  41. </view>
  42. <!-- #endif -->
  43. <!-- #ifdef APP-PLUS -->
  44. <view class="zaiui-video-box" v-if="item.video">
  45. <video-render :isCover="item.cover" :isSrc="item.video" :isNum="(index+1)"/>
  46. </view>
  47. <!-- #endif -->
  48. <view class="zaiui-img-grid-col" v-if="item.img.length > 0">
  49. <!--单图-->
  50. <view class="one-img" v-if="item.img.length == 1" @tap="imgTap(item.img[0],item.img,0)">
  51. <view class="img-grid" :style="[{backgroundImage:'url('+ item.img[0] +')'}]"/>
  52. </view>
  53. <!--两图-->
  54. <view class="grid col-2" v-if="item.img.length == 2">
  55. <block v-for="(items,indexs) in item.img" :key="indexs">
  56. <view class="img-grid-view" @tap="imgTap(items,items,indexs)">
  57. <view class="img-grid" :style="[{backgroundImage:'url('+ items +')'}]"/>
  58. </view>
  59. </block>
  60. </view>
  61. <!--多图-->
  62. <view class="grid col-3" v-if="item.img.length > 2">
  63. <block v-for="(items,indexs) in item.img" :key="indexs" v-if="indexs < 9">
  64. <view class="img-grid-view" @tap="imgTap(items,items,indexs)">
  65. <view class="img-grid" :style="[{backgroundImage:'url('+ items +')'}]"/>
  66. </view>
  67. </block>
  68. </view>
  69. </view>
  70. <!--话题-->
  71. <view class="cu-tag light bg-red round margin-top" v-if="item.talk" @tap="listTap('talkTap',item,index)">
  72. <text class="cuIcon-creativefill"></text>
  73. <text class="margin-left-xs">{{item.talk}}</text>
  74. </view>
  75. <!--操作-->
  76. <view class="flex p-xs zaiui-footer-tool">
  77. <view class="flex-sub" @tap="listTap('forwardTap',item,index)">
  78. <text class="cuIcon-forward icon"></text>
  79. <text class="margin-left-xs">分享</text>
  80. </view>
  81. <view class="flex-twice text-right">
  82. <text class="text-right margin-right-lg" @tap="listTap('commentTap',item,index)">
  83. <text class="cuIcon-comment icon"/>
  84. <text class="margin-left-xs">{{item.comment}}</text>
  85. </text>
  86. <text class="text-right" :class="item.appreciate_btn?'text-red':''" @tap="listTap('appreciateTap',item,index)">
  87. <text class="cuIcon-appreciate icon"/>
  88. <text class="margin-left-xs">{{item.appreciate}}</text>
  89. </text>
  90. </view>
  91. </view>
  92. </view>
  93. </block>
  94. </view>
  95. </template>
  96. <script>
  97. import videoRender from '@/components/zaiui-common/basics/video-render';
  98. import _tool from '@/static/zaiui/util/tools.js';
  99. export default {
  100. name: 'trends-list',
  101. components: {
  102. videoRender
  103. },
  104. props: {
  105. list_data: {
  106. type: Array,
  107. default: () => {
  108. return []
  109. }
  110. },
  111. isMin: {
  112. type: Number,
  113. default: 0
  114. },
  115. isMax: {
  116. type: Number,
  117. default: 0
  118. },
  119. viewBtn: {
  120. type: Boolean,
  121. default: false
  122. }
  123. },
  124. methods: {
  125. listTap(tap,data,index) {
  126. this.$emit(tap, {
  127. data,
  128. index
  129. });
  130. },
  131. imgTap(img,arr,index) {
  132. this.$emit('imgTap', {
  133. img,
  134. arr,
  135. index
  136. });
  137. },
  138. getMinToMax(index) {
  139. let isMin = this.isMin, isMax = this.isMax;
  140. if(isMin == 0 && isMax == 0 ) {
  141. return true;
  142. } else if (isMin > 0 && isMax == 0) {
  143. if(index >= isMin) {
  144. return true;
  145. } else {
  146. return false;
  147. }
  148. } else if (isMin == 0 && isMax > 0) {
  149. if(index < isMax) {
  150. return true;
  151. } else {
  152. return false;
  153. }
  154. } else if (isMin > 0 && isMax > 0) {
  155. if(index >= isMin && index < isMax) {
  156. return true;
  157. } else {
  158. return false;
  159. }
  160. } else {
  161. return false;
  162. }
  163. },
  164. videoErrorCallback(e) {
  165. uni.showToast({
  166. title: e.target.errMsg,
  167. duration: 2000,
  168. icon: 'none'
  169. });
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. .zaiui-trends {
  176. border-radius: 18.18upx;
  177. .cu-list {
  178. .cu-item {
  179. padding-right: 0;
  180. height: 99.99upx;
  181. .cu-avatar {
  182. left: 0;
  183. width: 81.81upx;
  184. height: 81.81upx;
  185. }
  186. .content {
  187. left: 99.99upx;
  188. line-height: 1.5em;
  189. }
  190. .action {
  191. width: 154.54upx;
  192. text-align: right;
  193. .cu-btn {
  194. &:after {
  195. border-radius: 18.18upx;
  196. }
  197. .cuIcon-add {
  198. font-size: 27.27upx;
  199. }
  200. }
  201. }
  202. &:after {
  203. width: 0;
  204. height: 0;
  205. border-bottom: 0;
  206. }
  207. }
  208. }
  209. .zaiui-text-content {
  210. line-height: 1.6;
  211. .cuIcon-right {
  212. position: relative;
  213. top: 1upx;
  214. }
  215. }
  216. .zaiui-video-box {
  217. position: relative;
  218. width: 100%;
  219. .video-view {
  220. width: 100%;
  221. height: 363.63upx;
  222. z-index: 0;
  223. }
  224. }
  225. .zaiui-img-grid-col {
  226. position: relative;
  227. width: 100%;
  228. .one-img {
  229. position: relative;
  230. .img-grid {
  231. width: 100%;
  232. height: 363.63upx;
  233. border-radius: 9.09upx;
  234. background-size: cover;
  235. background-position: center;
  236. background-repeat: no-repeat;
  237. }
  238. }
  239. .col-2 {
  240. .img-grid-view {
  241. padding: 5.45upx;
  242. .img-grid {
  243. position: relative;
  244. width: 309.09upx;
  245. height: 218.18upx;
  246. background-size: cover;
  247. background-position: center;
  248. border-radius: 9.09upx;
  249. }
  250. }
  251. }
  252. .col-3 {
  253. .img-grid-view {
  254. padding: 5.45upx;
  255. .img-grid {
  256. position: relative;
  257. width: 204.79upx;
  258. height: 204.79upx;
  259. background-size: cover;
  260. background-position: center;
  261. border-radius: 9.09upx;
  262. }
  263. }
  264. }
  265. }
  266. .zaiui-footer-tool {
  267. margin: 40upx 0 18.18upx;
  268. .margin-right-lg {
  269. margin-right: 94.54upx;
  270. }
  271. .icon {
  272. position: relative;
  273. font-size: 36.36upx;
  274. top: 4upx;
  275. }
  276. }
  277. }
  278. </style>