|
|
@@ -17,23 +17,26 @@ import { |
|
|
|
} from '../util/sm4.js' |
|
|
|
const s4 = new SM4Util() |
|
|
|
|
|
|
|
function updateToken(){ |
|
|
|
let toole = 0; |
|
|
|
|
|
|
|
/* 刷新token */ |
|
|
|
function updateToken() { |
|
|
|
const options = { |
|
|
|
type: 2, |
|
|
|
data: { |
|
|
|
mobilePhone: getItem("mobile") |
|
|
|
openId: getItem("openId"), |
|
|
|
accessToken: getItem("accessToken") |
|
|
|
}, |
|
|
|
method: "POST", |
|
|
|
showLoading: false, |
|
|
|
}; |
|
|
|
//刷新token |
|
|
|
return new Promise(async (resolve, reject) => { |
|
|
|
const res = await request('225aa780a91b40f0b44e7e5fe204fc9a', options); |
|
|
|
const res = await request(updateToken, options); |
|
|
|
const data = stringToJson(res.bizContent); |
|
|
|
console.log("data", data) |
|
|
|
this.saveToken(data.accessToken); |
|
|
|
this.saveOpenId(data.openId); |
|
|
|
console.log('输出内容', data.openId) |
|
|
|
setItem('accessToken', data.accessToken); |
|
|
|
setItem('openId', data.openId); |
|
|
|
resolve(data); |
|
|
|
}).catch((error) => { |
|
|
|
reject(error); |
|
|
@@ -42,7 +45,6 @@ function updateToken(){ |
|
|
|
|
|
|
|
//请求 |
|
|
|
export function request(code, options = {}) { |
|
|
|
// request(code,options) |
|
|
|
//公参 |
|
|
|
const Common = { |
|
|
|
agentId: "52010106004", |
|
|
@@ -113,6 +115,26 @@ export function request(code, options = {}) { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} else if (res.data.statusCode == 34567) { |
|
|
|
toole++ |
|
|
|
if (toole > 2) { |
|
|
|
updateToken(result.code).then((data) => { |
|
|
|
console.log("token刷新", data); |
|
|
|
request(code, options) |
|
|
|
}); |
|
|
|
} else { |
|
|
|
uni.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: res.data.errorMsg, |
|
|
|
success: function(res) { |
|
|
|
if (res.confirm) { |
|
|
|
console.log('用户点击确定'); |
|
|
|
} else if (res.cancel) { |
|
|
|
console.log('用户点击取消'); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
uni.showModal({ |
|
|
|
title: '提示', |