index.vue 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <uni-shadow-root class="vant-dist-card-index"><view class="custom-class van-card">
  3. <view :class="utils.bem('card__header', { center: centered })">
  4. <view class="van-card__thumb" @click="onClickThumb">
  5. <image v-if="thumb" :src="thumb" :mode="thumbMode" :lazy-load="lazyLoad" class="van-card__img thumb-class"></image>
  6. <slot v-else name="thumb"></slot>
  7. <van-tag v-if="tag" mark type="danger" custom-class="van-card__tag">
  8. {{ tag }}
  9. </van-tag>
  10. <slot v-else name="tag"></slot>
  11. </view>
  12. <view :class="'van-card__content '+(utils.bem('card__content', { center: centered }))">
  13. <view>
  14. <view v-if="title" class="van-card__title title-class">{{ title }}</view>
  15. <slot v-else name="title"></slot>
  16. <view v-if="desc" class="van-card__desc desc-class">{{ desc }}</view>
  17. <slot v-else name="desc"></slot>
  18. <slot name="tags"></slot>
  19. </view>
  20. <view class="van-card__bottom">
  21. <slot name="price-top"></slot>
  22. <view v-if="price || price === 0" class="van-card__price price-class">
  23. <text>{{ currency }}</text>
  24. <text class="van-card__price-integer">{{ integerStr }}</text>
  25. <text class="van-card__price-decimal">{{ decimalStr }}</text>
  26. </view>
  27. <slot v-else name="price"></slot>
  28. <view v-if="originPrice || originPrice === 0" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view>
  29. <slot v-else name="origin-price"></slot>
  30. <view v-if="num" class="van-card__num num-class">x {{ num }}</view>
  31. <slot v-else name="num"></slot>
  32. <slot name="bottom"></slot>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="van-card__footer">
  37. <slot name="footer"></slot>
  38. </view>
  39. </view></uni-shadow-root>
  40. </template>
  41. <wxs src="../wxs/utils.wxs" module="utils"></wxs>
  42. <script>
  43. import VanTag from '../tag/index.vue'
  44. global['__wxVueOptions'] = {components:{'van-tag': VanTag}}
  45. global['__wxRoute'] = 'vant/dist/card/index'
  46. import { link } from '../mixins/link';
  47. import { VantComponent } from '../common/component';
  48. VantComponent({
  49. classes: [
  50. 'num-class',
  51. 'desc-class',
  52. 'thumb-class',
  53. 'title-class',
  54. 'price-class',
  55. 'origin-price-class',
  56. ],
  57. mixins: [link],
  58. props: {
  59. tag: String,
  60. num: String,
  61. desc: String,
  62. thumb: String,
  63. title: String,
  64. price: {
  65. type: String,
  66. observer: 'updatePrice',
  67. },
  68. centered: Boolean,
  69. lazyLoad: Boolean,
  70. thumbLink: String,
  71. originPrice: String,
  72. thumbMode: {
  73. type: String,
  74. value: 'aspectFit',
  75. },
  76. currency: {
  77. type: String,
  78. value: '¥',
  79. },
  80. },
  81. methods: {
  82. updatePrice() {
  83. const { price } = this.data;
  84. const priceArr = price.toString().split('.');
  85. this.setData({
  86. integerStr: priceArr[0],
  87. decimalStr: priceArr[1] ? `.${priceArr[1]}` : '',
  88. });
  89. },
  90. onClickThumb() {
  91. this.jumpLink('thumbLink');
  92. },
  93. },
  94. });
  95. export default global['__wxComponents']['vant/dist/card/index']
  96. </script>
  97. <style platform="mp-weixin">
  98. @import '../common/index.css';.van-card{position:relative;box-sizing:border-box;padding:8px 16px;padding:var(--card-padding,8px 16px);font-size:12px;font-size:var(--card-font-size,12px);color:#323233;color:var(--card-text-color,#323233);background-color:#fafafa;background-color:var(--card-background-color,#fafafa)}.van-card__header{display:flex}.van-card__header--center{align-items:center;justify-content:center}.van-card__thumb{position:relative;flex:none;width:88px;width:var(--card-thumb-size,88px);height:88px;height:var(--card-thumb-size,88px);margin-right:8px;margin-right:var(--padding-xs,8px)}.van-card__thumb:empty{display:none}.van-card__img{width:100%;height:100%;border-radius:8px;border-radius:var(--border-radius-lg,8px)}.van-card__content{position:relative;display:flex;flex:1;flex-direction:column;justify-content:space-between;min-width:0;min-height:88px;min-height:var(--card-thumb-size,88px)}.van-card__content--center{justify-content:center}.van-card__desc,.van-card__title{word-wrap:break-word}.van-card__title{font-weight:700;line-height:16px;line-height:var(--card-title-line-height,16px)}.van-card__desc{line-height:20px;line-height:var(--card-desc-line-height,20px);color:#646566;color:var(--card-desc-color,#646566)}.van-card__bottom{line-height:20px}.van-card__price{display:inline-block;font-weight:700;color:#ee0a24;color:var(--card-price-color,#ee0a24);font-size:12px;font-size:var(--card-price-font-size,12px)}.van-card__price-integer{font-size:16px;font-size:var(--card-price-integer-font-size,16px)}.van-card__price-decimal,.van-card__price-integer{font-family:Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif;font-family:var(--card-price-font-family,Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif)}.van-card__origin-price{display:inline-block;margin-left:5px;text-decoration:line-through;font-size:10px;font-size:var(--card-origin-price-font-size,10px);color:#646566;color:var(--card-origin-price-color,#646566)}.van-card__num{float:right}.van-card__tag{position:absolute!important;top:2px;left:0}.van-card__footer{flex:none;width:100%;text-align:right}
  99. </style>