|
@@ -1,5 +1,17 @@
|
|
|
// pages/Components/selectDate/selectDate.js
|
|
|
Component({
|
|
|
+ lifetimes:{
|
|
|
+ attached:function(){
|
|
|
+ var date = new Date()
|
|
|
+ const year = date.getFullYear()
|
|
|
+ const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
|
|
|
+ const day = date.getDate() + 1 < 10 ? '0' + date.getDate() : data.getDate()
|
|
|
+ this.setData({
|
|
|
+ endDate: year + '-' + month + '-' + day,
|
|
|
+ lastDate: year + '-' + month + '-' + day
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
/**
|
|
|
* 组件的属性列表
|
|
|
*/
|
|
@@ -11,8 +23,10 @@ Component({
|
|
|
* 组件的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- beginDate: '2021-01-01',
|
|
|
+ beginDate: '2000-01-01',
|
|
|
endDate: '2021-02-02',
|
|
|
+ initDate:'2000-01-01',
|
|
|
+ lastDate:'',
|
|
|
yFlag: false,
|
|
|
animationBox: {},
|
|
|
animationBg: {},
|
|
@@ -22,6 +36,46 @@ Component({
|
|
|
* 组件的方法列表
|
|
|
*/
|
|
|
methods: {
|
|
|
+ bindBeginDateChange:function(e){
|
|
|
+ if(e.detail.value > this.data.endDate){
|
|
|
+ this.setData({
|
|
|
+ beginDate: this.data.endDate
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ beginDate: e.detail.value
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ bindEndDateChange:function(e){
|
|
|
+ if(e.detail.value > this.data.endDate){
|
|
|
+ this.setData({
|
|
|
+ endDate: this.data.lastDate
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ endDate: e.detail.value
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ resetDate:function(){
|
|
|
+ this.setData({
|
|
|
+ beginDate: this.data.initDate,
|
|
|
+ endDate: this.data.lastDate
|
|
|
+ })
|
|
|
+ const dateArr = [this.data.initDate,this.data.lastDate];
|
|
|
+ this.triggerEvent("getDates",dateArr);
|
|
|
+ this.showSelect()
|
|
|
+ },
|
|
|
+
|
|
|
+ submitDate:function(){
|
|
|
+ const dateArr = [this.data.beginDate,this.data.endDate];
|
|
|
+ this.triggerEvent("getDates",dateArr);
|
|
|
+ this.showSelect()
|
|
|
+ },
|
|
|
+
|
|
|
showSelect:function(){
|
|
|
var animation = wx.createAnimation({
|
|
|
timingFunction: 'linear',
|