token修改

master
Tuisku 3 years ago
parent b7d0a2a0bd
commit 7b389c589f

@ -63,7 +63,6 @@ Page({
http("/user/login", "post", {
code: res.code
}).then(res => {
console.log(res)
if (res.msg === "未注册!") {
this.getUserProfile()
} else {
@ -84,7 +83,6 @@ Page({
wx.getStorage({
key: 'token',
success (res) {
console.log(res.data)
}
})
}
@ -104,7 +102,6 @@ Page({
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (userRes) => {
console.log(userRes)
that.setData({
iv: userRes.iv,
encryptedData: userRes.encryptedData,
@ -123,7 +120,6 @@ Page({
phone: false
})
let that = this
console.log(that.data.iv)
let param = {
userinfo: {
iv: this.data.iv,

@ -25,22 +25,33 @@ const http = (url, method, data, isLoading = true) => {
});
}
return new Promise(function (resolve, reject) {
let token = getApp().globalData.token
// wx.getStorage({
// key: 'token',
// success (res) {
// // console.log(res.data)
// let token = res.data
// },
// fail (res) {
// console.log(res)
// wx.hideLoading();
// }
// })
let header = {
'token': token
if ( url === '/user/login' || url === '/user/register') {
var header = {}
} else {
wx.getStorage({
key: 'token',
success (res) {
// console.log(res.data)
let token = res.data
},
fail(res) {
if (res.errMsg === "getStorage:fail data not found"){
wx.showToast({
title: '未登录\r\n点击个人中心头像登录',
icon: 'none',
duration: 2000
})
}
wx.hideLoading();
},
complete (res) {
console.log(res)
}
})
var header = {
'token': token
}
}
if (token) {
wx.request({
url: host + url,
data: data,
@ -66,13 +77,6 @@ const http = (url, method, data, isLoading = true) => {
wx.hideLoading();
}
})
} else {
wx.showToast({
title: '未登录\r\n点击个人中心头像登录',
icon: 'none',
duration: 2000
})
}
})
}

Loading…
Cancel
Save