|
@@ -94,13 +94,9 @@ function loginSuccess(res) {
|
|
|
|
|
|
|
|
|
function send_post(url, data, successfun) {
|
|
|
+
|
|
|
console.log("令牌:", app.globalToken)
|
|
|
- // if(app.globalToken==null){
|
|
|
- // wx.reLaunch({
|
|
|
- // url: '../denglu/denglu',
|
|
|
- // })
|
|
|
- // }
|
|
|
- //如果令牌为空或过期,需要重新请求
|
|
|
+
|
|
|
wx.request({
|
|
|
url: BASE_Server + url, //仅为示例,并非真实的接口地址
|
|
|
method: "POST",
|
|
@@ -145,27 +141,14 @@ function post(url, data, successfun) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-// function wxpost(url, data, successfun) {
|
|
|
-// wx.request({
|
|
|
-// url: BASE_Server + url, //仅为示例,并非真实的接口地址
|
|
|
-// method: "POST",
|
|
|
-// header: {
|
|
|
-// 'content-type': 'application/json',
|
|
|
-// 'Authorization': 'Bearer ' + app.globalToken
|
|
|
-// },
|
|
|
-// data: data,
|
|
|
-// success(res) {
|
|
|
-// successfun(res.data)
|
|
|
-// }
|
|
|
-// })
|
|
|
-// }
|
|
|
|
|
|
function get(url, data, successfun) {
|
|
|
wx.request({
|
|
|
url: BASE_Server + url, //仅为示例,并非真实的接口地址
|
|
|
- method: "Get",
|
|
|
+ method: "GET",
|
|
|
header: {
|
|
|
- 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded',
|
|
|
+ 'Authorization': 'Bearer ' + app.globalToken
|
|
|
},
|
|
|
params: data,
|
|
|
success(res) {
|
|
@@ -179,6 +162,33 @@ function get(url, data, successfun) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+function send_get(url, data, successfun) {
|
|
|
+ console.log("令牌:", app.globalToken)
|
|
|
+ wx.request({
|
|
|
+ url: BASE_Server + url, //仅为示例,并非真实的接口地址
|
|
|
+ method: "GET",
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/json',
|
|
|
+ 'Authorization': 'Bearer ' + app.globalToken
|
|
|
+ },
|
|
|
+ data: data,
|
|
|
+ success(res) {
|
|
|
+ // var d = decodeURIComponent(decodeURIComponent(res.data.data))
|
|
|
+ // var json = JSON.parse(d)
|
|
|
+ console.log("TAG","返回数据:"+res.data)
|
|
|
+ authToken(res.data)
|
|
|
+ successfun(res.data)
|
|
|
+ },
|
|
|
+ fail(res){
|
|
|
+ wx.showToast({
|
|
|
+ title: "网络请求失败",
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
function send_postdecode(url, data, successfun) {
|
|
|
wx.request({
|
|
|
url: BASE_Server + url, //仅为示例,并非真实的接口地址
|
|
@@ -236,6 +246,7 @@ module.exports = {
|
|
|
post: post,
|
|
|
// wxpost: wxpost,
|
|
|
get: get,
|
|
|
+ send_get:send_get,
|
|
|
send_postdecode: send_postdecode,
|
|
|
|
|
|
|
|
@@ -257,9 +268,30 @@ function hideLoading() {
|
|
|
}
|
|
|
|
|
|
function authToken(res){
|
|
|
- if(res.code==300){
|
|
|
- wx.reLaunch({
|
|
|
- url: '../denglu/denglu',
|
|
|
+ if(res.code==401){//登录token过期状态码
|
|
|
+ wx.clearStorage({
|
|
|
+ success:(res)=>{
|
|
|
+ wx.reLaunch({
|
|
|
+ url: '../denglu/denglu',
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
+
|
|
|
}
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// function wxpost(url, data, successfun) {
|
|
|
+// wx.request({
|
|
|
+// url: BASE_Server + url, //仅为示例,并非真实的接口地址
|
|
|
+// method: "POST",
|
|
|
+// header: {
|
|
|
+// 'content-type': 'application/json',
|
|
|
+// 'Authorization': 'Bearer ' + app.globalToken
|
|
|
+// },
|
|
|
+// data: data,
|
|
|
+// success(res) {
|
|
|
+// successfun(res.data)
|
|
|
+// }
|
|
|
+// })
|
|
|
+// }
|