card.vue 4.6 KB

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