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 @@