mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 10:20:19 +08:00
chore(CouponList): fix snapshot (#8680)
* chore(CouponList): fix snapshot * docs: upd
This commit is contained in:
parent
dd4a637a0d
commit
999017d067
@ -76,12 +76,12 @@ export default {
|
|||||||
### CouponCell Props
|
### CouponCell Props
|
||||||
|
|
||||||
| Attribute | Description | Type | Default |
|
| Attribute | Description | Type | Default |
|
||||||
| --- | --- | --- | --- |
|
| ------------- | ---------------------------- | ------------------ | -------- |
|
||||||
| title | Cell title | _string_ | `Coupon` |
|
| title | Cell title | _string_ | `Coupon` |
|
||||||
| chosen-coupon | Index of chosen coupon | _number \| string_ | `-1` |
|
| chosen-coupon | Index of chosen coupon | _number \| string_ | `-1` |
|
||||||
| coupons | Coupon list | _Coupon[]_ | `[]` |
|
| coupons | Coupon list | _Coupon[]_ | `[]` |
|
||||||
| editable | Cell editable | _boolean_ | `true` |
|
| editable | Cell editable | _boolean_ | `true` |
|
||||||
| border | Whether to show innner border | _boolean_ | `true` |
|
| border | Whether to show inner border | _boolean_ | `true` |
|
||||||
| currency | Currency symbol | _string_ | `¥` |
|
| currency | Currency symbol | _string_ | `¥` |
|
||||||
|
|
||||||
### CouponList Props
|
### CouponList Props
|
||||||
@ -115,12 +115,12 @@ export default {
|
|||||||
### Data Structure of Coupon
|
### Data Structure of Coupon
|
||||||
|
|
||||||
| Key | Description | Type |
|
| Key | Description | Type |
|
||||||
| ----------- | ----------------------------------- | -------- |
|
| ----------------- | ---------------------------------------- | -------- |
|
||||||
| id | Id | _string_ |
|
| id | Id | _string_ |
|
||||||
| name | Name | _string_ |
|
| name | Name | _string_ |
|
||||||
| condition | Condition | _string_ |
|
| condition | Condition | _string_ |
|
||||||
| startAt | Start time (Timestmap, unit millisecond) | _number_ |
|
| startAt | Start time (Timestamp, unit millisecond) | _number_ |
|
||||||
| endAt | End time (Timestmap, unit millisecond) | _number_ |
|
| endAt | End time (Timestamp, unit millisecond) | _number_ |
|
||||||
| description | Description | _string_ |
|
| description | Description | _string_ |
|
||||||
| reason | Unavailable reason | _string_ |
|
| reason | Unavailable reason | _string_ |
|
||||||
| value | Value | _number_ |
|
| value | Value | _number_ |
|
||||||
|
@ -117,7 +117,7 @@ export default {
|
|||||||
### Coupon 数据结构
|
### Coupon 数据结构
|
||||||
|
|
||||||
| 键名 | 说明 | 类型 |
|
| 键名 | 说明 | 类型 |
|
||||||
| ----------- | ------------------------------- | -------- |
|
| ----------------- | --------------------------------- | -------- |
|
||||||
| id | 优惠券 id | _string_ |
|
| id | 优惠券 id | _string_ |
|
||||||
| name | 优惠券名称 | _string_ |
|
| name | 优惠券名称 | _string_ |
|
||||||
| condition | 满减条件 | _string_ |
|
| condition | 满减条件 | _string_ |
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
v-model="showList"
|
v-model="showList"
|
||||||
round
|
round
|
||||||
position="bottom"
|
position="bottom"
|
||||||
style="height: 90%; padding-top: 4px;"
|
style="height: 90%; padding-top: 4px"
|
||||||
>
|
>
|
||||||
<van-coupon-list
|
<van-coupon-list
|
||||||
:coupons="coupons"
|
:coupons="coupons"
|
||||||
@ -74,7 +74,6 @@ 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,23 @@
|
|||||||
import { createNamespace } from '../utils';
|
import { createNamespace } from '../utils';
|
||||||
import { RED } from '../utils/constant';
|
import { RED } from '../utils/constant';
|
||||||
import { dateToString } from '../sku/utils/time-helper';
|
import { padZero } from '../utils/format/string';
|
||||||
import Checkbox from '../checkbox';
|
import Checkbox from '../checkbox';
|
||||||
|
|
||||||
const [createComponent, bem, t] = createNamespace('coupon');
|
const [createComponent, bem, t] = createNamespace('coupon');
|
||||||
|
|
||||||
function getDate(timeStamp) {
|
function formatTimeStamp(timeStamp) {
|
||||||
if (timeStamp >= 1000000000000) {
|
// compatible when the timestamp is seconds
|
||||||
return dateToString(new Date(timeStamp * 1), 'datetime');
|
if (timeStamp < 10 ** 12) {
|
||||||
|
return timeStamp * 1000;
|
||||||
}
|
}
|
||||||
return dateToString(new Date(timeStamp * 1000));
|
return timeStamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDate(timeStamp) {
|
||||||
|
const date = new Date(formatTimeStamp(timeStamp));
|
||||||
|
return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
|
||||||
|
date.getDate()
|
||||||
|
)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDiscount(discount) {
|
function formatDiscount(discount) {
|
||||||
@ -36,7 +44,7 @@ export default createComponent({
|
|||||||
computed: {
|
computed: {
|
||||||
validPeriod() {
|
validPeriod() {
|
||||||
const { startAt, endAt, customValidPeriod } = this.coupon;
|
const { startAt, endAt, customValidPeriod } = this.coupon;
|
||||||
return customValidPeriod ? customValidPeriod : `${getDate(startAt)} - ${getDate(endAt)}`;
|
return customValidPeriod || `${getDate(startAt)} - ${getDate(endAt)}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
faceAmount() {
|
faceAmount() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user