This commit is contained in:
2026-03-11 14:52:32 +08:00
commit 688e46e1a6
105 changed files with 16711 additions and 0 deletions

81
api/index.js Normal file
View File

@@ -0,0 +1,81 @@
import { request } from './request'
import { Upload } from './request'
// 新增配送选择货物信息
const selectInfo = (params) => {
return request('/document/order/wisdom/rk/list', params, 'GET')
}
// 查看货物信息的详情
const selectInfoDetail = (params) => {
return request('/document/info/list', params, 'GET')
}
// 查看货物信息的字典
const getGoodsDict = (params) => {
return request('/document/mtd/calcTotalWv', params, 'POST')
}
// 获取配送车型列表
const getCarList = (params) => {
return request('/document/type/list', params, 'GET')
}
// 适配车型和预估费用
const autoCarAndPrice = (params) => {
return request('/document/type/fee', params, 'POST')
}
// 发布配送订单
const sendOrder = (params) => {
return request('/document/order/batch', params, 'POST')
}
// 配送订单列表
const getOrder = (params) => {
return request('/document/order/listWithDetail', params, 'GET')
}
// 配送订单详情
const getOrderDetail = (params) => {
return request('/document/order/detail/' + params.orderNo, params, 'GET')
}
// 上传配送附件
const uploadDeliveryAttachment = (files, formData) => {
return Upload('/document/attachment/upload', files, formData)
}
// 开始配送订单
const startOrder = (params) => {
return request('/document/attachment/executeBind', params, 'POST')
}
// 上报经纬度
const locationReport = (params) => {
params.showLoading = true
return request('/delivery/location/report', params, 'POST')
}
// 历史轨迹
const historyLocation = (params) => {
return request('/delivery/location/track', params, 'GET')
}
export {
selectInfo,
selectInfoDetail,
getGoodsDict,
getCarList,
autoCarAndPrice,
sendOrder,
getOrder,
getOrderDetail,
uploadDeliveryAttachment,
startOrder,
locationReport,
historyLocation
}

11
api/login.js Normal file
View File

@@ -0,0 +1,11 @@
import { request } from './request'
// 获取场景列表
const userLogin = (params) => {
return request('/app/login', params, 'POST')
}
export {
userLogin,
}

231
api/request.js Normal file
View File

