mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
40 lines
930 B
JavaScript
40 lines
930 B
JavaScript
import Page from '../../common/page';
|
|
import Toast from '../../dist/toast/toast';
|
|
|
|
Page({
|
|
data: {
|
|
minHour: 10,
|
|
maxHour: 20,
|
|
minDate: new Date(2018, 0, 1).getTime(),
|
|
maxDate: new Date(2019, 10, 1).getTime(),
|
|
currentDate1: new Date(2018, 2, 31).getTime(),
|
|
currentDate2: null,
|
|
currentDate3: new Date(2018, 0, 1),
|
|
currentDate4: '12:00',
|
|
loading: false
|
|
},
|
|
|
|
onInput(event) {
|
|
const { detail, currentTarget } = event;
|
|
const result = this.getResult(detail, currentTarget.dataset.type);
|
|
|
|
Toast(result);
|
|
},
|
|
|
|
getResult(time, type) {
|
|
const date = new Date(time);
|
|
switch (type) {
|
|
case 'datetime':
|
|
return date.toLocaleString();
|
|
case 'date':
|
|
return date.toLocaleDateString();
|
|
case 'year-month':
|
|
return `${date.getFullYear()}/${date.getMonth() + 1}`;
|
|
case 'time':
|
|
return time;
|
|
default:
|
|
return '';
|
|
}
|
|
}
|
|
});
|