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.
100 lines
2.4 KiB
100 lines
2.4 KiB
2 years ago
|
// logs.ts
|
||
|
// const util = require('../../utils/util.js')
|
||
|
import { formatTime } from '../../utils/util'
|
||
|
|
||
|
Page({
|
||
|
data: {
|
||
|
logs: [],
|
||
|
taskList: [],
|
||
|
taskFlag: false,
|
||
|
releaseFlag: false,
|
||
|
from: {
|
||
|
taskName: "",
|
||
|
end: ""
|
||
|
}
|
||
|
},
|
||
|
inputFrom(event: any) {
|
||
|
if (event.currentTarget.dataset.gater == "from.end") {
|
||
|
let num = event.detail.value;
|
||
|
if (num.length == 4) num += "-";
|
||
|
if (num.length == 7) num += "-";
|
||
|
this.setData({ [`from.end`]: num })
|
||
|
} else if(event.currentTarget.dataset.gater == "from.taskName"){
|
||
|
this.setData({
|
||
|
[`${event.currentTarget.dataset.gater}`]: event.detail.value
|
||
|
})
|
||
|
}else{
|
||
|
this.setData({
|
||
|
[`${event.currentTarget.dataset.gater}`]: event.detail.value
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
addSelect() {
|
||
|
const { taskName, end } = this.data.from;
|
||
|
if (end.length != 10) return;
|
||
|
if (!taskName || !end) {
|
||
|
wx.showToast({
|
||
|
title: "请填写任务名称和任务进度",
|
||
|
icon: 'error',
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
const list = wx.getStorageSync("taskList") || [];
|
||
|
const index = list.findIndex((item: any) => item.title == taskName);
|
||
|
if (index >= 0) {
|
||
|
wx.showToast({
|
||
|
title: "任务名称重复",
|
||
|
icon: 'error',
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
const data = {
|
||
|
id: list.length + 1,
|
||
|
title: taskName,
|
||
|
startTime: formatTime(new Date), endTime: end, end: '40',
|
||
|
}
|
||
|
list.push(data)
|
||
|
wx.setStorageSync("taskList", list);
|
||
|
wx.showToast({
|
||
|
title: "发布成功",
|
||
|
icon: 'success',
|
||
|
});
|
||
|
this.setData({
|
||
|
taskList: wx.getStorageSync("taskList") || []
|
||
|
});
|
||
|
},
|
||
|
atReleaseFlag() {
|
||
|
const user = wx.getStorageSync("userInfo");
|
||
|
console.log(user)
|
||
|
if (user!=null) {
|
||
|
wx.showToast({
|
||
|
title: "请先登录",
|
||
|
icon: 'error',
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
this.setData({ releaseFlag: !this.data.releaseFlag })
|
||
|
},
|
||
|
atTaskFlag() {
|
||
|
this.setData({ taskFlag: !this.data.taskFlag })
|
||
|
},
|
||
|
onShow() {
|
||
|
this.setData({
|
||
|
taskList: wx.getStorageSync("taskList") || []
|
||
|
});
|
||
|
},
|
||
|
onLoad() {
|
||
|
this.setData({
|
||
|
taskList: wx.getStorageSync("taskList") || []
|
||
|
});
|
||
|
// this.setData({
|
||
|
// logs: (wx.getStorageSync('logs') || []).map((log: string) => {
|
||
|
// return {
|
||
|
// date: formatTime(new Date(log)),
|
||
|
// timeStamp: log
|
||
|
// }
|
||
|
// }),
|
||
|
// })
|
||
|
},
|
||
|
})
|