1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
epp/miniprogram/pages/code/code.js

77 lines
1.6 KiB
JavaScript
Raw Normal View History

const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
2022-11-05 15:28:03 +08:00
var util = require('../../utils/util.js');
Page({
data: {
imgUrl: '../../img/code.jpg',
2022-11-05 15:28:03 +08:00
stuId: '',
name: wx.getStorageSync('name'),
isHealth: 0,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
stuId: wx.getStorageSync('stuId'),
name: wx.getStorageSync('name')
2022-11-05 15:28:03 +08:00
})
this.onShow()
2022-11-05 15:28:03 +08:00
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.setData({
stuId: wx.getStorageSync('stuId'),
name: wx.getStorageSync('name')
2022-11-05 15:28:03 +08:00
})
setInterval(() => {
var time = util.formatTime(new Date())
//为页面中time赋值
this.setData({
time: time
})
2022-11-05 15:28:03 +08:00
}, 1000);
if (wx.getStorageSync("state") == this.formatDate(new Date())) {
2022-11-05 15:28:03 +08:00
this.setData({
isHealth: 1
2022-11-05 15:28:03 +08:00
})
} else {
2022-11-05 15:28:03 +08:00
this.setData({
isHealth: 0
2022-11-05 15:28:03 +08:00
})
}
wx.request({
url: `${baseUrl}/code/showCode`,
2022-11-05 15:28:03 +08:00
data: {
stuId: this.data.stuId,
name: this.data.name,
2022-11-05 15:28:03 +08:00
isHealth: this.data.isHealth
},
success: function (d) {}
})
},
formatDate: function (date) {
2022-11-05 15:28:03 +08:00
let year = date.getFullYear()
let month = date.getMonth() + 1
month = month.toString()
month[1] ? month = month : month = '0' + month
2022-11-05 15:28:03 +08:00
let day = date.getDate()
day = day.toString()
day[1] ? day = day : day = '0' + day
return year + "-" + month + "-" + day
},
})