api接口baseUrl通过全局变量引入;代码格式化
This commit is contained in:
@@ -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