api接口baseUrl通过全局变量引入;代码格式化
This commit is contained in:
@@ -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 () {
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user