// pages/process/order-check/index.js import Dialog from '../../../components/dialog/dialog' import { repeatOrder, getFactoryOrderInfo, checkingOrder, printOrder} from "../../../api/saas" const event = require('../../../utils/event') const util = require('../../../utils/util') const app = getApp() Page({ /** * 页面的初始数据 */ data: { safeBottom: app.globalData.safeBottom, form: null, title: '过磅详情' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if(options.id){ this.fetchOrderInfo(options.id) } }, fetchOrderInfo(id){ wx.showLoading({ title: '正在获取', mask: true }) getFactoryOrderInfo(id).then(result => { wx.hideLoading() if(result.data.status == 4){ this.data.title = '待付款' } else if(result.data.status == 5){ this.data.title = '已完成' } this.setData({ safeBottom: app.globalData.safeBottom, form: result.data, title: this.data.title }) }).catch(err => { wx.hideLoading() this.setData({ safeBottom: app.globalData.safeBottom }) util.showToast(err) }) }, showPlate: function (e) { this.keyboard = this.keyboard || this.selectComponent('#wux-keyboard') this.keyboard.show(this.data.form.plateNumber, 0) }, onPlatenumber: function({detail}){ if(detail && detail.plateNumber){ this.setData({ ['form.plateNumber']: detail.plateNumber }) } }, bindInput: function (e) { this.data.form[e.target.id] = e.detail.value }, onChange: function({ detail }) { // 需要手动对 checked 状态进行更新 this.setData({ ['form.isDefault']: detail ? 1 : 0 }) }, printOrder: function(){ wx.showLoading({ title: '正在获取', mask: true }) printOrder({id: this.data.form.id}).then(result => { wx.hideLoading() util.showToast('即将打印,请稍后') }).catch(err => { wx.hideLoading() util.showToast(err) }) }, paddingOrder: function(){ this.setData({ ['form.checking']: !this.data.form.checking }) }, paymentOrder: function(){ const that = this wx.navigateTo({ url: `/pages/process/payment/index?channel=1`, events: { onOrderChange: (data) => { if (data.what == 12) { that.fetchOrderInfo(that.data.form.id) } } }, success: function(res) { res.eventChannel.emit('onParam', that.data.form) } }) }, repeatOrder: function(e){ Dialog.confirm({ title: '温馨提示', message: '确定重新过皮重?' }).then(() => { wx.showLoading({ title: '正在获取', mask: true }) repeatOrder(this.data.form.id).then(result => { wx.hideLoading() util.showBackToast('订单已经处理') event.emit('OrderMessage', { what: 12, desc: 'cancelOrder' }) }).catch(err => { wx.hideLoading() util.showToast(err) }) }) }, checkOrder: function(){ wx.showLoading({ title: '正在获取', mask: true }) checkingOrder({ id: this.data.form.id }).then(result => { wx.hideLoading() util.showBackToast('订单审核已通过') event.emit('OrderMessage', { what: 12, desc: 'checkingOrder' }) }).catch(err => { wx.hideLoading() util.showToast(err) }) }, viewImage: function (e) { var imgList = [] if(e.currentTarget.dataset.type == 0){ for (let index = 0; index < this.data.form.totalWeighingPicture.length; index++) { imgList.push(this.data.form.totalWeighingPicture[index].url) } } else { for (let index = 0; index < this.data.form.emptyWeighingPicture.length; index++) { imgList.push(this.data.form.emptyWeighingPicture[index].url) } } wx.previewImage({ urls: imgList, current: e.currentTarget.dataset.url }) } })