连云港陪玩陪聊
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.
chunwan/api/request.js

65 lines
1.5 KiB

2 months ago
import Vue from 'vue'
2 months ago
let baseUrl = 'https://api.lyiyuan.cn';
2 months ago
Vue.prototype.$baseUrl = baseUrl;
export function request(prams) {
return new Promise((resolve, reject) => {
2 months ago
let url = baseUrl+"/prod-api/"+prams.url;
2 months ago
uni.request({
2 months ago
url,
2 months ago
data: prams.data,
method: prams.method,
2 months ago
header: {
2 months ago
"token": uni.getStorageSync("userInfo").token,
"Content-type": "application/json",
2 months ago
"deviceSn": uni.getStorageSync("deviceSn"),
2 months ago
},
success: (res) => {
1 month ago
if (res.data.code == 200 || res.data.code == -1){
4 weeks ago
// console.log(prams)
// console.log("返回结果:"+JSON.stringify(res.data))
2 months ago
resolve(res.data);
}else if(res.data.code == 401){
uni.showModal({
title: "温馨提示",
content: "当前账号已过期,是否重新登录",
2 weeks ago
confirmColor: "#000",
2 months ago
success(res) {
uni.removeStorageSync("userInfo")
uni.navigateTo({
url: "/pages/login/login"
})
}
})
2 weeks ago
} else if(res.data.code == -2){
uni.showModal({
title: "温馨提示",
content: "当前账号未三方认证,请前往认证",
confirmColor: "#000",
confirmText: "前往",
success(res) {
uni.navigateTo({
url: "/pages/users/renzheng/index"
})
}
})
}else {
2 months ago
reject(res.data);
uni.showToast({
icon: "none",
title: res.data.msg,
duration: 3000
});
}
},
fail: (err) => {
reject(err);
},
complete: () => {
//console.log('请求完成')
}
});
})
}