CollectionList.vue 8.4 KB

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