card.vue 4.4 KB

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