[improvement] Card: add thumb link prop (#706)

This commit is contained in:
neverland 2018-10-08 17:43:43 +08:00 committed by GitHub
parent afeed567d2
commit a8d7d248a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 9 deletions

View File

@ -54,6 +54,8 @@
| price | 商品价格 | `String | Number` | - | | price | 商品价格 | `String | Number` | - |
| centered | 内容是否垂直居中 | `String` | `false` | | centered | 内容是否垂直居中 | `String` | `false` |
| currency | 货币符号 | `String` | `¥` | | currency | 货币符号 | `String` | `¥` |
| thumb-link | 点击左侧图片后的跳转链接 | `String` | - |
| link-type | 链接跳转类型,可选值为 `redirectTo` `switchTab` `reLaunch` | `String` | `navigateTo` |
### Slot ### Slot

View File

@ -3,7 +3,7 @@
.van-card { .van-card {
color: @text-color; color: @text-color;
height: 100px; height: 100px;
font-size: 16px; font-size: 12px;
background: #fafafa; background: #fafafa;
position: relative; position: relative;
box-sizing: border-box; box-sizing: border-box;
@ -55,9 +55,8 @@
} }
&__desc { &__desc {
color: @gray-darker;
font-size: 12px;
max-height: 20px; max-height: 20px;
color: @gray-darker;
} }
&__price, &__price,
@ -68,13 +67,14 @@
text-align: right; text-align: right;
} }
&__price {
font-size: 14px;
}
&__num { &__num {
color: @gray-darker; color: @gray-darker;
font-size: 12px; }
&__tag {
position: absolute;
top: 2px;
left: 0;
} }
&__tag { &__tag {

View File

@ -17,9 +17,23 @@ VantComponent({
title: String, title: String,
price: String, price: String,
centered: Boolean, centered: Boolean,
thumbLink: String,
linkType: {
type: String,
value: 'navigateTo'
},
currency: { currency: {
type: String, type: String,
value: '¥' value: '¥'
} }
},
methods: {
onClickThumb() {
const { thumbLink } = this.data;
if (thumbLink) {
wx[this.data.linkType]({ url: thumbLink });
}
}
} }
}); });

View File

@ -1,5 +1,5 @@
<view class="custom-class van-card {{ centered ? 'van-card--center' : '' }}"> <view class="custom-class van-card {{ centered ? 'van-card--center' : '' }}">
<view class="van-card__thumb"> <view class="van-card__thumb" bind:tap="onClickThumb">
<image wx:if="{{ thumb }}" src="{{ thumb }}" class="van-card__img thumb-class" /> <image wx:if="{{ thumb }}" src="{{ thumb }}" class="van-card__img thumb-class" />
<slot wx:else name="thumb" /> <slot wx:else name="thumb" />
<van-tag <van-tag