// pages/workDetail/workDetail.js var app = getApp() Page({ data: { iconShow: false, //是否显示图标弹窗 commitShow:false, //上报组长 inpShow:true, //显示输入框还是显示完成 detail:[], one:false, two:false, three:false, four:false, id:'', value:'' }, onLoad: function(options) { var that = this; that.setData({id:options.id}) that.status() }, input:function(e){ console.log(e) this.setData({value:e.detail.value}) }, status:function(){ var that = this; app.request('work_order/workOrderDetail?work_order_id=' + that.data.id, '', 'GET').then(res => { console.log(res) that.setData({ detail: res.data }) if (res.data.planned == 4) { that.setData({ one: true, two: true, three: true, four: true }) } else if (res.data.planned == 3) { that.setData({ one: true, two: true, three: true }) } else if (res.data.planned == 2) { that.setData({ one: true, two: true }) } else if (res.data.planned == 1) { that.setData({ one: true }) } }) }, goHome:function(){ wx.reLaunch({ url: '/pages/logs/logs?bike_no=' + this.data.detail.bike_no, }) }, //打开图标弹窗 openICon() { if(this.data.detail.planned==4){ wx.showToast({ title: '已完成', icon:'none' }) }else{ this.setData({ iconShow: true }) } }, //关闭图标弹窗 closeIcon() { this.setData({ iconShow: false, commitShow:false, inpShow:false }) }, //领取工单 getWork(){ var that = this; app.request('work_order/receive?work_order_id='+this.data.id,'','GET').then(res=>{ console.log(res); that.status() wx.showToast({ title: '接单成功', icon:'none' }) that.setData({ iconShow:false}) }) }, //上报组长 reported(){ this.setData({ commitShow:true, iconShow: false, inpShow: true, }) }, //完成 finish(){ this.setData({ iconShow:false, commitShow: true, inpShow:false, }) }, //取消按钮 cancel(){ this.setData({ commitShow:false }) }, //确定按钮 submit(){ console.log(this.data.inpShow) var that = this; let condition = this.data.inpShow if (condition == true){ //调上报组长接口 var data = { work_order_id:that.data.id, remark:that.data.value } app.request('work_order/upgrade',data,'POST').then(res=>{ console.log(res); if(res.statusCode==200){ wx.showToast({ title: '上报成功', icon:'none' }) that.setData({inpShow: false, iconShow: false,commitShow: false}) that.status() } }) }else{ app.request('work_order/over?work_order_id='+that.data.id, '', 'GET').then(res => { console.log(res); if (res.statusCode == 200) { wx.showToast({ title: '处理完成', icon: 'none' }) that.setData({ inpShow: false, iconShow: false, commitShow: false }) that.status() } }) } }, onReady: function() { }, onShow: function() { }, onHide: function() { }, onUnload: function() { }, onPullDownRefresh: function() { }, onReachBottom: function() { }, onShareAppMessage: function() { } })