From 67ca7ae70b2865e2fe54e1d4c55901dc99d7e3ce Mon Sep 17 00:00:00 2001 From: Suk1No <674874220@qq.com> Date: Thu, 21 Aug 2025 16:41:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=20=E6=98=B5=E7=A7=B0=E3=80=81=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E4=BC=98=E5=8C=96=E5=8F=8A=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- order-app/src/api/order.js | 7 ++- order-app/src/api/user.js | 4 ++ order-app/src/common/http.js | 84 ++++++++++++++++++----------- order-app/src/pages/mine/mine.vue | 39 ++++++++++++-- order-app/src/pages/order/order.vue | 35 ++++++++++-- 5 files changed, 129 insertions(+), 40 deletions(-) diff --git a/order-app/src/api/order.js b/order-app/src/api/order.js index 02573e9..4a4189c 100644 --- a/order-app/src/api/order.js +++ b/order-app/src/api/order.js @@ -2,6 +2,9 @@ import http from '../common/http.js' export const splaceOrderApi = (parm) => { return http.post("/wxapi/order/splaceOrder", parm) } -export const getOrderListApi = (parm)=>{ - return http.get("/wxapi/order/getOrderList",parm) +export const getOrderListApi = (parm) => { + return http.get("/wxapi/order/getOrderList", parm) +} +export const cancelOrderApi = (parm) => { + return http.post("/wxapi/order/cancelOrder", parm) } \ No newline at end of file diff --git a/order-app/src/api/user.js b/order-app/src/api/user.js index 1f806b6..cf87bea 100644 --- a/order-app/src/api/user.js +++ b/order-app/src/api/user.js @@ -65,4 +65,8 @@ export const editAddressApi = (parm) => { export const getAddressApi = (parm) => { console.log("查询默认地址成功") return http.get("/wxapi/address/getAddress", parm) +} +//头像上传 +export const uploadImageApi = (parm) => { + return http.upload(parm) } \ No newline at end of file diff --git a/order-app/src/common/http.js b/order-app/src/common/http.js index c218975..b3d0922 100644 --- a/order-app/src/common/http.js +++ b/order-app/src/common/http.js @@ -1,40 +1,62 @@ - const baseUrl = 'http://localhost:8089' -//const baseUrl = 'http://192.168.31.70:8089' +const baseUrl = 'http://localhost:8089' +//const baseUrl = 'http://192.168.31.70:8089' const http = (options = {}) => { - return new Promise((resolve, reject) => { - uni.request({ - url: baseUrl + options.url || '', - method:options.type || 'GET' , - data: options.data || {}, - header: options.header || {}, - }).then((response) => { - console.log(response) - resolve(response.data); - }).catch(error => { - reject(error) - }) - }); + return new Promise((resolve, reject) => { + uni.request({ + url: baseUrl + options.url || '', + method: options.type || 'GET', + data: options.data || {}, + header: options.header || {}, + }).then((response) => { + console.log(response) + resolve(response.data); + }).catch(error => { + reject(error) + }) + }); } -const get=(url,data,options={})=>{ - options.type='get'; - options.data = data; - options.url = url; - return http(options) +const get = (url, data, options = {}) => { + options.type = 'get'; + options.data = data; + options.url = url; + return http(options) } const post = (url, data, options = {}) => { - options.type = 'post'; - options.data = data; - options.url = url; - return http(options) + options.type = 'post'; + options.data = data; + options.url = url; + return http(options) } const put = (url, data, options = {}) => { - options.type = 'put'; - options.data = data; - options.url = url; - return http(options) + options.type = 'put'; + options.data = data; + options.url = url; + return http(options) +} +const upload = (parm) => { + return new Promise((resolve, reject) => { + uni.uploadFile({ + url: baseUrl + parm.url, + filePath: parm.filePath, + name: 'file', + formData: { + openid: uni.getStorageSync('openid') + }, + header: { + // Authorization: uni.getStorageSync("token") + }, + success: (res) => { + resolve(res.data); + }, + fail: (error) => { + reject(error) + } + }) + }) } export default { - get, - post, - put + get, + post, + put, + upload } \ No newline at end of file diff --git a/order-app/src/pages/mine/mine.vue b/order-app/src/pages/mine/mine.vue index 1639e95..ec65605 100644 --- a/order-app/src/pages/mine/mine.vue +++ b/order-app/src/pages/mine/mine.vue @@ -1,15 +1,20 @@