剩余模块:生产退料

This commit is contained in:
2025-06-09 22:07:10 +08:00
parent 63a44af1d8
commit 03e22dd9f6
77 changed files with 2832 additions and 817 deletions

View File

@@ -1,6 +1,6 @@
import env from './env';
// import uniChat from "./uniChat";
export default function requst(url : string, type : string, params : any, header : object = {}, noMsg:boolean = true) {
export default function requst(url : string, type : string, params : any, header : object = {}, noMsg : boolean = true) {
// #ifndef APP-PLUS
uni.showLoading({
mask: true
@@ -9,61 +9,60 @@ export default function requst(url : string, type : string, params : any, header
// #ifdef APP-PLUS
plus.nativeUI.showWaiting();
// #endif
console.log('检查URL' + env.API_URL + url,)
console.log('检查TOKEN' + 'Bearer '+ uni.getStorageSync('TOKEN'),)
console.log(params);
// console.log('检查URL' + env.API_URL + url,)
// console.log('检查TOKEN' + 'Bearer '+ uni.getStorageSync('TOKEN'),)
console.log('检查请求体', params);
var apiHeader = ''
var headerObj = {}
if(url.indexOf('http') !== -1){
if (url.indexOf('http') !== -1) {
apiHeader = url
headerObj = {}
} else {
apiHeader = env.API_URL + url
headerObj = {
Authorization: 'Bearer '+ uni.getStorageSync('TOKEN') || ''
Authorization: 'Bearer ' + uni.getStorageSync('TOKEN') || ''
}
}
console.log(apiHeader);
// console.log(apiHeader);
return new Promise((resolve, reject) => {
uni.request({
url: apiHeader,
method: type,
data: params,
sslVerify:false,
sslVerify: false,
header: {
...headerObj
},
timeout: 5000,
success(result : any) {
console.log(result);
console.log('检查返回', result);
let res = result.data;
if (res.code === 200) {
resolve(res);
} else if (res.code == 401) {
// #ifdef APP-PLUS
plus.nativeUI.toast('登录状态失效,请重新登录');
// #endif
uni.showToast({
icon: 'none',
mask: true,
title: '登录状态失效,请重新登录',
duration: 2500,
})
// uni.removeStorageSync('TOKEN')
// uni.removeStorageSync('userInfo');
// uni.clearStorage();
// tools.jumpTo('/pages/client/account/login', {}, 0)
resolve(res)
} else {
if(!noMsg){
setTimeout(() => {
uni.showToast({
icon: 'none',
mask: true,
title: res.msg
})
// if (!noMsg) {
// setTimeout(() => {
// uni.showToast({
// icon: 'none',
// mask: true,
// title: res.msg
// })
// })
// }
console.log(res.msg,'========================================================');
setTimeout(() => {
uni.showToast({
title: res.msg,
icon: 'none',
mask: false,
duration:5000,
success: function () {
console.log('成功显示');
}
})
}
},1000)
uni.$u.toast(res.msg)
resolve(res)
}
},