CollectionList.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <div class="current_recommendation_con" :key="index" @click="goDetail">
  3. <!-- <img :src="info.pic[0].url" alt="" class="current_recommendation_img"> -->
  4. <van-image width="100%" height="164px" :src="getImg(info.pic[0].url)" fit="cover" />
  5. <!-- <van-image width="100%" height="calc(50vw - 24px)" :src="getImg(changeImgs(info.pic, 600))" fit="cover" class="current_recommendation_img"/> -->
  6. <div class="current_recommendation_title">{{ info.name }}</div>
  7. <div class="current_recommendation_price" :style="{ 'padding-left': info.salable ? '18px' : '9px' }">
  8. <div v-if="info.salable">
  9. <div class="current_recommendation_price_one">¥</div>
  10. <div class="current_recommendation_price_two">{{ info.price }}</div>
  11. </div>
  12. <div v-else class="showOnly">仅展示</div>
  13. </div>
  14. <div class="current_recommendation_bottom">
  15. <div class="current_recommendation_bottom_left">
  16. <!-- <img :src="info.minterAvatar" alt="" class="current_recommendation_name_img"> -->
  17. <van-image width="18px" height="18px" :radius="18" :src="getImg(info.minterAvatar)" fit="cover" />
  18. <div class="current_recommendation_name">{{ info.owner }}</div>
  19. </div>
  20. <div class="current_recommendation_bottom_right">
  21. <img :src="info.liked ? likes : noLikes" alt="" />
  22. <div class="give_number">{{ info.likes }}</div>
  23. </div>
  24. </div>
  25. </div>
  26. <!-- <div class="sold xianliang" v-if="time && info.salable">
  27. <img src="@assets/shizhong.png" alt="" />
  28. <span>{{ startTime || time }}</span>
  29. </div>
  30. <div class="sold" v-if="isSolded">已售罄</div>
  31. <div class="sold" v-else-if="isSold" style="color: #ff4f50">即将售罄</div>
  32. </div> -->
  33. </template>
  34. <script>
  35. // import product from '../../mixins/product';
  36. export default {
  37. // mixins: [product],
  38. props: {
  39. info: {
  40. type: Object,
  41. default: () => {
  42. return {};
  43. }
  44. }
  45. },
  46. data() {
  47. return {
  48. noLikes: require('@assets/icon-dianzan.png'),
  49. likes: require('@assets/icon-dianzan@2x.png')
  50. };
  51. },
  52. computed: {
  53. time() {
  54. if (this.info.startTime) {
  55. if (this.dayjs().isSameOrBefore(this.info.startTime, 'YYYY-MM-DD HH:mm:ss')) {
  56. return this.dayjs(this.info.startTime, 'YYYY-MM-DD HH:mm:ss').format('MM月DD日');
  57. }
  58. }
  59. return '';
  60. }
  61. },
  62. mounted() {
  63. // if (this.info.startTime) {
  64. // var x = this.dayjs(this.info.startTime);
  65. // var y = this.dayjs();
  66. // let d = this.dayjs.duration(x.diff(y));
  67. // let day = parseInt(d.asDays());
  68. // if (day <= 0) {
  69. // this.getTime(this.info.startTime);
  70. // }
  71. // }
  72. },
  73. methods: {
  74. likeProduct() {
  75. if (!this.info.liked) {
  76. this.$http.get(`/collection/${this.info.id}/like`).then(() => {
  77. this.$emit('update:info', {
  78. ...this.info,
  79. liked: true,
  80. likes: this.info.likes + 1
  81. });
  82. this.$toast.success('收藏成功');
  83. });
  84. } else {
  85. this.$http.get(`/collection/${this.info.id}/unlike`).then(() => {
  86. this.$emit('update:info', {
  87. ...this.info,
  88. liked: false,
  89. likes: this.info.likes - 1
  90. });
  91. this.$toast.success('取消收藏');
  92. });
  93. }
  94. },
  95. goDetail() {
  96. this.$router.push({ path: '/productDetail', query: { collectionId: this.info.id } });
  97. // if (!this.usedBuy && this.info.source === 'TRANSFER') {
  98. // this.$toast('该通道暂且关闭');
  99. // } else {
  100. // this.$router.push({
  101. // path: '/productDetail/' + this.info.id
  102. // });
  103. // }
  104. }
  105. }
  106. };
  107. </script>
  108. <style lang="less" scoped>
  109. .current_recommendation_con {
  110. width: 48%;
  111. height: 254px;
  112. background: #29293f;
  113. border-radius: 8px;
  114. margin-bottom: 16px;
  115. overflow: hidden;
  116. .current_recommendation_title {
  117. margin-top: 6px;
  118. padding: 0 10px;
  119. width: 170px;
  120. white-space: nowrap;
  121. overflow: hidden;
  122. text-overflow: ellipsis;
  123. box-sizing: border-box;
  124. font-size: 14px;
  125. font-family: PingFangSC-Medium, PingFang SC;
  126. font-weight: 500;
  127. color: #ffffff;
  128. }
  129. .current_recommendation_price {
  130. width: 100%;
  131. margin-top: 5px;
  132. // padding-left: 22px;
  133. box-sizing: border-box;
  134. display: flex;
  135. position: relative;
  136. margin-bottom: 8px;
  137. .showOnly {
  138. font-size: 14px;
  139. font-family: PingFangSC-Regular, PingFang SC;
  140. font-weight: 400;
  141. color: #939599;
  142. }
  143. .current_recommendation_price_one {
  144. font-size: 10px;
  145. font-family: PingFangSC-Medium, PingFang SC;
  146. font-weight: 500;
  147. color: #28b6ff;
  148. position: absolute;
  149. bottom: 1px;
  150. left: 8px;
  151. }
  152. .current_recommendation_price_two {
  153. font-size: 16px;
  154. font-family: PingFangSC-Medium, PingFang SC;
  155. font-weight: 500;
  156. color: #28b6ff;
  157. }
  158. }
  159. .current_recommendation_bottom {
  160. width: 100%;
  161. display: flex;
  162. justify-content: space-between;
  163. padding: 0px 10px;
  164. box-sizing: border-box;
  165. .current_recommendation_bottom_left {
  166. display: flex;
  167. }
  168. .current_recommendation_bottom_right {
  169. display: flex;
  170. height: 18px;
  171. }
  172. .current_recommendation_name {
  173. margin-left: 4px;
  174. width: 80px;
  175. height: 18px;
  176. line-height: 18px;
  177. font-size: 12px;
  178. font-family: PingFangSC-Regular, PingFang SC;
  179. font-weight: 400;
  180. color: #939599;
  181. overflow: hidden;
  182. text-overflow: ellipsis;
  183. white-space: nowrap;
  184. }
  185. .give_img {
  186. width: 18px;
  187. height: 18px;
  188. margin-right: 2px;
  189. }
  190. .give_number {
  191. margin-left: 2px;
  192. height: 18px;
  193. line-height: 18px;
  194. font-size: 12px;
  195. font-family: PingFangSC-Regular, PingFang SC;
  196. font-weight: 400;
  197. color: #939599;
  198. }
  199. }
  200. }
  201. </style>