纸通宝小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

58 lines
1.5 KiB

// components/factory-picker/index.js
const util = require('../../utils/util')
Component({
options: {
addGlobalClass: true,
},
properties: {
day:{
type: Number,
value: 3
}
},
/**
* 页面的初始数据
*/
data: {
modalName: null,
timeList: [],
timePeriods: [
{ value: 1, text: '8:00~10:00' },
{ value: 2, text: '10:00~12:00' },
{ value: 3, text: '12:00~14:00' },
{ value: 4, text: '14:00~16:00' },
{ value: 5, text: '16:00~18:00' },
{ value: 6, text: '18:00~20:00' }
],
value: [0, 0]
},
attached: function () {
// 在组件实例进入页面节点树时执行
var day = new Date()
for (let i = 0; i < this.data.day; i++) {
day.setDate(day.getDate() + (i > 1 ? 1 : i))
this.data.timeList.push({ value: (i + 1), text: util.formatDate(day, 'Y-M-D') })
}
this.setData({ timeList: this.data.timeList })
},
methods: {
showPicker: function () {
this.setData({ modalName: 'bottomModal' })
},
onDateChange: function (e) {
this.setData({ value: e.detail.value})
},
hideModal: function(){
this.setData({ modalName: null })
this.triggerEvent('customevent', null)
},
confrimModal: function () {
this.setData({ modalName: null })
var date = this.data.timeList[this.data.value[0]]
var time = this.data.timePeriods[this.data.value[1]]
this.triggerEvent('customevent', [date, time])
}
}
})