From 2feb321ba87286aa11d37e4f264f81f4f5b4d12a Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 9 Nov 2020 22:51:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=B7=A1=E6=A3=80=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E5=BF=85=E5=A1=AB=E5=9B=BE=E7=89=87=E6=88=96=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/inspect/add.js | 10 +++++++- project.config.json | 2 +- utils/request.js | 54 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 utils/request.js diff --git a/pages/inspect/add.js b/pages/inspect/add.js index b21986b..e739a20 100644 --- a/pages/inspect/add.js +++ b/pages/inspect/add.js @@ -31,7 +31,6 @@ Page({ * 生命周期函数--监听页面加载 */ radioChange: function (e) { - console.log('radio发生change事件,携带value值为:', e.detail.value); this.setData({ state: e.detail.value, }); @@ -315,6 +314,15 @@ submit:function(){ } let data2 = that.data.itemscheck for(var i=0;i { + wx.showNavigationBarLoading(); + wx.request({ + url: getApp().globalData.host + url, + method: method, + data: data, + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': getApp().globalData.sessionId, + }, + success: (res => { + if (res.data.code == 1) { + resolve(res.data); + }else if(res.data.code == -1){ + getApp().onLaunch() + wx.switchTab({ + url: '/pages/main/main', + }) + } + else { + var msg = '' + if(res.data){ + msg = res.data + } + wx.showToast({ + title: msg, + icon: 'none', + duration: 1000 + }) + } + + }), + fail: (res => { + wx.showToast({ + title: '请求出错', + icon: 'none', + duration: 1500 + }) + console.log(res) + reject('网络出错'); + }), + complete: function () { + wx.hideNavigationBarLoading(); + } + + }) + }) + return promise; +} + +module.exports = { + request: request +} \ No newline at end of file