diff --git a/api/index.js b/api/index.js index 6fbb7f9..4ca0afd 100644 --- a/api/index.js +++ b/api/index.js @@ -1,18 +1,16 @@ -import request from "@/utils/request"; +import request, { baseUrl } from "@/utils/request"; import { getToken, removeToken, removeUserInfo } from "@/utils/auth"; - export const getGoodsList = (params) => request('/erp/goods/list', params, 'get') export const getGoodsById = (params) => request('/erp/goods/queryById', params, 'get') -export const getAddrList = (params) => request('/erp/addrManager/list', params, 'get') - export const getOrderList = (params) => request('/erp/order/list', params, 'get') export const addOrder = (params) => request('/erp/order/add', params, 'post') export const editOrder = (params) => request('/erp/order/edit', params, 'post') +export const getStatusList = (params) => request('/erp/order/queryState', params, 'get') - +export const getAddrList = (params) => request('/erp/addrManager/list', params, 'get') export const addAddr = (params) => request('/erp/addrManager/add', params, 'post') export const editAddr = (params) => request('/erp/addrManager/edit', params, 'post') export const delAddr = (params) => request('/erp/addrManager/delete?id='+params, {} , 'delete') @@ -20,14 +18,10 @@ export const delAddr = (params) => request('/erp/addrManager/delete?id='+params, export const getCode = (params) => request('/sys/randomImage/' + params, {}, 'get') export const login = (params) => request('/sys/login', params, 'POST') - -export const getStatusList = (params) => request('/erp/order/queryState', params, 'get') - export const addCommit = (params) => request('/erp/bbs/add', params, 'post') export const getCommits = (params) => request('/erp/bbs/list', params, 'get') export const getCommit = (params) => request('/erp/bbs/queryById', params, 'get') - export const addCart = (params) => request('/erp/shoppingCart/add', params, 'post') export const delCart = (params) => request('/erp/shoppingCart/delete?id='+params, {} , 'delete') export const delCarts = (params) => request('/erp/shoppingCart/deleteBatch?ids='+params, {} , 'delete') @@ -41,7 +35,7 @@ export const uploadFile = (filePath) => { mask: true }) uni.uploadFile({ - url: 'http://47.100.35.222:8080/jeecg-boot/sys/common/upload', //仅为示例,非真实的接口地址 + url: baseUrl + '/sys/common/upload', //仅为示例,非真实的接口地址 filePath, name: 'file', header: { @@ -68,6 +62,14 @@ export const uploadFile = (filePath) => { return } const data = JSON.parse(res.data) + if (data.code === 500) + { + uni.showToast({ + title: data.message, + icon: 'none' + }) + return + } resolve(data.message) }, fail(e) { diff --git a/utils/request.js b/utils/request.js index f38d286..8f48ffc 100644 --- a/utils/request.js +++ b/utils/request.js @@ -5,7 +5,8 @@ * .then(res=>{console.log(res)}) */ import { getToken, removeToken } from "./auth"; -const baseUrl = 'http://47.100.35.222:8080/jeecg-boot'; +export const baseUrl = 'http://47.100.35.222:8080/jeecg-boot'; + async function request(mehtod, params, type = 'GET') { //创建一个名为request请求的方法函数 const token = getToken()