征信小程序
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.
zhengxinApplets/api/request.js

53 lines
1.3 KiB

3 months ago
import Vue from 'vue'
let baseUrl = 'https://www.lijkj.cn';
3 months ago
Vue.prototype.$baseUrl = baseUrl;
export function request(prams) {
return new Promise((resolve, reject) => {
let url;
3 months ago
url = baseUrl+"/"+prams.url;
console.log(url)
3 months ago
uni.request({
url: url,
data: prams.data,
method: prams.method,
header: {
3 months ago
"token": uni.getStorageSync('token'),
"Content-type": "application/x-www-form-urlencoded"
3 months ago
},
success: (res) => {
3 months ago
if (res.data.code == 1 ){
3 months ago
resolve(res.data);
3 months ago
}else if(res.data.code == 401){
3 months ago
uni.showModal({
title: "温馨提示",
content: "当前账号已过期,是否重新登录",
confirmColor: "#05754D",
success(res) {
uni.removeStorageSync("userInfo")
uni.removeStorageSync("token")
uni.navigateTo({
url: "/pages/login/login"
})
}
})
} else {
reject(res.data);
uni.showToast({
icon: "none",
title: res.data.msg,
duration: 3000
});
}
},
fail: (err) => {
reject(err);
},
complete: () => {
//console.log('请求完成')
}
});
})
}