|
|
|
|
@ -1,14 +1,8 @@
|
|
|
|
|
// let ajaxUrl = "http://192.168.3.83:8001";
|
|
|
|
|
let ajaxUrl = "https://daotian.matripe.com.cn";
|
|
|
|
|
let requestTask;
|
|
|
|
|
let data = {
|
|
|
|
|
ajaxUrl: ajaxUrl,
|
|
|
|
|
startAbort($bool = 0) {
|
|
|
|
|
if ($bool == 1) {
|
|
|
|
|
requestTask.abort();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Get($url = '', $parmas = {}, callback = () => {}, failback = () => {}) {
|
|
|
|
|
Get ($url = '', $parmas = {}, callback = () => { }, failback = () => { }) {
|
|
|
|
|
let that = this,
|
|
|
|
|
params = {};
|
|
|
|
|
let promise = new Promise((resolve, reject) => {
|
|
|
|
|
@ -19,7 +13,7 @@ let data = {
|
|
|
|
|
that.postData($url, params, callback, failback, 'GET');
|
|
|
|
|
}).catch();
|
|
|
|
|
},
|
|
|
|
|
Post($url = '', $parmas = {}, callback = () => {}, failback = () => {}) {
|
|
|
|
|
Post ($url = '', $parmas = {}, callback = () => { }, failback = () => { }) {
|
|
|
|
|
let that = this,
|
|
|
|
|
params = {};
|
|
|
|
|
let promise = new Promise((resolve, reject) => {
|
|
|
|
|
@ -30,7 +24,7 @@ let data = {
|
|
|
|
|
that.postData($url, params, callback, failback, 'POST');
|
|
|
|
|
}).catch();
|
|
|
|
|
},
|
|
|
|
|
Put($url = '', $parmas = {}, callback = () => {}, failback = () => {}) {
|
|
|
|
|
Put ($url = '', $parmas = {}, callback = () => { }, failback = () => { }) {
|
|
|
|
|
let that = this,
|
|
|
|
|
params = {};
|
|
|
|
|
let promise = new Promise((resolve, reject) => {
|
|
|
|
|
@ -42,7 +36,7 @@ let data = {
|
|
|
|
|
}).catch();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setPublicParams() {
|
|
|
|
|
setPublicParams () {
|
|
|
|
|
let that = this,
|
|
|
|
|
params = {};
|
|
|
|
|
let uuid_new = "";
|
|
|
|
|
@ -91,7 +85,7 @@ let data = {
|
|
|
|
|
return params
|
|
|
|
|
},
|
|
|
|
|
// 发送请求
|
|
|
|
|
postData($url = '', $parmas = {}, callback = () => {}, failback = () => {}, $method) {
|
|
|
|
|
postData ($url = '', $parmas = {}, callback = () => { }, failback = () => { }, $method) {
|
|
|
|
|
let that = this,
|
|
|
|
|
$header = {};
|
|
|
|
|
if (uni.getStorageSync("apply-token")) {
|
|
|
|
|
@ -113,11 +107,7 @@ let data = {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log("公共参数,+++++", Object.assign($parmas, that.setPublicParams()));
|
|
|
|
|
uni.getNetworkType({
|
|
|
|
|
success: function(res) {
|
|
|
|
|
// console.log(res);
|
|
|
|
|
if (res.networkType != 'none') {
|
|
|
|
|
requestTask = uni.request({
|
|
|
|
|
uni.request({
|
|
|
|
|
url: ajaxUrl + $url,
|
|
|
|
|
data: Object.assign($parmas, that.setPublicParams()),
|
|
|
|
|
header: Object.assign($header, that.setPublicParams()),
|
|
|
|
|
@ -127,9 +117,9 @@ let data = {
|
|
|
|
|
// console.log('测试报错123123123123123123$url',$url);
|
|
|
|
|
let resData = res.data;
|
|
|
|
|
|
|
|
|
|
if (resData.status == 200) { // 正常
|
|
|
|
|
if (resData.status == 200) {// 正常
|
|
|
|
|
callback(resData.data, resData.msg);
|
|
|
|
|
} else if (resData.status == 9999) { // 登录过期或者身份变动等需要登录的场景
|
|
|
|
|
} else if (resData.status == 9999) {// 登录过期或者身份变动等需要登录的场景
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: resData.msg,
|
|
|
|
|
icon: "none"
|
|
|
|
|
@ -137,11 +127,10 @@ let data = {
|
|
|
|
|
failback(resData);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: '/root/person/loginIndex?path=/' + that.getPathCopy().path + '&level=' +
|
|
|
|
|
that.getPathCopy().level
|
|
|
|
|
url: '/root/person/loginIndex?path=/' + that.getPathCopy().path + '&level=' + that.getPathCopy().level
|
|
|
|
|
});
|
|
|
|
|
}, 1500);
|
|
|
|
|
} else if (resData.status == 500 || resData.status == 502) { // 某种原因导致接口提示该状态码
|
|
|
|
|
} else if (resData.status == 500 || resData.status == 502) {// 某种原因导致接口提示该状态码
|
|
|
|
|
// if (resData.msg == '系统异常,请稍后') {
|
|
|
|
|
// uni.reLaunch({
|
|
|
|
|
// url: '/root/other/error'
|
|
|
|
|
@ -161,11 +150,10 @@ let data = {
|
|
|
|
|
});
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: '/root/person/loginIndex?path=/pages/home/index&level=' + that
|
|
|
|
|
.getPathCopy().level
|
|
|
|
|
url: '/root/person/loginIndex?path=/pages/home/index&level=' + that.getPathCopy().level
|
|
|
|
|
});
|
|
|
|
|
}, 1500);
|
|
|
|
|
} else { // 其他异常
|
|
|
|
|
} else {// 其他异常
|
|
|
|
|
if ($url == '/yishoudan/user/apply/order/V2/details') {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
@ -179,7 +167,7 @@ let data = {
|
|
|
|
|
failback(resData.msg);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fail(error) {
|
|
|
|
|
fail (error) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
// title: error.errMsg,
|
|
|
|
|
title: '系统异常,请稍后',
|
|
|
|
|
@ -188,18 +176,10 @@ let data = {
|
|
|
|
|
failback(error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '网络异常,请检查网络',
|
|
|
|
|
icon: "none"
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 头像上传
|
|
|
|
|
uploadFile($file, callback = () => {}) {
|
|
|
|
|
uploadFile ($file, callback = () => { }) {
|
|
|
|
|
let that = this;
|
|
|
|
|
uni.uploadFile({
|
|
|
|
|
url: ajaxUrl + '/user/changeUserImgsrc',
|
|
|
|
|
@ -216,7 +196,7 @@ let data = {
|
|
|
|
|
},
|
|
|
|
|
/* 获取当前path
|
|
|
|
|
*/
|
|
|
|
|
getPathCopy() {
|
|
|
|
|
getPathCopy () {
|
|
|
|
|
const pages = getCurrentPages();
|
|
|
|
|
if (pages.length > 0) {
|
|
|
|
|
let _path = pages[pages.length - 1].route;
|
|
|
|
|
@ -231,6 +211,17 @@ let data = {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
//监听用户的页面点击
|
|
|
|
|
watchUserPage (path) {
|
|
|
|
|
let that = this;
|
|
|
|
|
try {
|
|
|
|
|
if (uni.getStorageSync("apply-userinfo")) {
|
|
|
|
|
that.Post("/common/user/browsing/history/addRecord", { browsingUrl: path }, (res) => { });
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log("error", error);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default data;
|