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

@@ -17,7 +17,9 @@ App({
scope: 'scope', scope: 'scope',
}) })
}, },
// 全局变量
globalData: { globalData: {
baseUrl: "http://localhost:8080", // 不带最后的 /
userInfo: null userInfo: null
} }
}) })

View File

@@ -1,4 +1,7 @@
// pages/apply/apply.js const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
var dateTimePicker = require('./dateTimePicker.js'); var dateTimePicker = require('./dateTimePicker.js');
Page({ Page({
data: { data: {
@@ -95,7 +98,7 @@ Page({
apply: function () { apply: function () {
var data = this.data; var data = this.data;
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/apply/applySub', url: `${baseUrl}/apply/applySub`,
data: { data: {
stu_id: data.id, stu_id: data.id,
issue: data.issue, issue: data.issue,

View File

@@ -1,11 +1,13 @@
// pages/other/feedback.js const app = getApp()
Page({ const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
List:'', List: '',
replay: [], replay: [],
}, },
@@ -27,13 +29,13 @@ Page({
replay: e.detail.value replay: e.detail.value
}) })
}, },
agree:function (event) { agree: function (event) {
var that = this var that = this
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/apply/applyReplay', url: `${baseUrl}/apply/applyReplay`,
data: { data: {
id:event.target.dataset.id, id: event.target.dataset.id,
replay:event.target.dataset.replay, replay: event.target.dataset.replay,
reasonId: 99 reasonId: 99
}, },
success: function (d) { success: function (d) {
@@ -41,25 +43,24 @@ Page({
title: d.data.msg, title: d.data.msg,
icon: 'success', icon: 'success',
duration: 2000, duration: 2000,
success: function () { success: function () {}
}
}) })
that.onShow(); that.onShow();
} }
}) })
}, },
disagree:function (event) { disagree: function (event) {
var that = this var that = this
wx.showActionSheet({ wx.showActionSheet({
itemList: ['格式错误','出行地点不允许','时间填写错误'], itemList: ['格式错误', '出行地点不允许', '时间填写错误'],
success:function (res) { success: function (res) {
if(!res.cancel){ if (!res.cancel) {
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/apply/applyReplay', url: `${baseUrl}/apply/applyReplay`,
data: { data: {
id:event.target.dataset.id, id: event.target.dataset.id,
replay:event.target.dataset.replay, replay: event.target.dataset.replay,
reasonId:res.tapIndex, reasonId: res.tapIndex,
}, },
success: function (d) { success: function (d) {
wx.showToast({ wx.showToast({
@@ -82,7 +83,7 @@ Page({
onShow: function () { onShow: function () {
var that = this; var that = this;
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/apply/applyListNoReplay', url: `${baseUrl}/apply/applyListNoReplay`,
success: function (d) { success: function (d) {
that.setData({ that.setData({
List: d.data.data List: d.data.data
@@ -95,8 +96,7 @@ Page({
// var that = this // var that = this
// console.log(event.target.dataset) // console.log(event.target.dataset)
// wx.request({ // wx.request({
// url: 'http://127.0.0.1:8080/apply/applyListNoReplay', // url: `${baseUrl}/apply/applyListNoReplay`,
// }) // })
// }, // },
/** /**
@@ -133,4 +133,4 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
} }
}) })

View File

@@ -1,11 +1,14 @@
// pages/other/feedback.js const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
List:'', List: '',
replay: [], replay: [],
}, },
@@ -27,37 +30,37 @@ Page({
replay: e.detail.value replay: e.detail.value
}) })
}, },
agree:function (event) { agree: function (event) {
var that = this var that = this
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/apply/applyReplay', url: `${baseUrl}/apply/applyReplay`,
data: { data: {
id:event.target.dataset.id, id: event.target.dataset.id,
replay:event.target.dataset.replay, replay: event.target.dataset.replay,
reasonId: 99 reasonId: 99
}, },
success: function (d) { success: function (d) {
if(d.data.msg == "成功"){ if (d.data.msg == "成功") {
that.onshow(); that.onshow();
} }
} }
}) })
}, },
disagree:function (event) { disagree: function (event) {
var that = this var that = this
wx.showActionSheet({ wx.showActionSheet({
itemList: ['格式错误','出行地点不允许','时间填写错误'], itemList: ['格式错误', '出行地点不允许', '时间填写错误'],
success:function (res) { success: function (res) {
if(!res.cancel){ if (!res.cancel) {
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/apply/applyReplay', url: `${baseUrl}/apply/applyReplay`,
data: { data: {
id:event.target.dataset.id, id: event.target.dataset.id,
replay:event.target.dataset.replay, replay: event.target.dataset.replay,
reasonId:res.tapIndex, reasonId: res.tapIndex,
}, },
success: function (d) { success: function (d) {
if(d.data.msg == "成功"){ if (d.data.msg == "成功") {
that.onShow(); that.onShow();
} }
} }
@@ -72,8 +75,10 @@ Page({
onShow: function () { onShow: function () {
var that = this; var that = this;
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/apply/myApply', url: `${baseUrl}/apply/myApply`,
data:{id:wx.getStorageSync('id')}, data: {
id: wx.getStorageSync('id')
},
success: function (d) { success: function (d) {
that.setData({ that.setData({
List: d.data.data List: d.data.data
@@ -116,4 +121,4 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
} }
}) })

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

View File

@@ -1,18 +1,21 @@
// pages/home/home.js const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
isManager:false, isManager: false,
isStudent:false, isStudent: false,
notice:'' notice: ''
}, },
goWebPage: function (event) { goWebPage: function (event) {
wx.navigateTo({ wx.navigateTo({
url: '../webPage/'+event.target.dataset.web, url: '../webPage/' + event.target.dataset.web,
}) })
}, },
toRedList: function (event) { toRedList: function (event) {
@@ -20,7 +23,7 @@ Page({
url: '../other/redList' url: '../other/redList'
}) })
}, },
goCode:function() { goCode: function () {
wx.navigateTo({ wx.navigateTo({
url: '../other/redList2' url: '../other/redList2'
}) })
@@ -30,12 +33,12 @@ Page({
url: '../person/count' url: '../person/count'
}) })
}, },
goNotice:function () { goNotice: function () {
wx.navigateTo({ wx.navigateTo({
url: '../notice/notice' url: '../notice/notice'
}) })
}, },
goVisitor:function () { goVisitor: function () {
wx.navigateTo({ wx.navigateTo({
url: '../visitor/visitorReplay' url: '../visitor/visitorReplay'
}) })
@@ -80,7 +83,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
}, },
/** /**
@@ -94,17 +97,17 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
if(!wx.getStorageSync("username")){ if (!wx.getStorageSync("username")) {
wx.navigateTo({ wx.navigateTo({
url: '../login/login' url: '../login/login'
}) })
} }
if(wx.getStorageSync("role") == 2){ if (wx.getStorageSync("role") == 2) {
this.setData({ this.setData({
isManager: false, isManager: false,
isStudent: true, isStudent: true,
}) })
}else if(wx.getStorageSync("role") == 1){ } else if (wx.getStorageSync("role") == 1) {
this.setData({ this.setData({
isManager: true, isManager: true,
isStudent: false, isStudent: false,
@@ -112,8 +115,10 @@ Page({
} }
var that = this; var that = this;
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/notice/noticeList', url: `${baseUrl}/notice/noticeList`,
data:{limit:3}, data: {
limit: 3
},
success: function (d) { success: function (d) {
that.setData({ that.setData({
notice: d.data.data notice: d.data.data
@@ -156,4 +161,4 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
} }
}) })

View File

@@ -1,74 +1,79 @@
const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
data: { data: {
username: '', username: '',
password: '' password: ''
}, },
// 获取输入账号 // 获取输入账号
usernameInput: function (e) { usernameInput: function (e) {
this.setData({ this.setData({
username: e.detail.value username: e.detail.value
}) })
}, },
// 获取输入密码 // 获取输入密码
passwordInput: function (e) { passwordInput: function (e) {
this.setData({ this.setData({
password: e.detail.value password: e.detail.value
}) })
}, },
// 登录 // 登录
login: function () { login: function () {
var username = this.data.username var username = this.data.username
if(this.data.username == '' || this.data.password == ''){ var password = this.data.password
wx.showToast({ if (username == '' || password == '') {
title: "请完善登录信息", wx.showToast({
icon: 'error', title: "请完善登录信息",
duration: 2000 icon: 'error',
}) duration: 2000
}else{ })
wx.request({ } else {
url: 'http://127.0.0.1:8080/user/login', wx.request({
data: { url: `${baseUrl}/user/login`,
username: this.data.username, data: {
password: this.data.password, username: this.data.username,
}, password: this.data.password,
success: function (d) { },
if (d.data.msg == "成功") { success: function (d) {
wx.setStorageSync("username",username); if (d.data.msg == "成功") {
if(d.data.data.stu_id){ wx.setStorageSync("username", username);
wx.setStorageSync("stuId",d.data.data.stu_id); if (d.data.data.stu_id) {
} wx.setStorageSync("stuId", d.data.data.stu_id);
wx.setStorageSync("id",d.data.data.id); }
wx.setStorageSync("name",d.data.data.name); wx.setStorageSync("id", d.data.data.id);
wx.setStorageSync("role",d.data.data.role); wx.setStorageSync("name", d.data.data.name);
wx.setStorageSync("state",d.data.data.state) wx.setStorageSync("role", d.data.data.role);
wx.showToast({ wx.setStorageSync("state", d.data.data.state)
title: "登录成功", wx.showToast({
icon: 'success', title: "登录成功",
success: function () { icon: 'success',
wx.switchTab({ success: function () {
url: '../home/home' wx.switchTab({
}) url: '../home/home'
}
})
} else {
wx.showToast({
title: d.data.msg,
icon: 'error',
duration: 2000
}) })
} }
} })
}) } else {
wx.showToast({
title: d.data.msg,
icon: 'error',
duration: 2000
})
}
} }
}, })
}
},
visitor: function () { visitor: function () {
wx.navigateTo({ wx.navigateTo({
url: '../visitor/visitor', url: '../visitor/visitor',
success: function () {}, //成功后的回调; success: function () { }, //成功后的回调;
}) })
}, },
}) })

View File

@@ -1,12 +1,15 @@
//issues.js //issues.js
//获取应用实例 //获取应用实例
var app = getApp(); const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
var util = require('../../utils/util') var util = require('../../utils/util')
Page({ Page({
data: { data: {
title: '', title: '',
content: '', content: '',
time:'' time: ''
}, },
titleInput: function (e) { titleInput: function (e) {
@@ -21,14 +24,14 @@ Page({
}) })
}, },
submit:function () { submit: function () {
var TIME = util.formatTime(new Date()); var TIME = util.formatTime(new Date());
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/notice/addNotice', url: `${baseUrl}/notice/addNotice`,
data: { data: {
title: this.data.title, title: this.data.title,
content: this.data.content, content: this.data.content,
time:TIME, time: TIME,
}, },
success: function (d) { success: function (d) {
if (d.data != "提交失败") { if (d.data != "提交失败") {
@@ -37,11 +40,11 @@ Page({
icon: 'success', icon: 'success',
duration: 2000, duration: 2000,
success: function () { success: function () {
setTimeout(function() { setTimeout(function () {
wx.switchTab({ wx.switchTab({
url: '../home/home' url: '../home/home'
}) })
}, 2000); }, 2000);
} }
}) })
} else { } else {
@@ -55,8 +58,8 @@ Page({
}) })
}, },
onLoad: function(){ onLoad: function () {
}, },
}); });

View File

@@ -1,11 +1,14 @@
// pages/other/feedback.js const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
feedbackList:'', feedbackList: '',
}, },
/** /**
@@ -28,13 +31,13 @@ Page({
onShow: function () { onShow: function () {
var that = this; var that = this;
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/other/feedbackList', url: `${baseUrl}/other/feedbackList`,
data: { data: {
id:wx.getStorageSync('id') id: wx.getStorageSync('id')
}, },
success: function (d) { success: function (d) {
for (const iterator of d.data.data) { for (const iterator of d.data.data) {
if(!iterator.reply){ if (!iterator.reply) {
iterator.reply = "暂无" iterator.reply = "暂无"
} }
} }
@@ -79,4 +82,4 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
} }
}) })

View File

@@ -5,7 +5,7 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
feedbackList:'', feedbackList: '',
replay: [], replay: [],
}, },
@@ -33,13 +33,13 @@ Page({
onShow: function () { onShow: function () {
var that = this; var that = this;
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/other/feedbackListNoReplay', url: `${baseUrl}/other/feedbackListNoReplay`,
data: { data: {
id:wx.getStorageSync('id') id: wx.getStorageSync('id')
}, },
success: function (d) { success: function (d) {
for (const iterator of d.data.data) { for (const iterator of d.data.data) {
if(!iterator.reply){ if (!iterator.reply) {
iterator.reply = "" iterator.reply = ""
} }
} }
@@ -54,10 +54,10 @@ Page({
var that = this var that = this
console.log(event.target.dataset) console.log(event.target.dataset)
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/other/feedbackReplay', url: `${baseUrl}/other/feedbackReplay`,
data: { data: {
id:event.target.dataset.id, id: event.target.dataset.id,
replay:event.target.dataset.replay replay: event.target.dataset.replay
}, },
success: function (d) { success: function (d) {
wx.showToast({ wx.showToast({
@@ -66,12 +66,12 @@ Page({
duration: 2000, duration: 2000,
success: function () { success: function () {
that.setData({ that.setData({
replay : "" replay: ""
}) })
that.onShow() that.onShow()
} }
}) })
} }
}) })
}, },
@@ -109,4 +109,4 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
} }
}) })

View File

@@ -1,14 +1,17 @@
// pages/other/password.js const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
username:wx.getStorageSync('username'), username: wx.getStorageSync('username'),
pwd1:'', pwd1: '',
pwd2:'', pwd2: '',
pwd3:'' pwd3: ''
}, },
pwd1: function (e) { pwd1: function (e) {
this.setData({ this.setData({
@@ -27,15 +30,15 @@ Page({
}, },
submit: function () { submit: function () {
if(this.data.pwd2 != this.data.pwd3){ if (this.data.pwd2 != this.data.pwd3) {
wx.showToast({ wx.showToast({
title: '新密码不一致', title: '新密码不一致',
icon: 'error', icon: 'error',
duration: 2000 duration: 2000
}) })
}else{ } else {
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/user/updPwd', url: `${baseUrl}/user/updPwd`,
data: { data: {
username: this.data.username, username: this.data.username,
pwd1: this.data.pwd1, pwd1: this.data.pwd1,
@@ -48,12 +51,12 @@ Page({
icon: 'success', icon: 'success',
duration: 2000, duration: 2000,
success: function () { success: function () {
setTimeout(function() { setTimeout(function () {
wx.clearStorageSync() wx.clearStorageSync()
wx.navigateTo({ wx.navigateTo({
url: '../login/login' url: '../login/login'
}) })
}, 2000); }, 2000);
} }
}) })
} else { } else {
@@ -66,7 +69,7 @@ Page({
} }
}) })
} }
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
@@ -123,4 +126,4 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
} }
}) })

View File

@@ -1,33 +1,33 @@
const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
data:{ data: {
tableInfo: {},
tableInfo: {}, count: ''
count:''
}, },
onReady: function () { onReady: function () {
// 生命周期函数--监听页面初次渲染完成 // 生命周期函数--监听页面初次渲染完成
var that = this; var that = this;
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/user/redCodeList', url: `${baseUrl}/user/redCodeList`,
success: function (d) { success: function (d) {
let item = []; let item = [];
for (const iterator of d.data.data) { for (const iterator of d.data.data) {
let item1 = [iterator.stu_id,iterator.name]; let item1 = [iterator.stu_id, iterator.name];
item.push(item1) item.push(item1)
}
that.setData({
tableInfo:{
title:["学号","姓名"],
contentItem: item,
},
count: d.data.data.length
})
} }
}) that.setData({
tableInfo: {
}, title: ["学号", "姓名"],
contentItem: item,
}) },
count: d.data.data.length
})
}
})
},
})

View File

@@ -1,33 +1,32 @@
const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
data: {
data:{ tableInfo: {},
count: ''
tableInfo: {},
count:''
}, },
onReady: function () { onReady: function () {
// 生命周期函数--监听页面初次渲染完成 // 生命周期函数--监听页面初次渲染完成
var that = this; var that = this;
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/user/redCodeList2', url: `${baseUrl}/user/redCodeList2`,
success: function (d) { success: function (d) {
let item = []; let item = [];
for (const iterator of d.data.data) { for (const iterator of d.data.data) {
let item1 = [iterator.stu_id,iterator.name]; let item1 = [iterator.stu_id, iterator.name];
item.push(item1) item.push(item1)
}
that.setData({
tableInfo:{
title:["学号","姓名"],
contentItem: item,
},
count: d.data.data.length
})
} }
}) that.setData({
tableInfo: {
}, title: ["学号", "姓名"],
contentItem: item,
}) },
count: d.data.data.length
})
}
})
},
})

View File

@@ -1,18 +1,28 @@
// pages/person/count.js const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
useranme:'', useranme: '',
name:'', name: '',
radio1: [{name:'管理员',value:'1'},{name:'学生',value:'2',checked: 'true'}], radio1: [{
role:'2' name: '管理员',
value: '1'
}, {
name: '学生',
value: '2',
checked: 'true'
}],
role: '2'
}, },
radioChange: function(e) { radioChange: function (e) {
this.setData({ this.setData({
role:e.detail.value role: e.detail.value
}) })
}, },
username: function (e) { username: function (e) {
@@ -25,10 +35,10 @@ Page({
name: e.detail.value name: e.detail.value
}) })
}, },
submit:function () { submit: function () {
var that = this var that = this
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/user/addUser', url: `${baseUrl}/user/addUser`,
data: { data: {
username: this.data.username, username: this.data.username,
name: this.data.name, name: this.data.name,
@@ -42,7 +52,7 @@ Page({
duration: 2000, duration: 2000,
}) })
that.onLoad(); that.onLoad();
}else{ } else {
wx.showToast({ wx.showToast({
title: d.data.data, title: d.data.data,
icon: 'error', icon: 'error',
@@ -50,8 +60,8 @@ Page({
}) })
} }
} }
}) })
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
@@ -107,4 +117,4 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
} }
}) })

View File

@@ -1,23 +1,26 @@
// pages/person/info.js const app = getApp()
Page({ const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
id:wx.getStorageSync('id'), id: wx.getStorageSync('id'),
name:wx.getStorageSync('name'), name: wx.getStorageSync('name'),
stuId:wx.getStorageSync('stuId'), stuId: wx.getStorageSync('stuId'),
img:'' img: ''
}, },
personInfo() { personInfo() {
var that = this; var that = this;
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/user/person', url: `${baseUrl}/user/person`,
data: { data: {
username: wx.getStorageSync('username'), username: wx.getStorageSync('username'),
},success: function (d) { },
success: function (d) {
that.setData({ that.setData({
img: d.data.img, img: d.data.img,
name: wx.getStorageSync('name'), name: wx.getStorageSync('name'),
@@ -32,7 +35,7 @@ Page({
count: 1, count: 1,
sizeType: 'compressed', sizeType: 'compressed',
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'],
success (res) { success(res) {
let imgbase64 = 'data:image/png;base64,' + wx.getFileSystemManager().readFileSync(res.tempFilePaths[0], "base64") let imgbase64 = 'data:image/png;base64,' + wx.getFileSystemManager().readFileSync(res.tempFilePaths[0], "base64")
that.setData({ that.setData({
img: imgbase64, img: imgbase64,
@@ -43,22 +46,23 @@ Page({
update: function () { update: function () {
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/user/updateImg', url: `${baseUrl}/user/updateImg`,
data: { data: {
id: this.data.id, id: this.data.id,
img: this.data.img img: this.data.img
},success: function (d) { },
success: function (d) {
if (d.data != "修改失败") { if (d.data != "修改失败") {
wx.showToast({ wx.showToast({
title: d.data, title: d.data,
icon: 'success', icon: 'success',
duration: 2000, duration: 2000,
success: function () { success: function () {
setTimeout(function() { setTimeout(function () {
wx.switchTab({ wx.switchTab({
url: '../person/person' url: '../person/person'
}) })
}, 2000); }, 2000);
} }
}) })
} else { } else {
@@ -76,7 +80,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
}, },
/** /**
@@ -90,7 +94,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
}, },
/** /**
@@ -127,4 +131,4 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
} }
}) })

View File

@@ -1,12 +1,15 @@
//issues.js //issues.js
//获取应用实例 //获取应用实例
var app = getApp(); const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
var util = require('../../utils/util') var util = require('../../utils/util')
Page({ Page({
data: { data: {
title: '', title: '',
content: '', content: '',
time:'' time: ''
}, },
titleInput: function (e) { titleInput: function (e) {
@@ -21,15 +24,15 @@ Page({
}) })
}, },
submit:function () { submit: function () {
var TIME = util.formatTime(new Date()); var TIME = util.formatTime(new Date());
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/other/subFeedback', url: `${baseUrl}/other/subFeedback`,
data: { data: {
title: this.data.title, title: this.data.title,
content: this.data.content, content: this.data.content,
time:TIME, time: TIME,
id:wx.getStorageSync('id') id: wx.getStorageSync('id')
}, },
success: function (d) { success: function (d) {
if (d.data != "提交失败") { if (d.data != "提交失败") {
@@ -38,11 +41,11 @@ Page({
icon: 'success', icon: 'success',
duration: 2000, duration: 2000,
success: function () { success: function () {
setTimeout(function() { setTimeout(function () {
wx.switchTab({ wx.switchTab({
url: '../person/person' url: '../person/person'
}) })
}, 2000); }, 2000);
} }
}) })
} else { } else {
@@ -56,8 +59,8 @@ Page({
}) })
}, },
onLoad: function(){ onLoad: function () {
}, },
}); });

View File

@@ -1,18 +1,21 @@
// pages/person/person.js const app = getApp()
var app = getApp(); const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
data: { data: {
name:wx.getStorageSync('name'), name: wx.getStorageSync('name'),
img:'' img: ''
}, },
personInfo() { personInfo() {
var that = this; var that = this;
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/user/person', url: `${baseUrl}/user/person`,
data: { data: {
username: wx.getStorageSync('username'), username: wx.getStorageSync('username'),
},success: function (d) { },
success: function (d) {
that.setData({ that.setData({
img: d.data.img, img: d.data.img,
name: wx.getStorageSync('name'), name: wx.getStorageSync('name'),
@@ -36,18 +39,17 @@ Page({
icon: 'success', icon: 'success',
duration: 1000 duration: 1000
}) })
} else { } else {}
}
} }
}) })
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
}, },
/** /**
@@ -98,4 +100,4 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
} }
}) })

View File

@@ -1,36 +1,35 @@
const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
data: {
data:{ tableInfo: {},
count: ''
tableInfo: {},
count:''
}, },
onReady: function () { onReady: function () {
// 生命周期函数--监听页面初次渲染完成 // 生命周期函数--监听页面初次渲染完成
var that = this; var that = this;
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/report/myReport', url: `${baseUrl}/report/myReport`,
data: { data: {
id:wx.getStorageSync('id') id: wx.getStorageSync('id')
}, },
success: function (d) { success: function (d) {
let item = []; let item = [];
for (const iterator of d.data.data) { for (const iterator of d.data.data) {
let item1 = [iterator.name,iterator.time,iterator.normal,iterator.address]; let item1 = [iterator.name, iterator.time, iterator.normal, iterator.address];
item.push(item1) item.push(item1)
}
that.setData({
tableInfo:{
title:["姓名","填报时间","体温状况","位置"],
contentItem: item,
},
count: d.data.data.length
})
} }
}) that.setData({
tableInfo: {
}, title: ["姓名", "填报时间", "体温状况", "位置"],
contentItem: item,
}) },
count: d.data.data.length
})
}
})
},
})

View File

@@ -1,4 +1,6 @@
// pages/report/report.js const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
var util = require('../../utils/util') var util = require('../../utils/util')
Page({ Page({
@@ -6,30 +8,44 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
id:'', id: '',
address: '', address: '',
time: '', time: '',
radio1: [{value:'正常',checked: 'true'},{value:'发热'}], radio1: [{
radio2:[{value:'无需隔离',checked:'true'},{value:'居家隔离'},{value:'集中隔离'},{value:'入院隔离'}], value: '正常',
normal:'正常', checked: 'true'
isolation:'无需隔离', }, {
value: '发热'
}],
radio2: [{
value: '无需隔离',
checked: 'true'
}, {
value: '居家隔离'
}, {
value: '集中隔离'
}, {
value: '入院隔离'
}],
normal: '正常',
isolation: '无需隔离',
name: '', name: '',
stuId: '', stuId: '',
yes_noon_temp:36.2, yes_noon_temp: 36.2,
yes_night_temp:36.4, yes_night_temp: 36.4,
today_morning_temp:36.2 today_morning_temp: 36.2
}, },
radioChange1: function(e) { radioChange1: function (e) {
this.setData({ this.setData({
normal:e.detail.value normal: e.detail.value
}) })
}, },
radioChange2: function(e) { radioChange2: function (e) {
this.setData({ this.setData({
isolation:e.detail.value isolation: e.detail.value
}) })
}, },
chooseLocation: function () { chooseLocation: function () {
var that = this; var that = this;
wx.getSetting({ wx.getSetting({
@@ -37,7 +53,7 @@ Page({
if (!res.authSetting['scope.userLocation']) { if (!res.authSetting['scope.userLocation']) {
wx.authorize({ wx.authorize({
scope: 'scope.userLocationBackground', scope: 'scope.userLocationBackground',
success(){ success() {
that.location(); that.location();
} }
}) })
@@ -48,7 +64,7 @@ Page({
}) })
}, },
location:function () { location: function () {
var that = this; var that = this;
wx.chooseLocation({ wx.chooseLocation({
success: function (res) { success: function (res) {
@@ -65,7 +81,7 @@ Page({
}) })
}, },
myreport:function () { myreport: function () {
wx.navigateTo({ wx.navigateTo({
url: './myreport' url: './myreport'
}) })
@@ -73,39 +89,39 @@ Page({
report: function () { report: function () {
var that = this var that = this
if(this.data.address==''){ if (this.data.address == '') {
wx.showToast({ wx.showToast({
title: '请先选择地址', title: '请先选择地址',
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}) })
}else{ } else {
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/report/doReport', url: `${baseUrl}/report/doReport`,
data: { data: {
user_id:this.data.id, user_id: this.data.id,
name:this.data.name, name: this.data.name,
address: this.data.address, address: this.data.address,
time: this.data.time, time: this.data.time,
normal:this.data.normal, normal: this.data.normal,
yes_noon_temp:this.data.yes_noon_temp, yes_noon_temp: this.data.yes_noon_temp,
yes_night_temp:this.data.yes_night_temp, yes_night_temp: this.data.yes_night_temp,
today_morning_temp:this.data.today_morning_temp, today_morning_temp: this.data.today_morning_temp,
isolation:this.data.isolation isolation: this.data.isolation
}, },
success: function (d) { success: function (d) {
if (d.data == "填报成功") { if (d.data == "填报成功") {
wx.showToast({ wx.showToast({
title: d.data, title: d.data,
icon: 'success', icon: 'success',
success: function () { success: function () {
if(that.data.normal != "发热" && that.data.isolation == "无需隔离"){ if (that.data.normal != "发热" && that.data.isolation == "无需隔离") {
wx.setStorageSync("state",that.formatDate(new Date())) wx.setStorageSync("state", that.formatDate(new Date()))
}else{ } else {
wx.setStorageSync("state","1999-01-01") wx.setStorageSync("state", "1999-01-01")
} }
} }
}) })
} else { } else {
@@ -119,16 +135,16 @@ Page({
}) })
} }
}, },
formatDate: function(date) { formatDate: function (date) {
let year = date.getFullYear() let year = date.getFullYear()
let month = date.getMonth() + 1 let month = date.getMonth() + 1
month = month.toString() month = month.toString()
month[1] ? month=month :month='0' + month month[1] ? month = month : month = '0' + month
let day = date.getDate() let day = date.getDate()
day = day.toString() day = day.toString()
day[1] ? day=day : day='0' + day day[1] ? day = day : day = '0' + day
return year+"-"+month+"-"+day return year + "-" + month + "-" + day
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
@@ -152,7 +168,7 @@ Page({
time: TIME, time: TIME,
name: wx.getStorageSync('name'), name: wx.getStorageSync('name'),
stuId: wx.getStorageSync('stuId'), stuId: wx.getStorageSync('stuId'),
id:wx.getStorageSync('id') id: wx.getStorageSync('id')
}); });
}, },
@@ -190,4 +206,4 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
} }
}) })

View File

@@ -1,6 +1,8 @@
// pages/visitor/showMyVisitor.js const app = getApp()
Page({ const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
@@ -25,22 +27,22 @@ Page({
}) })
} else { } else {
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/visitor/showMyVisitor', url: `${baseUrl}/visitor/showMyVisitor`,
data: { data: {
phone: this.data.phone, phone: this.data.phone,
}, },
success: function (d) { success: function (d) {
if (d.data == "审批通过") { if (d.data == "审批通过") {
that.setData({ that.setData({
greenCode:true, greenCode: true,
redCode:false, redCode: false,
msg:d.data msg: d.data
}) })
}else{ } else {
that.setData({ that.setData({
greenCode:false, greenCode: false,
redCode:true, redCode: true,
msg:d.data msg: d.data
}) })
} }
} }
@@ -102,4 +104,4 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
} }
}) })

View File

@@ -1,15 +1,17 @@
// pages/visitor/visitor.js const app = getApp()
Page({ const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
date:'', date: '',
time:'', time: '',
phone:'', phone: '',
issue:'', issue: '',
meetName:'' meetName: ''
}, },
showMyVisitor: function () { showMyVisitor: function () {
wx.navigateTo({ wx.navigateTo({
@@ -19,21 +21,21 @@ Page({
}, },
report: function () { report: function () {
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/visitor/visitorApply', url: `${baseUrl}/visitor/visitorApply`,
data: { data: {
phone: this.data.phone, phone: this.data.phone,
issue: this.data.issue, issue: this.data.issue,
meet_name: this.data.meetName, meet_name: this.data.meetName,
time: this.data.date+" "+this.data.time time: this.data.date + " " + this.data.time
}, },
success:function(d){ success: function (d) {
if(d.data == "您还有未审批的申请,不能重复申请"){ if (d.data == "您还有未审批的申请,不能重复申请") {
wx.showToast({ wx.showToast({
title:'不能重复申请', title: '不能重复申请',
icon: 'error', icon: 'error',
duration: 2000 duration: 2000
}) })
}else{ } else {
wx.showToast({ wx.showToast({
title: d.data, title: d.data,
icon: 'success', icon: 'success',
@@ -43,27 +45,27 @@ Page({
} }
}) })
}, },
bindDateChange: function(e) { bindDateChange: function (e) {
this.setData({ this.setData({
date: e.detail.value date: e.detail.value
}) })
}, },
bindTimeChange: function(e) { bindTimeChange: function (e) {
this.setData({ this.setData({
time: e.detail.value time: e.detail.value
}) })
}, },
phoneChange: function(e) { phoneChange: function (e) {
this.setData({ this.setData({
phone: e.detail.value phone: e.detail.value
}) })
}, },
issueChange: function(e) { issueChange: function (e) {
this.setData({ this.setData({
issue: e.detail.value issue: e.detail.value
}) })
}, },
meetNameChange: function(e) { meetNameChange: function (e) {
this.setData({ this.setData({
meetName: e.detail.value meetName: e.detail.value
}) })
@@ -123,4 +125,4 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
} }
}) })

View File

@@ -1,11 +1,13 @@
// pages/other/feedback.js const app = getApp()
Page({ const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
List:'', List: '',
replay: [], replay: [],
}, },
@@ -15,13 +17,13 @@ Page({
onLoad: function (options) { onLoad: function (options) {
}, },
replay:function (event) { replay: function (event) {
var that = this var that = this
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/visitor/visitorChangeState', url: `${baseUrl}/visitor/visitorChangeState`,
data: { data: {
id:event.target.dataset.id, id: event.target.dataset.id,
state:event.target.dataset.replay, state: event.target.dataset.replay,
}, },
success: function (d) { success: function (d) {
wx.showToast({ wx.showToast({
@@ -52,7 +54,7 @@ Page({
onShow: function () { onShow: function () {
var that = this; var that = this;
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/visitor/showVisitorList', url: `${baseUrl}/visitor/showVisitorList`,
success: function (d) { success: function (d) {
that.setData({ that.setData({
List: d.data.data List: d.data.data
@@ -95,4 +97,4 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
} }
}) })