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 () {
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user