From 012fd851c1320f1eab31b39ae6ed85d14e008f95 Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 23 Jul 2019 20:20:57 +0800 Subject: [PATCH] [new feature] CouponList: add empty-image prop (#3941) --- src/coupon-list/README.md | 1 + src/coupon-list/README.zh-CN.md | 3 +- src/coupon-list/index.js | 6 +++- .../test/__snapshots__/index.spec.js.snap | 33 +++++++++++++++++++ src/coupon-list/test/index.spec.js | 10 ++++++ 5 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/coupon-list/README.md b/src/coupon-list/README.md index 3ab2db0d4..6055ec978 100644 --- a/src/coupon-list/README.md +++ b/src/coupon-list/README.md @@ -97,6 +97,7 @@ export default { | close-button-text | Close button text | `string` | `Close` | | input-placeholder | Input placeholder | `string` | `Coupon code` | | currency | Currency symbol | `string` | `¥` | +| empty-image | Placeholder image when list is empty | `string` | `https://img.yzcdn.cn/vant/coupon-empty.png` | ### CouponList Events diff --git a/src/coupon-list/README.zh-CN.md b/src/coupon-list/README.zh-CN.md index 289419cdd..af6a80a90 100644 --- a/src/coupon-list/README.zh-CN.md +++ b/src/coupon-list/README.zh-CN.md @@ -98,7 +98,8 @@ export default { | close-button-text | 列表底部按钮文字 | `string` | `不使用优惠` | - | | input-placeholder | 输入框文字提示 | `string` | `请输入优惠码` | - | | show-exchange-bar | 是否展示兑换栏 | `boolean` | `true` | - | -| currency | 货币符号 | `string` | `¥` | - | 1.5.0 | +| currency | 货币符号 | `string` | `¥` | 1.5.0 | +| empty-image | 列表为空时的占位图 | `string` | `https://img.yzcdn.cn/vant/coupon-empty.png` | 2.1.0 | ### CouponList Events diff --git a/src/coupon-list/index.js b/src/coupon-list/index.js index a97b4bf9c..beb94fba7 100644 --- a/src/coupon-list/index.js +++ b/src/coupon-list/index.js @@ -53,6 +53,10 @@ export default createComponent({ currency: { type: String, default: '¥' + }, + emptyImage: { + type: String, + default: EMPTY_IMAGE } }, @@ -128,7 +132,7 @@ export default createComponent({ renderEmpty() { return (
- +

{t('empty')}

); diff --git a/src/coupon-list/test/__snapshots__/index.spec.js.snap b/src/coupon-list/test/__snapshots__/index.spec.js.snap index 7545b2ae3..c0150e266 100644 --- a/src/coupon-list/test/__snapshots__/index.spec.js.snap +++ b/src/coupon-list/test/__snapshots__/index.spec.js.snap @@ -1,5 +1,38 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`empty-image prop 1`] = ` +
+
+
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+

暂无优惠券

+
+
+
+ +
+
+
+`; + exports[`render coupon cell 1`] = `
优惠券
diff --git a/src/coupon-list/test/index.spec.js b/src/coupon-list/test/index.spec.js index 633b240fa..4b19b3253 100644 --- a/src/coupon-list/test/index.spec.js +++ b/src/coupon-list/test/index.spec.js @@ -102,6 +102,16 @@ test('render empty coupon list', () => { expect(wrapper).toMatchSnapshot(); }); +test('empty-image prop', () => { + const wrapper = mount(CouponList, { + propsData: { + emptyImage: 'https://img.yzcdn.com/xxx.png' + } + }); + + expect(wrapper).toMatchSnapshot(); +}); + test('exchange coupon', () => { const wrapper = mount(CouponList); const exchange = wrapper.find('.van-coupon-list__exchange');