card.vue 4.3 KB

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