index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <uni-shadow-root class="weapp-lib-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'] = 'weapp/lib/card/index'
  46. "use strict";
  47. Object.defineProperty(exports, "__esModule", { value: true });
  48. var link_1 = require("../mixins/link");
  49. var component_1 = require("../common/component");
  50. (0, component_1.VantComponent)({
  51. classes: [
  52. 'num-class',
  53. 'desc-class',
  54. 'thumb-class',
  55. 'title-class',
  56. 'price-class',
  57. 'origin-price-class',
  58. ],
  59. mixins: [link_1.link],
  60. props: {
  61. tag: String,
  62. num: String,
  63. desc: String,
  64. thumb: String,
  65. title: String,
  66. price: {
  67. type: String,
  68. observer: 'updatePrice',
  69. },
  70. centered: Boolean,
  71. lazyLoad: Boolean,
  72. thumbLink: String,
  73. originPrice: String,
  74. thumbMode: {
  75. type: String,
  76. value: 'aspectFit',
  77. },
  78. currency: {
  79. type: String,
  80. value: '¥',
  81. },
  82. },
  83. methods: {
  84. updatePrice: function () {
  85. var price = this.data.price;
  86. var priceArr = price.toString().split('.');
  87. this.setData({
  88. integerStr: priceArr[0],
  89. decimalStr: priceArr[1] ? ".".concat(priceArr[1]) : '',
  90. });
  91. },
  92. onClickThumb: function () {
  93. this.jumpLink('thumbLink');
  94. },
  95. },
  96. });
  97. export default global['__wxComponents']['weapp/lib/card/index']
  98. </script>
  99. <style platform="mp-weixin">
  100. @import '../common/index.css';.van-card{background-color:var(--card-background-color,#fafafa);box-sizing:border-box;color:var(--card-text-color,#323233);font-size:var(--card-font-size,12px);padding:var(--card-padding,8px 16px);position:relative}.van-card__header{display:flex}.van-card__header--center{align-items:center;justify-content:center}.van-card__thumb{flex:none;height:var(--card-thumb-size,88px);margin-right:var(--padding-xs,8px);position:relative;width:var(--card-thumb-size,88px)}.van-card__thumb:empty{display:none}.van-card__img{border-radius:8px;height:100%;width:100%}.van-card__content{display:flex;flex:1;flex-direction:column;justify-content:space-between;min-height:var(--card-thumb-size,88px);min-width:0;position:relative}.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:var(--card-title-line-height,16px)}.van-card__desc{color:var(--card-desc-color,#646566);line-height:var(--card-desc-line-height,20px)}.van-card__bottom{line-height:20px}.van-card__price{color:var(--card-price-color,#ee0a24);display:inline-block;font-size:var(--card-price-font-size,12px);font-weight:700}.van-card__price-integer{font-size:var(--card-price-integer-font-size,16px)}.van-card__price-decimal,.van-card__price-integer{font-family:var(--card-price-font-family,Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif)}.van-card__origin-price{color:var(--card-origin-price-color,#646566);display:inline-block;font-size:var(--card-origin-price-font-size,10px);margin-left:5px;text-decoration:line-through}.van-card__num{float:right}.van-card__tag{left:0;position:absolute!important;top:2px}.van-card__footer{flex:none;text-align:right;width:100%}
  101. </style>