api接口baseUrl通过全局变量引入;代码格式化
This commit is contained in:
@@ -1,18 +1,28 @@
|
||||
// pages/person/count.js
|
||||
const app = getApp()
|
||||
const baseUrl = app.globalData.baseUrl
|
||||
// console.log("baseUrl", baseUrl)
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
useranme:'',
|
||||
name:'',
|
||||
radio1: [{name:'管理员',value:'1'},{name:'学生',value:'2',checked: 'true'}],
|
||||
role:'2'
|
||||
useranme: '',
|
||||
name: '',
|
||||
radio1: [{
|
||||
name: '管理员',
|
||||
value: '1'
|
||||
}, {
|
||||
name: '学生',
|
||||
value: '2',
|
||||
checked: 'true'
|
||||
}],
|
||||
role: '2'
|
||||
},
|
||||
radioChange: function(e) {
|
||||
radioChange: function (e) {
|
||||
this.setData({
|
||||
role:e.detail.value
|
||||
role: e.detail.value
|
||||
})
|
||||
},
|
||||
username: function (e) {
|
||||
@@ -25,10 +35,10 @@ Page({
|
||||
name: e.detail.value
|
||||
})
|
||||
},
|
||||
submit:function () {
|
||||
submit: function () {
|
||||
var that = this
|
||||
wx.request({
|
||||
url: 'http://127.0.0.1:8080/user/addUser',
|
||||
url: `${baseUrl}/user/addUser`,
|
||||
data: {
|
||||
username: this.data.username,
|
||||
name: this.data.name,
|
||||
@@ -42,7 +52,7 @@ Page({
|
||||
duration: 2000,
|
||||
})
|
||||
that.onLoad();
|
||||
}else{
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: d.data.data,
|
||||
icon: 'error',
|
||||
@@ -50,8 +60,8 @@ Page({
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
@@ -107,4 +117,4 @@ Page({
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@@ -1,23 +1,26 @@
|
||||
// pages/person/info.js
|
||||
Page({
|
||||
const app = getApp()
|
||||
const baseUrl = app.globalData.baseUrl
|
||||
// console.log("baseUrl", baseUrl)
|
||||
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
id:wx.getStorageSync('id'),
|
||||
name:wx.getStorageSync('name'),
|
||||
stuId:wx.getStorageSync('stuId'),
|
||||
img:''
|
||||
id: wx.getStorageSync('id'),
|
||||
name: wx.getStorageSync('name'),
|
||||
stuId: wx.getStorageSync('stuId'),
|
||||
img: ''
|
||||
},
|
||||
|
||||
personInfo() {
|
||||
var that = this;
|
||||
wx.request({
|
||||
url: 'http://127.0.0.1:8080/user/person',
|
||||
url: `${baseUrl}/user/person`,
|
||||
data: {
|
||||
username: wx.getStorageSync('username'),
|
||||
},success: function (d) {
|
||||
},
|
||||
success: function (d) {
|
||||
that.setData({
|
||||
img: d.data.img,
|
||||
name: wx.getStorageSync('name'),
|
||||
@@ -32,7 +35,7 @@ Page({
|
||||
count: 1,
|
||||
sizeType: 'compressed',
|
||||
sourceType: ['album', 'camera'],
|
||||
success (res) {
|
||||
success(res) {
|
||||
let imgbase64 = 'data:image/png;base64,' + wx.getFileSystemManager().readFileSync(res.tempFilePaths[0], "base64")
|
||||
that.setData({
|
||||
img: imgbase64,
|
||||
@@ -43,22 +46,23 @@ Page({
|
||||
|
||||
update: function () {
|
||||
wx.request({
|
||||
url: 'http://127.0.0.1:8080/user/updateImg',
|
||||
url: `${baseUrl}/user/updateImg`,
|
||||
data: {
|
||||
id: this.data.id,
|
||||
img: this.data.img
|
||||
},success: function (d) {
|
||||
},
|
||||
success: function (d) {
|
||||
if (d.data != "修改失败") {
|
||||
wx.showToast({
|
||||
title: d.data,
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
success: function () {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
wx.switchTab({
|
||||
url: '../person/person'
|
||||
})
|
||||
}, 2000);
|
||||
}, 2000);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -76,7 +80,7 @@ Page({
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -90,7 +94,7 @@ Page({
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -127,4 +131,4 @@ Page({
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@@ -1,12 +1,15 @@
|
||||
//issues.js
|
||||
//获取应用实例
|
||||
var app = getApp();
|
||||
const app = getApp()
|
||||
const baseUrl = app.globalData.baseUrl
|
||||
// console.log("baseUrl", baseUrl)
|
||||
|
||||
var util = require('../../utils/util')
|
||||
Page({
|
||||
data: {
|
||||
title: '',
|
||||
content: '',
|
||||
time:''
|
||||
time: ''
|
||||
},
|
||||
|
||||
titleInput: function (e) {
|
||||
@@ -21,15 +24,15 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
submit:function () {
|
||||
submit: function () {
|
||||
var TIME = util.formatTime(new Date());
|
||||
wx.request({
|
||||
url: 'http://127.0.0.1:8080/other/subFeedback',
|
||||
url: `${baseUrl}/other/subFeedback`,
|
||||
data: {
|
||||
title: this.data.title,
|
||||
content: this.data.content,
|
||||
time:TIME,
|
||||
id:wx.getStorageSync('id')
|
||||
time: TIME,
|
||||
id: wx.getStorageSync('id')
|
||||
},
|
||||
success: function (d) {
|
||||
if (d.data != "提交失败") {
|
||||
@@ -38,11 +41,11 @@ Page({
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
success: function () {
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
wx.switchTab({
|
||||
url: '../person/person'
|
||||
})
|
||||
}, 2000);
|
||||
}, 2000);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -56,8 +59,8 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
onLoad: function(){
|
||||
|
||||
onLoad: function () {
|
||||
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
@@ -1,18 +1,21 @@
|
||||
// pages/person/person.js
|
||||
var app = getApp();
|
||||
const app = getApp()
|
||||
const baseUrl = app.globalData.baseUrl
|
||||
// console.log("baseUrl", baseUrl)
|
||||
|
||||
Page({
|
||||
data: {
|
||||
name:wx.getStorageSync('name'),
|
||||
img:''
|
||||
name: wx.getStorageSync('name'),
|
||||
img: ''
|
||||
},
|
||||
|
||||
personInfo() {
|
||||
var that = this;
|
||||
wx.request({
|
||||
url: 'http://127.0.0.1:8080/user/person',
|
||||
url: `${baseUrl}/user/person`,
|
||||
data: {
|
||||
username: wx.getStorageSync('username'),
|
||||
},success: function (d) {
|
||||
},
|
||||
success: function (d) {
|
||||
that.setData({
|
||||
img: d.data.img,
|
||||
name: wx.getStorageSync('name'),
|
||||
@@ -36,18 +39,17 @@ Page({
|
||||
icon: 'success',
|
||||
duration: 1000
|
||||
})
|
||||
} else {
|
||||
}
|
||||
} else {}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -98,4 +100,4 @@ Page({
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user