123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- // 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() : date.getDate()
- this.setData({
- endDate: year + '-' + month + '-' + day,
- lastDate: year + '-' + month + '-' + day
- })
- }
- },
- /**
- * 组件的属性列表
- */
- properties: {
- beginDate: {
- type: String
- },
- endDate: {
- type: String
- },
- typeFlag:{
- type:Boolean,
- default: false
- },
- toTop:{
- type:Number,
- value: -360
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- beginDate: '2020-01-01',
- endDate: '2021-02-02',
- initDate: '2020-01-01',
- lastDate: '',
- yFlag: false,
- animationBox: {},
- animationBg: {},
- typeArr:['全部','已预约','排队中'],
- typeIndex: 0,
- str:{}
- },
- /**
- * 组件的方法列表
- */
- 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,
- typeIndex: 0
- })
- const date = new Date()
- const dateArr = [date.getFullYear()+"-01"+"-01", 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 = Math.abs(this.data.toTop) / 2 + 30
- opacity = 0.4
- this.setData({
- yFlag: true
- })
- } else {
- num = this.data.toTop
- 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()
- })
- },
- bindPickerChange:function(e){
- const typeIndex = e.detail.value
- const name = this.data.typeArr[typeIndex]
- const str = {
- typeIndex,
- name
- }
- this.setData({
- str,
- typeIndex
- })
- // this.triggerEvent("changeType",str)
- },
- }
- })
|