onShow:{
this.check()
}
methods:{
check() {
this.lesect = uni.getStorageSync('lock') || []
console.log(this.lesect)
let workT = new Date().getDate()
console.log(workT);
this.lesect.forEach((item, index) => {
this.array.forEach((value, i) => {
if (item.time == workT && item.code == value.value) {
value.flag = true
} else {
}
})
})
console.log(this.array)
this.$forceUpdate()
},
//提交按钮
Add(code){
let obj = {
time: new Date().getDate(),
code: code,
flag: true
}
let arrp = uni.getStorageSync('lock') || []
if (arrp.length == 4) {
arrp.forEach((item, index) => {
if (item.code == code && item.time != new Date().getDate()) {
item.time = new Date().getDate()
}
})
} else {
let id = arrp.findIndex((item) => {
return item.code == code
})
if (id == -1) {
arrp.push(obj)
} else {
arrp.forEach((item, index) => {
if (item.code == code && item.time != new Date().getDate()) {
item.time = new Date().getDate()
}
})
}
uni.setStorageSync('lock', arrp)
}
this.check()
}
}