feat: 新增物料图标和优化UI组件
fix(入库页面): 修复重复箱检测和批次检查逻辑 refactor(请求模块): 优化错误处理和防抖机制 style(全局字体): 更改默认字体为数黑体 perf(扫码组件): 添加防抖处理避免重复提交 feat(卡片组件): 增加删除功能并优化样式 docs(工具函数): 添加入库工具函数文档 chore: 更新依赖和配置文件
This commit is contained in:
@@ -26,9 +26,9 @@ const request = config => {
|
||||
config.header = config.header || {}
|
||||
|
||||
// 假设你使用的是PHP作为你的后端语言
|
||||
config.header['Access-Control-Allow-Origin']= '*'; // 允许任何源访问
|
||||
config.header['Access-Control-Allow-Methods']='GET, POST, OPTIONS'; // 允许的HTTP方法
|
||||
config.header['Access-Control-Allow-Headers']= 'X-Requested-With'; // 允许的HTTP头
|
||||
config.header['Access-Control-Allow-Origin'] = '*'; // 允许任何源访问
|
||||
config.header['Access-Control-Allow-Methods'] = 'GET, POST, OPTIONS'; // 允许的HTTP方法
|
||||
config.header['Access-Control-Allow-Headers'] = 'X-Requested-With'; // 允许的HTTP头
|
||||
if (getToken() && !isToken) {
|
||||
config.header['Authorization'] = 'Bearer ' + getToken()
|
||||
config.header['userName'] = encodeURIComponent(store.getters.nickName ?? "未知用户")
|
||||
@@ -42,46 +42,49 @@ const request = config => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
uni.request({
|
||||
method: config.method || 'get',
|
||||
timeout: config.timeout || timeout,
|
||||
url: config.baseUrl || (storageBaseUrl + config.url),
|
||||
data: config.data,
|
||||
header: config.header,
|
||||
dataType: 'json'
|
||||
}).then(response => {
|
||||
let [error, res] = response
|
||||
//console.log('token:','Bearer ' + getToAccess-Control-Allow-Originken());
|
||||
//console.log('request:',storageBaseUrl + config.url,response);
|
||||
if (error) {
|
||||
showConfirm(error)
|
||||
// toast('后端接口连接异常')
|
||||
reject('后端接口连接异常')
|
||||
return
|
||||
method: config.method || 'get',
|
||||
timeout: config.timeout || timeout,
|
||||
url: config.baseUrl || (storageBaseUrl + config.url),
|
||||
data: config.data,
|
||||
header: config.header,
|
||||
dataType: 'json'
|
||||
}).then(response => {
|
||||
let [error, res] = response
|
||||
//console.log('token:','Bearer ' + getToAccess-Control-Allow-Originken());
|
||||
//console.log('request:',storageBaseUrl + config.url,response);
|
||||
if (error) {
|
||||
if (error.errMsg.includes('Failed to connect')) {
|
||||
toast('后台地址连接失败,请检查:' + (config.baseUrl || (storageBaseUrl + config.url)))
|
||||
} else {
|
||||
toast('后端接口连接异常')
|
||||
}
|
||||
const code = res.data.code || 200
|
||||
const msg = errorCode[code] || res.data.msg || errorCode['default']
|
||||
if (code === 401) {
|
||||
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
|
||||
if (res.confirm) {
|
||||
store.dispatch('LogOut').then(res => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login'
|
||||
})
|
||||
reject('后端接口连接异常')
|
||||
return
|
||||
}
|
||||
const code = res.data.code || 200
|
||||
const msg = errorCode[code] || res.data.msg || errorCode['default']
|
||||
if (code === 401) {
|
||||
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
|
||||
if (res.confirm) {
|
||||
store.dispatch('LogOut').then(res => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login'
|
||||
})
|
||||
}
|
||||
})
|
||||
reject('无效的会话,或者会话已过期,请重新登录。')
|
||||
} else if (code === 500) {
|
||||
// toast(msg)
|
||||
showConfirm(msg)
|
||||
reject('500')
|
||||
} else if (code !== 200) {
|
||||
// toast(msg)
|
||||
showConfirm(msg)
|
||||
reject(code)
|
||||
}
|
||||
resolve(res.data)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
reject('无效的会话,或者会话已过期,请重新登录。')
|
||||
} else if (code === 500) {
|
||||
// toast(msg)
|
||||
showConfirm(msg)
|
||||
reject('500')
|
||||
} else if (code !== 200) {
|
||||
// toast(msg)
|
||||
showConfirm(msg)
|
||||
reject(code)
|
||||
}
|
||||
resolve(res.data)
|
||||
})
|
||||
.catch(error => {
|
||||
let {
|
||||
message
|
||||
|
||||
Reference in New Issue
Block a user