ProductInfo.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <div class="product-card" @click="detail">
  3. <van-image width="80" height="115" :src="info.image" fit="cover" radius="6" />
  4. <div class="product-content">
  5. <div class="text1">{{ info.caseName }}</div>
  6. <div class="text2">
  7. <span>距结束</span>
  8. <van-count-down class="val" :time="time" format="DD 天 HH:mm:ss" />
  9. </div>
  10. <div class="text2">
  11. <span>已拼箱</span>
  12. <span class="val">{{ info.preorder || 0 }}/{{ info.total || 0 }}</span>
  13. </div>
  14. <div class="flex1"></div>
  15. <div class="price">
  16. <van-icon size="10" :color="$colors.red" name="jiage" class-prefix="iconfont" />
  17. <span>{{ info.price }}</span>
  18. </div>
  19. <div class="button" v-if="showBtn">
  20. <van-button @click.stop="manage" type="primary" size="small" v-if="isMine">管理拼箱</van-button>
  21. <van-button @click.stop="cancelFollow" type="info" plain size="small" v-else-if="showType === 'collect'"
  22. >取消关注</van-button
  23. >
  24. <van-button type="primary" size="small" v-else-if="info.caseStatus === 'PROGRESS'">立即拼箱</van-button>
  25. </div>
  26. </div>
  27. <div class="live" v-if="!isMine && info.liveNow">
  28. <img src="/native/svgs/icon_kapai_zhibo.svg" alt="" />
  29. <span>直播</span>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import dayjs from 'dayjs';
  35. import collection from '../mixins/collection';
  36. export default {
  37. name: 'ProductInfo',
  38. mixins: [collection],
  39. props: {
  40. info: {
  41. type: Object,
  42. default: () => {
  43. return {};
  44. }
  45. },
  46. showBtn: {
  47. type: Boolean,
  48. default: true
  49. },
  50. showType: {
  51. type: String,
  52. default: 'product'
  53. },
  54. isMine: {
  55. type: Boolean,
  56. default: false
  57. },
  58. startChoose: {
  59. type: Boolean,
  60. default: false
  61. }
  62. },
  63. data() {
  64. return {
  65. cartId: 0,
  66. isCollection: false
  67. };
  68. },
  69. mounted() {
  70. this.$nextTick(() => {
  71. if (this.showType === 'collect') {
  72. this.cartId = this.info.cartId;
  73. this.isCollection = true;
  74. }
  75. });
  76. },
  77. computed: {
  78. time() {
  79. if (this.info.endTime) {
  80. let date = dayjs(this.info.endTime, 'YYYY-MM-DD HH:mm:ss');
  81. return date.diff(dayjs());
  82. } else {
  83. return 0;
  84. }
  85. }
  86. },
  87. methods: {
  88. manage() {
  89. console.log(this.info.liveNow);
  90. this.navigateTo('/pages/store/productEdit?id=' + this.info.cardCaseId + '&name=' + this.info.caseName);
  91. },
  92. detail() {
  93. if (this.startChoose) {
  94. this.$emit('choose', this.info.cardCaseId);
  95. } else {
  96. this.navigateTo('/pages/details?id=' + this.info.cardCaseId, false);
  97. }
  98. },
  99. cancelFollow() {
  100. wx.showModal({
  101. content: '确定要取消关注吗?',
  102. confirmColor: this.$colors.prim,
  103. success: res => {
  104. if (res.confirm) {
  105. this.collect().then(() => {
  106. setTimeout(() => {
  107. this.$emit('getInfo');
  108. }, 1000);
  109. });
  110. }
  111. }
  112. });
  113. }
  114. }
  115. };
  116. </script>
  117. <style lang="less" scoped>
  118. .product-card {
  119. height: 115px;
  120. .flex();
  121. position: relative;
  122. }
  123. .product-content {
  124. flex-grow: 1;
  125. margin-left: 10px;
  126. align-self: stretch;
  127. .flex-col();
  128. position: relative;
  129. overflow: hidden;
  130. .text1 {
  131. font-size: 16px;
  132. font-weight: bold;
  133. color: #000000;
  134. line-height: 24px;
  135. .ellipsis();
  136. margin-bottom: 6px;
  137. }
  138. .text2 {
  139. padding: 2px 0;
  140. .flex();
  141. span {
  142. font-size: 14px;
  143. color: #c8c9cc;
  144. line-height: 24px;
  145. &.val {
  146. font-size: 14px;
  147. color: @prim;
  148. }
  149. }
  150. /deep/ .val {
  151. .van-count-down {
  152. --count-down-text-color: @prim;
  153. }
  154. }
  155. }
  156. .flex1 {
  157. flex-grow: 1;
  158. }
  159. .price {
  160. .flex();
  161. font-size: 24px;
  162. font-family: 'OSP';
  163. font-weight: normal;
  164. color: #f42202;
  165. line-height: 22px;
  166. }
  167. }
  168. .button {
  169. position: absolute;
  170. right: 0;
  171. bottom: 0;
  172. }
  173. .live {
  174. padding: 4px 3px;
  175. background-color: @prim;
  176. border-radius: 4px;
  177. position: absolute;
  178. top: 10px;
  179. left: -7px;
  180. .flex();
  181. img {
  182. width: 14px;
  183. height: 14px;
  184. margin-right: 4px;
  185. }
  186. span {
  187. font-size: 12px;
  188. color: #ffffff;
  189. line-height: 14px;
  190. }
  191. }
  192. </style>