card.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="waterfall-item" :style="{width,...customStyle}" @click="goWork(item)">
  3. <view class="waterfall-item__image" :style="{width}">
  4. <image :src="item.image" mode="widthFix" style="border-radius: 20rpx;"></image>
  5. </view>
  6. <view class="waterfall-item__ft">
  7. <view class="waterfall-item__ft__title">
  8. <text class="value" :style="{color:textColor}">{{item.title}}</text>
  9. </view>
  10. <view class="waterfall-item__ft__desc">
  11. <view class="user">
  12. <image src="@/static/icon/caidou.png" mode="aspectFill" class="avater">
  13. </image>
  14. <text class="name" :style="{color:textColor}">{{item.author}}</text>
  15. </view>
  16. <view class="like" @click="changeLike">
  17. <image class="like-icon" :src="isLike ?'/static/icon/icon-7.png':'/static/icon/icon-2.png'" mode="">
  18. </image>
  19. <text class="value" :style="{color:textColor}">{{item.num_like}}</text>
  20. </view>
  21. </view>
  22. <view class="waterfall-item__ft__btn" v-if="false">
  23. <image class="waterfall-item__ft__btn__icon" src="@/static/zhHans-text-icon/text-10.png" mode="">
  24. </image>
  25. </view>
  26. </view>
  27. <view class="waterfall-item__tips">
  28. <view class="item">
  29. <image class="look-icon" src="@/static/icon/icon-4.png" mode=""></image>
  30. <text class="value" style="color: #fff;">{{item.num_view}}</text>
  31. </view>
  32. <view class="item" style="background-color: #3F4141;">
  33. <text class="value" style="color: #fff;">精选</text>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. name: "card",
  41. props: {
  42. width: {
  43. type: String,
  44. default: ''
  45. },
  46. item: {
  47. type: Object,
  48. default: () => ({})
  49. },
  50. textColor: {
  51. type: String,
  52. default: '#ff0000'
  53. },
  54. customStyle: {
  55. type: Object,
  56. default: () => ({
  57. background: '#3F4141',
  58. })
  59. }
  60. },
  61. data() {
  62. return {
  63. isLike: false,
  64. };
  65. },
  66. methods: {
  67. changeLike() {
  68. this.isLike = !this.isLike
  69. },
  70. goWork(item) {
  71. uni.navigateTo({
  72. url: '/pages/index/workDetail?id=' + item.id
  73. })
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss">
  79. .waterfall-item {
  80. margin-bottom: 20rpx;
  81. border-radius: 30rpx;
  82. position: relative;
  83. // #ifndef APP-NVUE
  84. .waterfall-item__image {
  85. width: 100%;
  86. height: auto;
  87. image {
  88. width: 100%;
  89. height: 100%;
  90. }
  91. }
  92. // #endif
  93. .waterfall-item__tips {
  94. position: absolute;
  95. top: 20rpx;
  96. padding: 5rpx 10rpx;
  97. // #ifndef APP-NVUE
  98. box-sizing: border-box;
  99. // #endif
  100. width: 100%;
  101. display: flex;
  102. flex-direction: row;
  103. align-items: center;
  104. justify-content: space-between;
  105. .item {
  106. // #ifndef APP-NVUE
  107. // #endif
  108. display: flex;
  109. flex-direction: row;
  110. align-items: center;
  111. background: rgba(0, 0, 0, 0.2);
  112. padding: 5rpx 10rpx;
  113. border-radius: 6rpx;
  114. .look-icon {
  115. width: 26rpx;
  116. height: 18rpx;
  117. margin-right: 10rpx;
  118. }
  119. .value {
  120. font-size: 20rpx;
  121. }
  122. }
  123. }
  124. .waterfall-item__ft {
  125. padding: 10rpx 20rpx;
  126. &__title {
  127. line-height: 48rpx;
  128. font-weight: 700;
  129. .value {
  130. font-size: 30rpx;
  131. }
  132. }
  133. &__desc {
  134. width: 100%;
  135. // #ifndef APP-NVUE
  136. display: flex;
  137. // #endif
  138. // #ifdef APP-NVUE
  139. // #endif
  140. flex-direction: row;
  141. align-items: center;
  142. justify-content: space-between;
  143. margin: 20rpx 0;
  144. .user {
  145. // #ifndef APP-NVUE
  146. display: flex;
  147. // #endif
  148. // #ifdef APP-NVUE
  149. flex-direction: row;
  150. // #endif
  151. align-items: center;
  152. .avater {
  153. width: 36rpx;
  154. height: 36rpx;
  155. border-radius: 18rpx;
  156. margin-right: 10rpx;
  157. }
  158. .name {
  159. font-size: 24rpx;
  160. }
  161. }
  162. .like {
  163. // #ifndef APP-NVUE
  164. display: flex;
  165. // #endif
  166. // #ifdef APP-NVUE
  167. flex-direction: row;
  168. // #endif
  169. align-items: center;
  170. .like-icon {
  171. width: 30rpx;
  172. height: 25rpx;
  173. margin-right: 10rpx;
  174. }
  175. .value {
  176. font-size: 24rpx;
  177. }
  178. }
  179. }
  180. &__btn {
  181. height: 65rpx;
  182. border-radius: 18px;
  183. background-image: linear-gradient(to bottom, #BFFE9C, #AEE75D);
  184. // #ifndef APP-NVUE
  185. background: linear-gradient(180deg, #BFFE9C 0%, #AEE75D 62%, #AEE75D 100%);
  186. display: flex;
  187. // #endif
  188. justify-content: center;
  189. align-items: center;
  190. &__icon {
  191. width: 155rpx;
  192. height: 32rpx;
  193. }
  194. }
  195. }
  196. }
  197. </style>