diff --git a/common/js/request.js b/common/js/request.js index 152556e..f2e1c7c 100644 --- a/common/js/request.js +++ b/common/js/request.js @@ -7,9 +7,9 @@ export default { uni.addInterceptor('request', { invoke(args) { // request 触发前拼接 url - // args.url = 'https://www.opsoul.com' + args.url; - args.url = 'http://127.0.0.1:80' + args.url; - // args.url = 'http://10.45.137.214:80' + args.url; + args.url = 'https://www.opsoul.com' + args.url; + // args.url = 'http://127.0.0.1:80' + args.url; + // args.url = 'http://10.45.111.215:80' + args.url; if (args.data) { args.data.deptId = globalData.deptId; args.data.from = globalData.from; @@ -224,11 +224,22 @@ export default { name: 'uploadFile' }) let resStr = res[1].data; - let resObj = {}; + let resObj = null; if (resStr != null && resStr.length > 0) { - resObj = JSON.parse(resStr); + try { + resObj = JSON.parse(resStr); + } catch(e) { + console.log(e) + } } - return resObj; + if (!resObj || resObj.code !== 0) { + uni.showToast({ + icon: 'error', + title: '上传失败' + }) + return ''; + } + return resObj.url; }, async listByStep(params = {goodsCategoryId : null}) { let res = await uni.request({ @@ -261,5 +272,13 @@ export default { data: params }) return res[1].data; + }, + async addGoods(params) { + let res = await uni.request({ + url: '/goods/goods/addGoods', + method: 'POST', + data: params + }) + return res[1].data; } } diff --git a/pages/my/master-occupancy.vue b/pages/my/master-occupancy.vue index 1531b33..acea66c 100644 --- a/pages/my/master-occupancy.vue +++ b/pages/my/master-occupancy.vue @@ -404,10 +404,8 @@ success: (res) => { // 上传图片 this.$request.uploadFile(res.tempFilePaths[0]).then((uploadRes) => { - // 成功后才存入缓存 - if (uploadRes.code === 0) { - imgList.push(uploadRes.url); - } + // 存入缓存 + imgList.push(uploadRes.url); }); } }); diff --git a/pages/my/new-serv.vue b/pages/my/new-serv.vue index 89bd3d5..f3ef1c4 100644 --- a/pages/my/new-serv.vue +++ b/pages/my/new-serv.vue @@ -9,11 +9,11 @@