|
@@ -1,27 +1,40 @@
|
|
// 引入配置文件
|
|
// 引入配置文件
|
|
import config from "./config.js";
|
|
import config from "./config.js";
|
|
|
|
+// #ifdef MP-WEIXIN
|
|
|
|
+ import wxApp from "./wecaht.min.app.js"
|
|
|
|
+ import {getToken} from './utils.js'
|
|
|
|
+ const token = getToken();
|
|
|
|
+// #endif
|
|
|
|
+const filterNoToken = ["/api/auth/refreshToken", "/api/auth/login"];
|
|
|
|
+
|
|
export default{
|
|
export default{
|
|
config:{
|
|
config:{
|
|
baseUrl:config.webUrl,
|
|
baseUrl:config.webUrl,
|
|
header:{
|
|
header:{
|
|
'Content-Type':'application/json;charset=UTF-8',
|
|
'Content-Type':'application/json;charset=UTF-8',
|
|
- 'Content-Type':'application/x-www-form-urlencoded'
|
|
|
|
},
|
|
},
|
|
data: {},
|
|
data: {},
|
|
method: "GET",
|
|
method: "GET",
|
|
- dataType: "json",
|
|
|
|
|
|
+ dataType: "json",
|
|
},
|
|
},
|
|
- request(options = {}){
|
|
|
|
|
|
+ async request(options = {}){
|
|
options.header = options.header || this.config.header;
|
|
options.header = options.header || this.config.header;
|
|
options.method = options.method || this.config.method;
|
|
options.method = options.method || this.config.method;
|
|
options.dataType = options.dataType || this.config.dataType;
|
|
options.dataType = options.dataType || this.config.dataType;
|
|
- options.url = this.config.baseUrl+options.url;
|
|
|
|
// TODO:token增加等操作
|
|
// TODO:token增加等操作
|
|
- if (options.token) {
|
|
|
|
- options.data.token = uni.getStorageSync("userinfo").token;
|
|
|
|
- options.data.uid = uni.getStorageSync("userinfo").id;
|
|
|
|
- }
|
|
|
|
- var version='web';
|
|
|
|
|
|
+
|
|
|
|
+ options.url = this.config.baseUrl+options.url;
|
|
|
|
+
|
|
|
|
+ var version='web';
|
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
|
+ options.header.appid = wxApp.getWXAppId();
|
|
|
|
+ options.header.source = 'wxapp';
|
|
|
|
+ if(filterNoToken.indexOf(options.url) === -1){
|
|
|
|
+ options.header.Authorization = token;
|
|
|
|
+ }
|
|
|
|
+ version = "wxapp";
|
|
|
|
+ // #endif
|
|
|
|
+ console.log('ctttttttttttttttttt',token)
|
|
// #ifdef APP-PLUS
|
|
// #ifdef APP-PLUS
|
|
var version=plus.runtime.version
|
|
var version=plus.runtime.version
|
|
// #endif
|
|
// #endif
|
|
@@ -30,26 +43,26 @@ export default{
|
|
if(res[1].data.msg=='version10001'){
|
|
if(res[1].data.msg=='version10001'){
|
|
uni.showModal({
|
|
uni.showModal({
|
|
title: '更新提示',
|
|
title: '更新提示',
|
|
- content:"当前版本需要更新,请及时更新",
|
|
|
|
|
|
+ content:"当前版本需要更新,请及时更新",
|
|
showCancel: false,
|
|
showCancel: false,
|
|
confirmText: "确定",
|
|
confirmText: "确定",
|
|
success: function (ress) {
|
|
success: function (ress) {
|
|
plus.runtime.openURL(res[1].data.data);
|
|
plus.runtime.openURL(res[1].data.data);
|
|
uni.reLaunch({
|
|
uni.reLaunch({
|
|
url:'/pages/public/login'
|
|
url:'/pages/public/login'
|
|
- })
|
|
|
|
|
|
+ })
|
|
}
|
|
}
|
|
});
|
|
});
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- return res;
|
|
|
|
|
|
+ return res[1].data.data;
|
|
});
|
|
});
|
|
},
|
|
},
|
|
get(url,data,options={}){
|
|
get(url,data,options={}){
|
|
options.url = url;
|
|
options.url = url;
|
|
options.data = data;
|
|
options.data = data;
|
|
options.method = 'GET';
|
|
options.method = 'GET';
|
|
- return this.request(options);
|
|
|
|
|
|
+ return this.request(options);
|
|
},
|
|
},
|
|
post(url,data,options={}){
|
|
post(url,data,options={}){
|
|
options.url = url;
|
|
options.url = url;
|