card.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view class="waterfall-item" :style="{width,...customStyle}">
  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}">wang</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}">11</text>
  20. </view>
  21. </view>
  22. <view class="waterfall-item__ft__btn">
  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;">100</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. }
  71. }
  72. </script>
  73. <style lang="scss">
  74. .waterfall-item {
  75. margin-bottom: 20rpx;
  76. border-radius: 30rpx;
  77. position: relative;
  78. // #ifndef APP-NVUE
  79. .waterfall-item__image {
  80. width: 100%;
  81. height: auto;
  82. image {
  83. width: 100%;
  84. height: 100%;
  85. }
  86. }
  87. // #endif
  88. .waterfall-item__tips {
  89. position: absolute;
  90. top: 20rpx;
  91. padding: 5rpx 10rpx;
  92. // #ifndef APP-NVUE
  93. box-sizing: border-box;
  94. // #endif
  95. width: 100%;
  96. display: flex;
  97. flex-direction: row;
  98. align-items: center;
  99. justify-content: space-between;
  100. .item {
  101. // #ifndef APP-NVUE
  102. // #endif
  103. display: flex;
  104. flex-direction: row;
  105. align-items: center;
  106. background: rgba(0, 0, 0, 0.2);
  107. padding: 5rpx 10rpx;
  108. border-radius: 6rpx;
  109. .look-icon {
  110. width: 26rpx;
  111. height: 18rpx;
  112. margin-right: 10rpx;
  113. }
  114. .value {
  115. font-size: 20rpx;
  116. }
  117. }
  118. }
  119. .waterfall-item__ft {
  120. padding: 10rpx 20rpx;
  121. &__title {
  122. line-height: 48rpx;
  123. font-weight: 700;
  124. .value {
  125. font-size: 30rpx;
  126. }
  127. }
  128. &__desc {
  129. width: 100%;
  130. // #ifndef APP-NVUE
  131. display: flex;
  132. // #endif
  133. // #ifdef APP-NVUE
  134. // #endif
  135. flex-direction: row;
  136. align-items: center;
  137. justify-content: space-between;
  138. margin: 20rpx 0;
  139. .user {
  140. // #ifndef APP-NVUE
  141. display: flex;
  142. // #endif
  143. // #ifdef APP-NVUE
  144. flex-direction: row;
  145. // #endif
  146. align-items: center;
  147. .avater {
  148. width: 36rpx;
  149. height: 36rpx;
  150. border-radius: 18rpx;
  151. margin-right: 10rpx;
  152. }
  153. .name {
  154. font-size: 24rpx;
  155. }
  156. }
  157. .like {
  158. // #ifndef APP-NVUE
  159. display: flex;
  160. // #endif
  161. // #ifdef APP-NVUE
  162. flex-direction: row;
  163. // #endif
  164. align-items: center;
  165. .like-icon {
  166. width: 30rpx;
  167. height: 25rpx;
  168. margin-right: 10rpx;
  169. }
  170. .value {
  171. font-size: 24rpx;
  172. }
  173. }
  174. }
  175. &__btn {
  176. height: 65rpx;
  177. border-radius: 18px;
  178. background-image: linear-gradient(to bottom, #BFFE9C, #AEE75D);
  179. // #ifndef APP-NVUE
  180. background: linear-gradient(180deg, #BFFE9C 0%, #AEE75D 62%, #AEE75D 100%);
  181. display: flex;
  182. // #endif
  183. justify-content: center;
  184. align-items: center;
  185. &__icon {
  186. width: 155rpx;
  187. height: 32rpx;
  188. }
  189. }
  190. }
  191. }
  192. </style>