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,6 +1,8 @@
// pages/other/feedback.js const app = getApp()
Page({ const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
@@ -30,7 +32,7 @@ Page({
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,
@@ -41,8 +43,7 @@ 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();
} }
@@ -55,7 +56,7 @@ Page({
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,
@@ -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`,
// }) // })
// }, // },
/** /**

View File

@@ -1,4 +1,7 @@
// pages/other/feedback.js const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
/** /**
@@ -30,7 +33,7 @@ Page({
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,
@@ -50,7 +53,7 @@ Page({
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,
@@ -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

View File

@@ -1,4 +1,7 @@
// 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: {
@@ -51,7 +54,7 @@ Page({
}) })
} }
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,

View File

@@ -1,4 +1,7 @@
// pages/home/home.js const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
/** /**
@@ -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

View File

@@ -1,3 +1,7 @@
const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
data: { data: {
username: '', username: '',
@@ -21,7 +25,8 @@ Page({
// 登录 // 登录
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
if (username == '' || password == '') {
wx.showToast({ wx.showToast({
title: "请完善登录信息", title: "请完善登录信息",
icon: 'error', icon: 'error',
@@ -29,7 +34,7 @@ Page({
}) })
} else { } else {
wx.request({ wx.request({
url: 'http://127.0.0.1:8080/user/login', url: `${baseUrl}/user/login`,
data: { data: {
username: this.data.username, username: this.data.username,
password: this.data.password, password: this.data.password,

View File

@@ -1,6 +1,9 @@
//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: {
@@ -24,7 +27,7 @@ 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,

View File

@@ -1,4 +1,7 @@
// pages/other/feedback.js const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
/** /**
@@ -28,7 +31,7 @@ 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')
}, },

View File

@@ -33,7 +33,7 @@ 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')
}, },
@@ -54,7 +54,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/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

View File

@@ -1,4 +1,7 @@
// pages/other/password.js const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
/** /**
@@ -35,7 +38,7 @@ Page({
}) })
} 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,

View File

@@ -1,17 +1,19 @@
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) {
@@ -27,7 +29,5 @@ Page({
}) })
} }
}) })
}, },
}) })

View File

@@ -1,17 +1,18 @@
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/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) {
@@ -27,7 +28,5 @@ Page({
}) })
} }
}) })
}, },
}) })

View File

@@ -1,4 +1,7 @@
// pages/person/count.js const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({ Page({
/** /**
@@ -7,7 +10,14 @@ Page({
data: { data: {
useranme: '', useranme: '',
name: '', name: '',
radio1: [{name:'管理员',value:'1'},{name:'学生',value:'2',checked: 'true'}], radio1: [{
name: '管理员',
value: '1'
}, {
name: '学生',
value: '2',
checked: 'true'
}],
role: '2' role: '2'
}, },
radioChange: function (e) { radioChange: function (e) {
@@ -28,7 +38,7 @@ Page({
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,

View File

@@ -1,6 +1,8 @@
// pages/person/info.js const app = getApp()
Page({ const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
@@ -14,10 +16,11 @@ Page({
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'),
@@ -43,11 +46,12 @@ 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,

View File

@@ -1,6 +1,9 @@
//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: {
@@ -24,7 +27,7 @@ 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,

View File

@@ -1,5 +1,7 @@
// 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'),
@@ -9,10 +11,11 @@ Page({
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,8 +39,7 @@ Page({
icon: 'success', icon: 'success',
duration: 1000 duration: 1000
}) })
} else { } else {}
}
} }
}) })

View File

@@ -1,17 +1,18 @@
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/report/myReport', url: `${baseUrl}/report/myReport`,
data: { data: {
id: wx.getStorageSync('id') id: wx.getStorageSync('id')
}, },
@@ -30,7 +31,5 @@ Page({
}) })
} }
}) })
}, },
}) })

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({
@@ -9,8 +11,22 @@ Page({
id: '', id: '',
address: '', address: '',
time: '', time: '',
radio1: [{value:'正常',checked: 'true'},{value:'发热'}], radio1: [{
radio2:[{value:'无需隔离',checked:'true'},{value:'居家隔离'},{value:'集中隔离'},{value:'入院隔离'}], value: '正常',
checked: 'true'
}, {
value: '发热'
}],
radio2: [{
value: '无需隔离',
checked: 'true'
}, {
value: '居家隔离'
}, {
value: '集中隔离'
}, {
value: '入院隔离'
}],
normal: '正常', normal: '正常',
isolation: '无需隔离', isolation: '无需隔离',
name: '', name: '',
@@ -81,7 +97,7 @@ Page({
}) })
} 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,

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,7 +27,7 @@ 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,
}, },

View File

@@ -1,6 +1,8 @@
// pages/visitor/visitor.js const app = getApp()
Page({ const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
@@ -19,7 +21,7 @@ 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,

View File

@@ -1,6 +1,8 @@
// pages/other/feedback.js const app = getApp()
Page({ const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
@@ -18,7 +20,7 @@ Page({
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,
@@ -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