From a8d7d248a1ef53e4e43db9134a39528890329401 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 8 Oct 2018 17:43:43 +0800 Subject: [PATCH] [improvement] Card: add thumb link prop (#706) --- packages/card/README.md | 2 ++ packages/card/index.less | 16 ++++++++-------- packages/card/index.ts | 14 ++++++++++++++ packages/card/index.wxml | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/packages/card/README.md b/packages/card/README.md index 25744bf9..06a67da6 100644 --- a/packages/card/README.md +++ b/packages/card/README.md @@ -54,6 +54,8 @@ | price | 商品价格 | `String | Number` | - | | centered | 内容是否垂直居中 | `String` | `false` | | currency | 货币符号 | `String` | `¥` | +| thumb-link | 点击左侧图片后的跳转链接 | `String` | - | +| link-type | 链接跳转类型,可选值为 `redirectTo` `switchTab` `reLaunch` | `String` | `navigateTo` | ### Slot diff --git a/packages/card/index.less b/packages/card/index.less index 4883c804..87ccc99f 100644 --- a/packages/card/index.less +++ b/packages/card/index.less @@ -3,7 +3,7 @@ .van-card { color: @text-color; height: 100px; - font-size: 16px; + font-size: 12px; background: #fafafa; position: relative; box-sizing: border-box; @@ -55,9 +55,8 @@ } &__desc { - color: @gray-darker; - font-size: 12px; max-height: 20px; + color: @gray-darker; } &__price, @@ -68,13 +67,14 @@ text-align: right; } - &__price { - font-size: 14px; - } - &__num { color: @gray-darker; - font-size: 12px; + } + + &__tag { + position: absolute; + top: 2px; + left: 0; } &__tag { diff --git a/packages/card/index.ts b/packages/card/index.ts index 39ca597b..09edba20 100644 --- a/packages/card/index.ts +++ b/packages/card/index.ts @@ -17,9 +17,23 @@ VantComponent({ title: String, price: String, centered: Boolean, + thumbLink: String, + linkType: { + type: String, + value: 'navigateTo' + }, currency: { type: String, value: '¥' } + }, + + methods: { + onClickThumb() { + const { thumbLink } = this.data; + if (thumbLink) { + wx[this.data.linkType]({ url: thumbLink }); + } + } } }); diff --git a/packages/card/index.wxml b/packages/card/index.wxml index 0e0d6611..d7dba72c 100644 --- a/packages/card/index.wxml +++ b/packages/card/index.wxml @@ -1,5 +1,5 @@ - +