// index.js // 获取应用实例 const app = getApp(); const util = require('../../../utils/jmsUtil.js'); const api = require('../../../api/jms.js'); import moment from 'moment' Page({ data: { isFinish:false, id:'', orderId:'', type:'', refusalRemark:'', noUserRemark:'', }, // 事件处理函数 onLoad(options) { if(options.id||options.type){ this.setData({ id:options.id, type:options.type, orderId:options.orderId }); } }, onshow(){ }, bindRrmark1(e){ this.setData({ refusalRemark:e.detail.value }); }, bindRrmark2(e){ this.setData({ noUserRemark:e.detail.value }); }, confTap(){ if(this.data.refusalRemark==''){ wx.showToast({ title: '请输入理由!', icon:'none' }); return false; } if(this.data.rnoUserRemark==''){ wx.showToast({ title: '请输入备注!', icon:'none' }); return false; } //如果是不通过 不用调用校验接口 if(this.data.type==4){ this.confirmPass(); }else{ wx.showLoading({ title: '加载中', }) let params={ id:this.data.id, orderId:this.data.orderId, amount:app.globalData.refundDetail.amount } util.request(api.PreRefundCheck, params , 'POST').then(res=>{ wx.hideLoading(); if(res.errno==0){ if (res.data.code == 0) { this.confirmPass(); }else if(res.data.code==1){ let that=this; wx.showModal({ title: '', confirmColor: '#b4282d', content: res.data.msg, success: function (res) { if (res.confirm) { that.confirmPass(); } } }) }else{ wx.showToast({ title: res.data.msg, icon:'none' }); } }else { wx.showToast({ title: res.errmsg, icon:'none' }); } }).catch(err=>{ wx.hideLoading(); }); } }, confirmPass(){ wx.showLoading({ title: '提交中', }) let params={ refusalRemark:this.data.refusalRemark, id:this.data.id, orderId:this.data.orderId, noUserRemark:this.data.noUserRemark, status:this.data.type } util.request(api.RefundisPass, params , 'POST').then(res=>{ wx.hideLoading(); if (res.errno == 0) { this.setData({ isFinish:true, }) wx.showModal({ title: '提示', content: '操作成功', showCancel:false, complete: (res) => { if (res.cancel) { } if (res.confirm) { wx.navigateBack({ delta:1 }); } } }) }else{ wx.showToast({ title: res.errmsg, icon:'none' }) } }).catch(err=>{ wx.hideLoading(); }); }, })