You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
4.3 KiB
JavaScript

"use strict";
const common_vendor = require("../common/vendor.js");
const common_baseurl = require("../common/baseurl.js");
const request = (url, data, method) => {
return new Promise((resolve, reject) => {
common_vendor.index.showLoading({
mask: true,
title: "加载中"
});
common_vendor.index.request({
url: common_baseurl.BASE_URL + url,
data,
header: {
1 year ago
"content-type": "application/json"
},
method,
success: (res) => {
if (res) {
common_vendor.index.hideLoading();
}
if (!res.code == 200) {
console.log("错误的url" + url);
}
resolve(res.data);
},
fail: (err) => {
common_vendor.index.showLoading({
mask: true,
title: "加载中"
});
if (err) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
icon: "none",
title: "网络异常!"
});
}
if (err) {
console.log(" 错误信息接口URL" + common_baseurl.BASE_URL + url);
}
reject(err);
}
});
});
};
1 year ago
const requests = (url, data, method) => {
return new Promise((resolve, reject) => {
common_vendor.index.showLoading({
mask: true,
title: "加载中"
});
common_vendor.index.request({
url: common_baseurl.BASE_URLS + url,
data,
header: {
"content-type": "application/json"
},
method,
success: (res) => {
if (res) {
common_vendor.index.hideLoading();
}
if (!res.code == 200) {
console.log("错误的url" + url);
}
resolve(res.data);
},
fail: (err) => {
common_vendor.index.showLoading({
mask: true,
title: "加载中"
});
if (err) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
icon: "none",
title: "网络异常!"
});
}
if (err) {
console.log(" 错误信息接口URL" + common_baseurl.BASE_URLS + url);
}
reject(err);
}
});
});
};
const reqs = (url, data, method) => {
return new Promise((resolve, reject) => {
common_vendor.index.showLoading({
mask: true,
title: "加载中"
});
common_vendor.index.request({
1 year ago
url: common_baseurl.BASE_URLSS + url,
1 year ago
data,
header: {
"content-type": "application/json"
},
method,
success: (res) => {
if (res) {
common_vendor.index.hideLoading();
}
if (!res.code == 200) {
console.log("错误的url" + url);
}
resolve(res.data);
},
fail: (err) => {
common_vendor.index.showLoading({
mask: true,
title: "加载中"
});
if (err) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
icon: "none",
title: "网络异常!"
});
}
if (err) {
1 year ago
console.log(" 错误信息接口URL" + common_baseurl.BASE_URLSS + url);
1 year ago
}
reject(err);
}
});
});
};
const wxRequest = (url, data, method) => {
return new Promise((resolve, reject) => {
common_vendor.index.showLoading({
mask: true,
title: "加载中"
});
common_vendor.index.request({
url: common_baseurl.BASE_URLWX + url,
data,
header: {
"content-type": "application/json"
},
method,
success: (res) => {
if (res) {
common_vendor.index.hideLoading();
}
if (!res.code == 200) {
console.log("错误的url" + url);
}
resolve(res.data);
},
fail: (err) => {
common_vendor.index.showLoading({
mask: true,
title: "加载中"
});
if (err) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
icon: "none",
title: "网络异常!"
});
}
if (err) {
console.log(" 错误信息接口URL" + common_baseurl.BASE_URLSS + url);
}
reject(err);
}
});
});
};
1 year ago
exports.reqs = reqs;
exports.request = request;
1 year ago
exports.requests = requests;
exports.wxRequest = wxRequest;