diff --git a/components.js b/components.js index f9ab4301a..dd814eeee 100644 --- a/components.js +++ b/components.js @@ -73,4 +73,7 @@ module.exports = [ 'contact-card', 'contact-edit', 'contact-list', + 'coupon', + 'coupon-list', + 'coupon-cell', ]; diff --git a/docs/markdown/changelog-v3.zh-CN.md b/docs/markdown/changelog-v3.zh-CN.md index 3ff963924..d151dda9b 100644 --- a/docs/markdown/changelog-v3.zh-CN.md +++ b/docs/markdown/changelog-v3.zh-CN.md @@ -66,6 +66,7 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。 其他改动: - Circle: `v-model` 重命名为 `v-model:currentRate` +- CouponList: `v-model` 重命名为 `v-model:code` - List: `v-model` 重命名为 `v-model:loading`,`error.sync` 重命名为 `v-model:error` - Tabs: `v-model` 重命名为 `v-model:active` - TreeSelect: `active-id.sync` 重命名为 `v-model:active-id` diff --git a/src/coupon-cell/index.tsx b/src/coupon-cell/index.tsx deleted file mode 100644 index f4d763ee7..000000000 --- a/src/coupon-cell/index.tsx +++ /dev/null @@ -1,88 +0,0 @@ -// Utils -import { createNamespace } from '../utils'; -import { inherit } from '../utils/functional'; - -// Components -import Cell from '../cell'; - -// Types -import { CreateElement, RenderContext } from 'vue/types'; -import { DefaultSlots } from '../utils/types'; -import { Coupon } from '../coupon/shared'; - -export type CouponCellProps = { - title?: string; - border: boolean; - coupons: Coupon[]; - currency: string; - editable: boolean; - chosenCoupon: number | string; -}; - -const [createComponent, bem, t] = createNamespace('coupon-cell'); - -function formatValue(props: CouponCellProps) { - const { coupons, chosenCoupon, currency } = props; - const coupon = coupons[+chosenCoupon]; - - if (coupon) { - const value = coupon.value || coupon.denominations || 0; - return `-${currency} ${(value / 100).toFixed(2)}`; - } - - return coupons.length === 0 ? t('tips') : t('count', coupons.length); -} - -function CouponCell( - h: CreateElement, - props: CouponCellProps, - slots: DefaultSlots, - ctx: RenderContext -) { - const valueClass = props.coupons[+props.chosenCoupon] - ? 'van-coupon-cell--selected' - : ''; - const value = formatValue(props); - - return ( - - ); -} - -CouponCell.model = { - prop: 'chosenCoupon', -}; - -CouponCell.props = { - title: String, - coupons: { - type: Array, - default: () => [], - }, - currency: { - type: String, - default: '¥', - }, - border: { - type: Boolean, - default: true, - }, - editable: { - type: Boolean, - default: true, - }, - chosenCoupon: { - type: [Number, String], - default: -1, - }, -}; - -export default createComponent(CouponCell); diff --git a/src/coupon-list/README.zh-CN.md b/src/coupon-list/README.zh-CN.md index 383eee5b1..fa00f6d24 100644 --- a/src/coupon-list/README.zh-CN.md +++ b/src/coupon-list/README.zh-CN.md @@ -88,7 +88,7 @@ export default { | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| v-model | 当前输入的兑换码 | _string_ | - | +| v-model:code | 当前输入的兑换码 | _string_ | - | | chosen-coupon | 当前选中优惠券的索引 | _number_ | `-1` | | coupons | 可用优惠券列表 | _Coupon[]_ | `[]` | | disabled-coupons | 不可用优惠券列表 | _Coupon[]_ | `[]` | diff --git a/src/coupon-list/demo/index.vue b/src/coupon-list/demo/index.vue index 7758b4021..d4dfb55ae 100644 --- a/src/coupon-list/demo/index.vue +++ b/src/coupon-list/demo/index.vue @@ -6,9 +6,8 @@ :chosen-coupon="chosenCoupon" @click="showList = true" /> - ))} {!coupons.length && this.genEmpty()} @@ -234,8 +232,8 @@ export default createComponent({