You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import Vue from 'vue'
|
|
|
|
let baseUrl = 'https://bodybuilding.bsdong.cn/';
|
|
|
|
//https://console-docs.apipost.cn/preview/077df998e6b8e954/a3d90a650bdbe292
|
|
|
|
Vue.prototype.$baseUrl = baseUrl;
|
|
|
|
|
|
|
|
// 当前是否显示modal
|
|
|
|
let loginModal = false
|
|
|
|
export function request(prams) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
let url;
|
|
|
|
url = baseUrl + prams.url;
|
|
|
|
uni.request({
|
|
|
|
url: url,
|
|
|
|
data: prams.data,
|
|
|
|
method: prams.method,
|
|
|
|
header: {
|
|
|
|
"userToken": uni.getStorageSync('token')
|
|
|
|
},
|
|
|
|
success: (res) => {
|
|
|
|
console.log('res.data.code',res.data.code);
|
|
|
|
if (res.data.code == 200){
|
|
|
|
resolve(res.data);
|
|
|
|
}else if(res.data.code == 402){
|
|
|
|
if(!loginModal){
|
|
|
|
loginModal = true
|
|
|
|
uni.showModal({
|
|
|
|
title: "温馨提示",
|
|
|
|
content: "当前账号已过期,是否重新登录",
|
|
|
|
confirmColor: "#05754D",
|
|
|
|
success(res) {
|
|
|
|
uni.removeStorageSync("userInfo")
|
|
|
|
uni.removeStorageSync("token")
|
|
|
|
uni.navigateTo({
|
|
|
|
url: "/pages/login/login"
|
|
|
|
})
|
|
|
|
loginModal = false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
reject(res.data);
|
|
|
|
uni.showToast({
|
|
|
|
icon: "none",
|
|
|
|
title: res.data.msg,
|
|
|
|
duration: 3000
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
fail: (err) => {
|
|
|
|
reject(err);
|
|
|
|
},
|
|
|
|
complete: () => {
|
|
|
|
//console.log('请求完成')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
export function requestwhq(prams) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
let url;
|
|
|
|
url = baseUrl + prams.url;
|
|
|
|
uni.request({
|
|
|
|
url: url,
|
|
|
|
data: prams.data,
|
|
|
|
method: prams.method,
|
|
|
|
success: (res) => {
|
|
|
|
console.log('res.data.code',res.data.code);
|
|
|
|
if (res.data.code == 200){
|
|
|
|
resolve(res.data);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fail: (err) => {
|
|
|
|
reject(err);
|
|
|
|
},
|
|
|
|
complete: () => {
|
|
|
|
//console.log('请求完成')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|