const request = (url, data, successCallback, errorCallback) => {
return wx.request({
url: 'IP及端口' + url,
data: data,
method: 'POST',
dataType: 'json',
responseType: 'text',
success: function (res) {
if (res.data.errCode == 0) {
successCallback(res.data.data)
}
else {
wx.showModal({
content: res.data.errMsg,
showCancel: false
});
}
},
fail: function (res) {
wx.hideLoading()
wx.showModal({
content: "服务器连接超时。",
showCancel: false
});
console.log(res)
}
})
}
const setToken = (token) => {
wx.setStorageSync('token', token)
}
const getToken = (token) => {
return wx.getStorageSync('token')
}
网友评论