CollectionList.vue 7.9 KB

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