From 06c58cac4de288efcf0be440cef99595a1b4aff9 Mon Sep 17 00:00:00 2001 From: ljx120 <10717296+ljx120@user.noreply.gitee.com> Date: Fri, 3 Jan 2025 17:32:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E5=81=9A=E5=8D=95=E5=AE=A1=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/http/index.ts | 9 +- common/http/interface.ts | 79 +-- pages.json | 12 + pages/customOrder/customOrder.vue | 230 +++++++-- pages/customOrder/detail.vue | 795 ++++++++++++++++++++++++++++++ pages/customOrder/list.vue | 230 +++------ pages/maintenance/m-other.vue | 279 ++++++----- 7 files changed, 1266 insertions(+), 368 deletions(-) create mode 100644 pages/customOrder/detail.vue diff --git a/common/http/index.ts b/common/http/index.ts index 55423ad..2f2e538 100644 --- a/common/http/index.ts +++ b/common/http/index.ts @@ -1,5 +1,5 @@ import httpRequest from '../http/interface' - +import myconfig from '../http/config' export const postAction = (url : string, data = {}, headerCustom = {}) => { return httpRequest( url, @@ -32,4 +32,11 @@ export const deleteAction = (url : string, data = {}, headerCustom = {}) => { headerCustom ) } +export const uploadAction = (url : string, data = {}) => { + return httpRequest( + url, + '', + data, + ) +} // 默认全部导出 import api from '@/common/vmeitime-http/' \ No newline at end of file diff --git a/common/http/interface.ts b/common/http/interface.ts index 2bb3b40..36347c6 100644 --- a/common/http/interface.ts +++ b/common/http/interface.ts @@ -22,43 +22,62 @@ function httpRequest(url : string, method : any, data = {}, headerCustom = {}) { let base_url='' if(url.includes('/v1')){ base_url=myconfig.base_auth - }else if(url==='/fabric/info/all'||url==='/color/list'){ + }else if(url==='/fabric/info/all'||url==='/color/list'||url.includes('/fabric/info/craftPrice')){ base_url=myconfig.base_mes }else if(url.includes('fabric/craft')){ base_url=myconfig.base_process }else{ base_url=myconfig.base_scm } - uni.request({ - url: base_url + url, // 拼接基础URL和请求路径 - method: method, - data: data, // 如果是GET请求,data应该为null - header: finalHeader, - success: (res:any) => { - // 如果服务器返回的状态码为200,则认为是成功的响应 - if (res.data && res.data.code === 200) { - resolve(res.data); - }else if(res.data && res.data.code === 401){ - uni.showToast({ - icon:'error', - title:'登录过期!' - }) - uni.clearStorage() - uni.reLaunch({ - url:'/pages/login/login' - }) - reject(new Error('请求失败: ' + (res.data && res.data?.message || '未知错误'))); - }else { - uni.showToast({ - icon:'error', - title:res.data.msg - }) + if(url==='/upload'){ + uni.uploadFile({ + url: base_url + url, // 拼接基础URL和请求路径 + file: data, + header: { + 'Authorization': 'Bearer ' + token + }, + success: (uploadFileRes : any) => { + let res=JSON.parse(uploadFileRes.data) + resolve(res); } - }, - fail: (err) => { - reject(err); - } - }); + }) + }else{ + uni.request({ + url: base_url + url, // 拼接基础URL和请求路径 + method: method, + data: data, // 如果是GET请求,data应该为null + header: finalHeader, + success: (res:any) => { + // 如果服务器返回的状态码为200,则认为是成功的响应 + if (res.data && res.data.code === 200) { + resolve(res.data); + }else if(res.data && res.data.code === 401){ + uni.showToast({ + icon:'error', + title:'登录过期!' + }) + uni.clearStorage() + uni.reLaunch({ + url:'/pages/login/login' + }) + reject(new Error('请求失败: ' + (res.data && res.data?.message || '未知错误'))); + }else if(res.data && res.data.code === 401){ + uni.showToast({ + icon:'error', + title:'暂无权限!' + }) + }else{ + uni.showToast({ + icon:'error', + title:res.data.msg + }) + } + }, + fail: (err) => { + reject(err); + } + }); + } }); } diff --git a/pages.json b/pages.json index 9a3fe0d..40d68fb 100644 --- a/pages.json +++ b/pages.json @@ -267,6 +267,18 @@ "bounce": "none" } } + }, + { + "path" : "pages/customOrder/detail", + "style" : + { + "navigationStyle": "custom", + "enablePullDownRefresh": false, + "disableScroll": true, + "app-plus": { + "bounce": "none" + } + } } ], "globalStyle": { diff --git a/pages/customOrder/customOrder.vue b/pages/customOrder/customOrder.vue index adb764c..65dca6c 100644 --- a/pages/customOrder/customOrder.vue +++ b/pages/customOrder/customOrder.vue @@ -1,14 +1,23 @@