// pages/inspect/check.js Page({ /** * 页面的初始数据 */ data: { items: [ { name: '正常', value: '正常' }, { name: '异常', value: '异常' }, ], serverUrl: getApp().globalData.serverUrl, state:1, selected:false,         selected1:true, csry:"", isok:true         },     selected:function(e){         this.setData({             selected1:false,             selected:true         })     },     selected1:function(e){         this.setData({             selected:false,             selected1:true         })     }, /** * 生命周期函数--监听页面加载 */ radioChange: function (e) { this.setData({ state: e.detail.value, }); }, bindjclxChange: function (e) { this.setData({ jclxIndex: e.detail.value, }) this.data.jclx = this.data.jclxArray[e.detail.value].value this.changeItems(this.data.jclx) }, changeItems:function(val){ var x = [] for(var i=0;i { if (res.statusCode === 200) { this.data.jclxArray = res.data; this.setData({ jclxArray: res.data, //jclx: res.data[0].value//默认检查类型 }) } } }); wx.request({ url: this.data.serverUrl + 'api/equipment?a=detail&id=' + id, header: { 'content-type': 'application/json', // 默认值 'Cookie': getApp().globalData.sessionId, }, success: res => { if (res.statusCode === 200) { console.log(res.data) this.setData({ equipment:res.data }) wx.request({ url: this.data.serverUrl + 'api/equipmentcheckform/'+res.data.checkform, header: { 'content-type': 'application/json', // 默认值 'Cookie': getApp().globalData.sessionId, }, success: res => { if (res.statusCode === 200) { this.setData({ itemscheck:res.data.items, itemscheck0:res.data.items }) } wx.hideLoading(); } }); wx.request({ url: this.data.serverUrl + 'api/risk?a=steps&type=equipment', header: { 'content-type': 'application/json', // 默认值 'Cookie': getApp().globalData.sessionId, }, method:'post', data:{'name':res.data.name,'id':res.data.id,'areaid':res.data.area__id}, success: res => { if (res.statusCode === 200) { if(res.data.code==1){ this.setData({ steps:res.data.steps }) } } wx.hideLoading(); } }); } } }); }, submit:function(){ let data={ equipment:this.data.equipment.id, state:this.data.state, content:this.data.content } wx.showLoading({ title: '提交中', }) wx.request({ url: this.data.serverUrl + 'api/inspect?a=add', header: { 'content-type': 'application/json', // 默认值 'Cookie': getApp().globalData.sessionId, }, method:'POST', data:data, success: res => { if (res.statusCode === 200) { console.log(res.data) wx.navigateBack({ }) } wx.hideLoading(); } }); }, submit2: function () { wx.navigateTo({ url: '/pages/trouble/addtrouble?type=inspect', }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { let lst = getApp().globalData.selectPeopleList let nst = [] let nst1 = [] if (lst) { for (var i = 0; i < lst.length; i++) { nst.push(lst[i]['name']) nst1.push(lst[i]['id']) } this.setData({ csryname: nst.join(','), csry: nst1.join(','), }) } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, chooseImage: function (e) { var that = this wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success: function (res) { wx.showLoading({ title: '上传图片..', mask:true }) wx.uploadFile({ header: { 'content-type': 'application/json', // 默认值 'Cookie': getApp().globalData.sessionId, }, url: getApp().globalData.serverUrl + 'upfile', filePath: res.tempFilePaths[0], name: 'upfile', success(res) { wx.hideLoading() var obj = JSON.parse(res.data); that.data.itemscheck[e.currentTarget.dataset.index].img = getApp().globalData.serverUrl + obj['filepath'] that.setData({ itemscheck:that.data.itemscheck }) }, complete: function (res) { wx.hideLoading() } }) } }) }, previewImage: function (e) { console.log(e) var current = e.target.dataset.src wx.previewImage({ current: current, urls: [current] }) }, deleteImage: function (e) { var that = this; var index = e.currentTarget.dataset.index; //获取当前长按图片下标 wx.showModal({ title: '系统提醒', content: '确定要删除此图片吗?', success: function (res) { if (res.confirm) { that.data.itemscheck[index].img = null } else if (res.cancel) { return false } that.setData({ itemscheck: that.data.itemscheck }); } }) }, descChange: function(e){ var that = this that.data.itemscheck[e.currentTarget.dataset.index].desc=e.detail.value }, submit3: function () { var that = this if(!that.data.jclx){ wx.showToast({ title: '请选择巡检类型!', icon:'none' }) return } for(var i=0;i { if (res.statusCode === 200) { wx.request({ url: getApp().globalData.serverUrl + 'api/inspectitem?a=adds', header: { 'content-type': 'application/json', // 默认值 'Cookie': getApp().globalData.sessionId, }, method: 'POST', data: { 'inspect':res.data.inspect, 'items':data2 }, success: res => { if (res.statusCode === 200) { wx.redirectTo({ url: '/pages/inspect/index', }) } wx.hideLoading(); } }); } wx.hideLoading(); } }); }, })