123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- // 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
- })
- }
- },
- /**
- * 组件的属性列表
- */
- properties: {
- },
- /**
- * 组件的初始数据
- */
- data: {
- beginDate: '2000-01-01',
- endDate: '2021-02-02',
- initDate:'2000-01-01',
- lastDate:'',
- yFlag: false,
- animationBox: {},
- animationBg: {},
- },
- /**
- * 组件的方法列表
- */
- 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',
- })
- this.animation = animation
- var num = 0
- var opacity = 0
- if(this.data.yFlag == false){
- num = 180
- opacity = 0.4
- this.setData({
- yFlag: true
- })
- } else {
- num = -360
- opacity = 0
- this.setData({
- yFlag: false
- })
- }
- animation.translateY(num).step()
- this.setData({
- animationBox:animation.export()
- })
-
- var animation2 = wx.createAnimation({
- timingFunction: 'linear',
- })
- this.animation2 = animation2
-
- animation2.opacity(opacity).step()
- this.setData({
- animationBg:animation2.export()
- })
-
- },
- }
- })
|