mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Coupon): support custom valid period (#8679)
* 优惠券组件有效时间支持毫秒及自定义 * fix: customValidPeriod * fix: 兼容字符串时间戳 Co-authored-by: ming <w_chenjiaming@youzan.com>
This commit is contained in:
parent
9abae5fbe6
commit
dd4a637a0d
@ -119,13 +119,14 @@ export default {
|
|||||||
| id | Id | _string_ |
|
| id | Id | _string_ |
|
||||||
| name | Name | _string_ |
|
| name | Name | _string_ |
|
||||||
| condition | Condition | _string_ |
|
| condition | Condition | _string_ |
|
||||||
| startAt | Start time (Timestmap, unit second) | _number_ |
|
| startAt | Start time (Timestmap, unit millisecond) | _number_ |
|
||||||
| endAt | End time (Timestmap, unit second) | _number_ |
|
| endAt | End time (Timestmap, unit millisecond) | _number_ |
|
||||||
| description | Description | _string_ |
|
| description | Description | _string_ |
|
||||||
| reason | Unavailable reason | _string_ |
|
| reason | Unavailable reason | _string_ |
|
||||||
| value | Value | _number_ |
|
| value | Value | _number_ |
|
||||||
| valueDesc | Value Text | _string_ |
|
| valueDesc | Value Text | _string_ |
|
||||||
| unitDesc | Unit Text | _string_ |
|
| unitDesc | Unit Text | _string_ |
|
||||||
|
| customValidPeriod | custom valid period | _string_ |
|
||||||
|
|
||||||
### Less Variables
|
### Less Variables
|
||||||
|
|
||||||
|
@ -121,13 +121,14 @@ export default {
|
|||||||
| id | 优惠券 id | _string_ |
|
| id | 优惠券 id | _string_ |
|
||||||
| name | 优惠券名称 | _string_ |
|
| name | 优惠券名称 | _string_ |
|
||||||
| condition | 满减条件 | _string_ |
|
| condition | 满减条件 | _string_ |
|
||||||
| startAt | 卡有效开始时间 (时间戳, 单位秒) | _number_ |
|
| startAt | 卡有效开始时间 (时间戳, 单位毫秒) | _number_ |
|
||||||
| endAt | 卡失效日期 (时间戳, 单位秒) | _number_ |
|
| endAt | 卡失效日期 (时间戳, 单位毫秒) | _number_ |
|
||||||
| description | 描述信息,优惠券可用时展示 | _string_ |
|
| description | 描述信息,优惠券可用时展示 | _string_ |
|
||||||
| reason | 不可用原因,优惠券不可用时展示 | _string_ |
|
| reason | 不可用原因,优惠券不可用时展示 | _string_ |
|
||||||
| value | 折扣券优惠金额,单位分 | _number_ |
|
| value | 折扣券优惠金额,单位分 | _number_ |
|
||||||
| valueDesc | 折扣券优惠金额文案 | _string_ |
|
| valueDesc | 折扣券优惠金额文案 | _string_ |
|
||||||
| unitDesc | 单位文案 | _string_ |
|
| unitDesc | 单位文案 | _string_ |
|
||||||
|
| customValidPeriod | 自定义有效时间文案 | _string_ |
|
||||||
|
|
||||||
### 样式变量
|
### 样式变量
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ export default {
|
|||||||
description: this.t('coupon.description'),
|
description: this.t('coupon.description'),
|
||||||
startAt: 1489104000,
|
startAt: 1489104000,
|
||||||
endAt: 1514592000,
|
endAt: 1514592000,
|
||||||
|
customValidPeriod: '周日 13点起生效',
|
||||||
valueDesc: '1.5',
|
valueDesc: '1.5',
|
||||||
unitDesc: '元',
|
unitDesc: '元',
|
||||||
};
|
};
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import { createNamespace } from '../utils';
|
import { createNamespace } from '../utils';
|
||||||
import { RED } from '../utils/constant';
|
import { RED } from '../utils/constant';
|
||||||
import { padZero } from '../utils/format/string';
|
import { dateToString } from '../sku/utils/time-helper';
|
||||||
import Checkbox from '../checkbox';
|
import Checkbox from '../checkbox';
|
||||||
|
|
||||||
const [createComponent, bem, t] = createNamespace('coupon');
|
const [createComponent, bem, t] = createNamespace('coupon');
|
||||||
|
|
||||||
function getDate(timeStamp) {
|
function getDate(timeStamp) {
|
||||||
const date = new Date(timeStamp * 1000);
|
if (timeStamp >= 1000000000000) {
|
||||||
return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
|
return dateToString(new Date(timeStamp * 1), 'datetime');
|
||||||
date.getDate()
|
}
|
||||||
)}`;
|
return dateToString(new Date(timeStamp * 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDiscount(discount) {
|
function formatDiscount(discount) {
|
||||||
@ -35,8 +35,8 @@ export default createComponent({
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
validPeriod() {
|
validPeriod() {
|
||||||
const { startAt, endAt } = this.coupon;
|
const { startAt, endAt, customValidPeriod } = this.coupon;
|
||||||
return `${getDate(startAt)} - ${getDate(endAt)}`;
|
return customValidPeriod ? customValidPeriod : `${getDate(startAt)} - ${getDate(endAt)}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
faceAmount() {
|
faceAmount() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user