@@ -0,0 +1,231 @@
//存放主站域名
const BASE_URL = 'http://47.100.212.83:18088' // 正式环境接口
// const BASE_URL = 'http://192.168.1.9:8088' // 测试环境接口
// const BASE_URL = 'http://192.168.1.5:8088' // 测试环境接口
const BASE_URL_IMG = BASE_URL + "/img/upload"; // 上传图片
// 存储请求记录
let requestRecords = {};
// 重复请求拦截时间(毫秒)
const INTERCEPT_DURATION = 2000;
const request = (url, data = {}, method = "GET", ContentType = "application/json") => {
const requestObj = {
data,
url,
time: Date.now(),
};
// if (method !== "GET") {
// if (Object.keys(requestRecords).length == 0) {
// requestRecords = requestObj;
// } else {
// const s_url = requestRecords.url; // 请求地址
// const s_data = requestRecords.data; // 请求数据
// const s_time = requestRecords.time; // 请求时间
// if (
// s_data === requestObj.data &&
// requestObj.time - s_time < INTERCEPT_DURATION &&
// s_url === requestObj.url
// ) {
// uni.showToast({
// title: "数据正在处理,请勿重复提交",
// icon: "none",
// duration: 2000,
// });
// return;
// }
// requestRecords = requestObj;
// }
// }
return new Promise(function (resolve, reject) {
let header = {};
if (uni.getStorageSync("token")) {
header = {
"Content-Type": ContentType,
Authorization: uni.getStorageSync("token"),
};
} else {
header = {
"Content-Type": ContentType,
};
}
if (Object.keys(data).length && !data.showLoading) {
uni.showLoading({
title: "加载中",
mask: true,
});
}
// console.log("请求参数", data, url);
uni.request({
url: BASE_URL + url,
data,
method,
header,
success: function (res) {
console.log("res", res);
if (res.data.code == 200) {
resolve(res.data);
} else if (res.data.code == 401) {
const pages = getCurrentPages();
if (pages[pages.length - 1].route !== "pages/login/login") {
uni.navigateTo({
url: "/pages/login/login",
});
}
} else {
if (Object.keys(res.data).length && !data.showLoading) {
uni.showToast({
title: res.data.msg,
icon: "none",
duration: 2000,
});
}
reject(res);
}
},
fail: function (err) {
console.log("err", err);
uni.getNetworkType({
success: function (res) {
console.log("当前网络状态:", res.networkType);
if (res.networkType === "none") {
console.log("当前无网络");
uni.showToast({
title: "当前网络不可用,请检查网络连接",
icon: "none",
});
return;
} else {
uni.showToast({
title: "加载失败,请稍后重试!",
icon: "none",
duration: 2000,
});
}
},
});
reject(err);
},
complete: function () {
// console.log("结束");
if (!data.showLoading) {
uni.hideLoading();
}
},
});
});
};
// 图片
const Upload = (url, source, formData) => {
return new Promise(function (resolve, reject) {
console.log(source)
let header = {};
if (uni.getStorageSync("token")) {
header = {
// 'Content-Type': ContentType,
authorization: uni.getStorageSync("token"),
};
}
console.log(BASE_URL + url, source, formData, header)
console.log(typeof source === 'string' ? { filePath: source } : { files: source })
uni.uploadFile({
url: BASE_URL + url,
...(typeof source === 'string'
? { filePath: source } // 单文件使用filePath
: { files: source } // 多文件使用files
),
name: 'files',
formData,
// name,
header,
success: function (res) {
console.log(res)
let obj1 = JSON.parse(res.data);
uni.hideLoading();
if (obj1.code !== 200) {
uni.showToast({
title: obj1.message,
icon: "none",
duration: 2000,
});
} else {
uni.showToast({
title: "上传成功",
icon: "success",
duration: 1000,
});
resolve(obj1)
}
},
fail: function (err) {
console.log(err)
console.log(JSON.stringify(err), "失败999");
uni.hideLoading();
uni.showToast({
title: "加载失败, 请稍后再试!",
icon: "none",
duration: 2000,
});
},
complete: function () {},
});
});
};
// 文件上传
const UploadFile = (url, data = {}, source) => {
return new Promise(function (resolve, reject) {
// 返回选定照片的本地文件路径列表tempFilePath可以作为img标签的src属性显示图片
data["name"] = "upload_resource";
let time = Math.floor(new Date().getTime() / 1000);
let sign = "";
var params = Object.keys(data).sort();
for (var ki in params) {
sign +=
(sign.indexOf("=") !== -1 ? "&" : "") +
params[ki] +
"=" +
encodeURIComponent(data[params[ki]]);
}
data["sign"] = md5(md5(sign) + "e8aac119d38cee477e49d0155832b7f4" + time);
data["time"] = time;
uni.uploadFile({
url: BASE_URL + url, //仅为示例,非真实的接口地址
filePath: source.tempFiles[0].path,
name: "upload_resource",
formData: data,
success: function (res) {
res.data = JSON.parse(res.data);
uni.hideLoading();
// uni.showToast({
// title: '图片上传成功',
// icon: 'success',
// duration: 1000
// })
if (data.returnAll) {
// 是否返回所有信息(成功或者失败都返回)
return resolve(res.data);
}
if (res.data.state) {
resolve(res.data);
} else {
uni.showToast({
title: res.data.message,
icon: "none",
});
}
},
fail: function (err) {
uni.hideLoading();
uni.showToast({
title: "加载失败,请退出后重试!",
icon: "none",
duration: 2000,
});
},
complete: function () {},
});
});
};
// form表单
export { BASE_URL, BASE_URL_IMG, request, Upload, UploadFile };