// 查寻签到状态 this.data.last_sign = 从数据库获取到的上次签到时间
data: {
qiand: "签到",
}
types(){
console.log(this.data.last_sign);
const date = new Date()
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
let times = year +'-'+ month +'-'+ day
// 获取到当前时间
console.log(times);
this.setData({
time: times,
})
if (this.data.last_sign == times) {
this.setData({
qiand: "已签到",
})
}
},
点击判断上次签到时间等不等于当前时间
// 点击签到
sign(){
if (this.data.last_sign == this.data.time) {
console.log("已签到");
return false
} else {
const that = this
require_my.my_request({
url: app.globalData.url + 'api/day_sign/',
data:{
id: app.globalData.ids
},
})
.then(value => {
console.log(value);
that.setData({
qiand: "已签到",
})
wx.showModal({
title: '签到成功',
content: value.data.message,
success (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
})
.catch(seaon => {
wx.showModal({
title: '签到失败',
content: '请重新签到',
success (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
})
}
},
注意: 日期要看后台传过来的日期 , 查看小于10时前面要不要加0
request 封装函数 查看 //www.greatytc.com/p/989caa15b668