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.7 KiB

import moment from "moment"
const app = getApp()
Component({
data: {
timelist: [],
sStartTime: '',
sEndTime: '',
sTimeType: '34',
intervalSel: 0,
},
lifetimes: {
attached() {
this.getData().then(() => {
let st = wx.getStorageSync('sTimeType') || ''
if (st) {
let n = this.data.timelist.findIndex(ele => ele.key == st);
this.setData({
intervalSel: n
})
} else {
wx.setStorageSync('sTimeType', 34);
wx.setStorageSync('sStartTime', '');
wx.setStorageSync('sEndTime', '');
}
})
}
},
methods: {
getData() {
return new Promise((resolve, reject) => {
app.globalData.request({
action: "getTime"
}).then(res => {
let arr = res || [];
this.setData({
timelist: arr
})
resolve(true)
})
})
},
priceSel(e) {
let row = e.currentTarget.dataset.row;
let n = this.data.timelist.findIndex(ele => ele.key == row.key);
this.setData({
intervalSel: n
})
wx.setStorageSync('sTimeType', row.key);
let start = "";
let end = "";
this.triggerEvent('change', {
sTimeType: row.key,
sStartTime: start,
sEndTime: end
})
}
}
})