|
@@ -7,6 +7,7 @@ const baseRequest = (method, url, data, header) => {
|
|
|
contentheader = header
|
|
|
}
|
|
|
console.log(uni.getStorageSync("shiro"))
|
|
|
+ let userInfo = uni.getStorageSync('userInfo');
|
|
|
let baseDefaultOpts = {
|
|
|
url: baseUrl + url,
|
|
|
// 请求接口地址
|
|
@@ -15,10 +16,9 @@ const baseRequest = (method, url, data, header) => {
|
|
|
method: method,
|
|
|
// 配置请求类型
|
|
|
header: {
|
|
|
- 'Content-Type': contentheader, //'application/x-www-form-urlencoded; charset=UTF-8',
|
|
|
- // cookie: uni.getStorageSync("shiro")
|
|
|
- // token:uni.getStorageSync("shiro")
|
|
|
- },
|
|
|
+ 'content-type': contentheader ,//'application/x-www-form-urlencoded; charset=UTF-8',
|
|
|
+ 'accessToken':userInfo.accessToken
|
|
|
+ }
|
|
|
}
|
|
|
let promise = new Promise(function(resolve, reject) {
|
|
|
uni.getNetworkType({}).then((res) => {
|
|
@@ -44,6 +44,12 @@ const baseRequest = (method, url, data, header) => {
|
|
|
uni.request(baseDefaultOpts).then(
|
|
|
(res) => {
|
|
|
console.log(res)
|
|
|
+ if (res.cookies) {
|
|
|
+ console.log(res.cookies)
|
|
|
+ if (res.cookies.length != 0) {
|
|
|
+ uni.setStorageSync('cookie', res.cookies[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
// console.log(JSON.stringify(res[1].data))
|
|
|
// if(res[1].data.code == '200' || res[1].data.code == 200){
|
|
|
// // 后端返回的状态码100为成功状态,成功则返回请求结果,在app调试时可以通过console.log(JSON.stringify(res[1].data))来查看返回值(以项目实际情况为准)
|
|
@@ -68,7 +74,6 @@ const baseRequest = (method, url, data, header) => {
|
|
|
// });
|
|
|
}
|
|
|
} else {
|
|
|
- // console.log(res)
|
|
|
reject(res)
|
|
|
// uni.showToast({
|
|
|
// icon: 'none',
|