|
@@ -1,5 +1,8 @@
|
|
|
// pages/test/index.js
|
|
|
const app = getApp()
|
|
|
+import dateTimePicker from '../../utils/dateTimePicker';
|
|
|
+const moment = require("../../utils/moment.min");
|
|
|
+
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -13,6 +16,20 @@ Page({
|
|
|
img_url: [],
|
|
|
// dialog弹框
|
|
|
dialog: { title: '弹框标题', show: false, type: '1' },
|
|
|
+ // 日期时间选择
|
|
|
+ dateTimeArray: [
|
|
|
+ ['2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010'],
|
|
|
+ ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'],
|
|
|
+ ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'],
|
|
|
+ ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'],
|
|
|
+ ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59'],
|
|
|
+ ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59'],
|
|
|
+ ],
|
|
|
+ // 日期时间选择
|
|
|
+ datatime: '',
|
|
|
+ // 计算日期
|
|
|
+ year: '',
|
|
|
+ moneh: ''
|
|
|
},
|
|
|
// 跳转菜单
|
|
|
tabPath(e) {
|
|
@@ -47,11 +64,70 @@ Page({
|
|
|
const that = this;
|
|
|
that.setData({ dialog: { title: '弹框标题', show: false, type: '1' } })
|
|
|
},
|
|
|
-
|
|
|
+ // 确认选择
|
|
|
+ change: function (e) {
|
|
|
+ const that = this;
|
|
|
+ let dateTime = that.data.dateTimeArray;
|
|
|
+ let value = e.detail.value;
|
|
|
+ let datetimes = dateTime[0][value[0]] + '-' + dateTime[1][value[1]] + '-' + dateTime[2][value[2]] + ' ' + dateTime[3][value[3]] + ':' + dateTime[4][value[4]] + ':' + dateTime[5][value[5]];
|
|
|
+ that.setData({ datatime: datetimes });
|
|
|
+ },
|
|
|
+ // 选择月份
|
|
|
+ columnChange: function (e) {
|
|
|
+ const that = this;
|
|
|
+ const { column, value } = e.detail;
|
|
|
+ let dateTimeArray = that.data.dateTimeArray;
|
|
|
+ let year = that.data.year;
|
|
|
+ let month = that.data.month;
|
|
|
+
|
|
|
+ // let year = monthDay.year || dateTimeArray[0][0];
|
|
|
+ // let month = monthDay.month || dateTimeArray[1][0];
|
|
|
+ // if (column == '0') year = dateTimeArray[0][value];
|
|
|
+ // else if (column == '1') month = dateTimeArray[1][value];
|
|
|
+ // console.log(year);
|
|
|
+ // console.log(month);
|
|
|
+ // that.setData({ monthDay: { year: year, moneh: month } });
|
|
|
+ // console.log(that.data.monthDay);
|
|
|
+ // 计算当前选择年月所要显示的日期
|
|
|
+ let ym = year + '-' + month;
|
|
|
+ // let monthDay = moment(ym).daysInMonth();
|
|
|
+ // console.log(monthDay);
|
|
|
+ // if (column == '0') {
|
|
|
+ // console.log(column, value);
|
|
|
+ // } else if (column == '1') {
|
|
|
+ // monthDay = dateTimeArray
|
|
|
+ // }
|
|
|
+ // that.setData({ monthDay })
|
|
|
+ // console.log(that.data.monthDay);
|
|
|
+ // console.log(data);
|
|
|
+ // if (column == '0') {
|
|
|
+ // console.log('0');
|
|
|
+ // } else if (column == '1') {
|
|
|
+ // console.log('1');
|
|
|
+ // }
|
|
|
+ // console.log(column);
|
|
|
+ // console.log(value);
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad: function (options) { },
|
|
|
+ onLoad: async function (options) {
|
|
|
+ // 获取完整的年月日 时分秒,以及默认显示的数组
|
|
|
+ var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
|
|
|
+ var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
|
|
|
+ // this.setData({ dateTimeArray: obj.dateTimeArray });
|
|
|
+ // let start = moment('02').startOf('month').format('YYYY-MM-DD');
|
|
|
+ // let end = moment('02').endOf('month').format('YYYY-MM-DD');
|
|
|
+ // 01,03,05,07,08,10
|
|
|
+ // 02
|
|
|
+ // let days = moment('2001-02').daysInMonth();
|
|
|
+ // console.log(start);
|
|
|
+ // console.log(end);
|
|
|
+ // console.log(days);
|
|
|
+ const arr = await app.$get('/user', {}, 'race');
|
|
|
+ console.log(arr);
|
|
|
+
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|