1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

api接口baseUrl通过全局变量引入;代码格式化

This commit is contained in:
2022-11-05 16:45:52 +08:00
parent 3e0c182bc9
commit 5cf1ed3a49
22 changed files with 477 additions and 406 deletions

View File

@@ -1,8 +1,11 @@
// pages/home/code.js
const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
var util = require('../../utils/util.js');
Page({
data: {
imgUrl:'../../img/code.jpg',
imgUrl: '../../img/code.jpg',
stuId: '',
name: wx.getStorageSync('name'),
isHealth: 0,
@@ -12,11 +15,11 @@ Page({
*/
onLoad: function (options) {
this.setData({
stuId : wx.getStorageSync('stuId'),
name : wx.getStorageSync('name')
stuId: wx.getStorageSync('stuId'),
name: wx.getStorageSync('name')
})
this.onShow()
},
/**
@@ -31,43 +34,43 @@ Page({
*/
onShow: function () {
this.setData({
stuId : wx.getStorageSync('stuId'),
name : wx.getStorageSync('name')
stuId: wx.getStorageSync('stuId'),
name: wx.getStorageSync('name')
})
setInterval(() => {
var time = util.formatTime(new Date())
//为页面中time赋值
this.setData({
time: time
})
}, 1000);
if(wx.getStorageSync("state") == this.formatDate(new Date())){
//为页面中time赋值
this.setData({
isHealth:1
time: time
})
}else{
}, 1000);
if (wx.getStorageSync("state") == this.formatDate(new Date())) {
this.setData({
isHealth:0
isHealth: 1
})
} else {
this.setData({
isHealth: 0
})
}
wx.request({
url: 'http://127.0.0.1:8080/code/showCode',
url: `${baseUrl}/code/showCode`,
data: {
stuId:this.data.stuId,
name:this.data.name,
stuId: this.data.stuId,
name: this.data.name,
isHealth: this.data.isHealth
},
success: function (d) {}
})
},
formatDate: function(date) {
formatDate: function (date) {
let year = date.getFullYear()
let month = date.getMonth() + 1
month = month.toString()
month[1] ? month=month :month='0' + month
month[1] ? month = month : month = '0' + month
let day = date.getDate()
day = day.toString()
day[1] ? day=day : day='0' + day
return year+"-"+month+"-"+day
},
})
day[1] ? day = day : day = '0' + day
return year + "-" + month + "-" + day
},
})