chore(CouponList): fix snapshot (#8680)

* chore(CouponList): fix snapshot

* docs: upd
This commit is contained in:
neverland 2021-05-08 18:26:59 +08:00 committed by GitHub
parent dd4a637a0d
commit 999017d067
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 42 deletions

View File

@ -76,12 +76,12 @@ export default {
### CouponCell Props
| Attribute | Description | Type | Default |
| --- | --- | --- | --- |
| ------------- | ---------------------------- | ------------------ | -------- |
| title | Cell title | _string_ | `Coupon` |
| chosen-coupon | Index of chosen coupon | _number \| string_ | `-1` |
| coupons | Coupon list | _Coupon[]_ | `[]` |
| 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_ | `¥` |
### CouponList Props
@ -115,12 +115,12 @@ export default {
### Data Structure of Coupon
| Key | Description | Type |
| ----------- | ----------------------------------- | -------- |
| ----------------- | ---------------------------------------- | -------- |
| id | Id | _string_ |
| name | Name | _string_ |
| condition | Condition | _string_ |
| startAt | Start time (Timestmap, unit millisecond) | _number_ |
| endAt | End time (Timestmap, unit millisecond) | _number_ |
| startAt | Start time (Timestamp, unit millisecond) | _number_ |
| endAt | End time (Timestamp, unit millisecond) | _number_ |
| description | Description | _string_ |
| reason | Unavailable reason | _string_ |
| value | Value | _number_ |

View File

@ -117,7 +117,7 @@ export default {
### Coupon 数据结构
| 键名 | 说明 | 类型 |
| ----------- | ------------------------------- | -------- |
| ----------------- | --------------------------------- | -------- |
| id | 优惠券 id | _string_ |
| name | 优惠券名称 | _string_ |
| condition | 满减条件 | _string_ |

View File

@ -11,7 +11,7 @@
v-model="showList"
round
position="bottom"
style="height: 90%; padding-top: 4px;"
style="height: 90%; padding-top: 4px"
>
<van-coupon-list
:coupons="coupons"
@ -74,7 +74,6 @@ export default {
description: this.t('coupon.description'),
startAt: 1489104000,
endAt: 1514592000,
customValidPeriod: '周日 13点起生效',
valueDesc: '1.5',
unitDesc: '元',
};

View File

@ -1,15 +1,23 @@
import { createNamespace } from '../utils';
import { RED } from '../utils/constant';
import { dateToString } from '../sku/utils/time-helper';
import { padZero } from '../utils/format/string';
import Checkbox from '../checkbox';
const [createComponent, bem, t] = createNamespace('coupon');
function getDate(timeStamp) {
if (timeStamp >= 1000000000000) {
return dateToString(new Date(timeStamp * 1), 'datetime');
function formatTimeStamp(timeStamp) {
// compatible when the timestamp is seconds
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) {
@ -36,7 +44,7 @@ export default createComponent({
computed: {
validPeriod() {
const { startAt, endAt, customValidPeriod } = this.coupon;
return customValidPeriod ? customValidPeriod : `${getDate(startAt)} - ${getDate(endAt)}`;
return customValidPeriod || `${getDate(startAt)} - ${getDate(endAt)}`;
},
faceAmount() {