// pages/process/order-check/index.js import Dialog from '../../../components/dialog/dialog' import { pricingOrder, cancelOrder, getFactoryOrderInfo, getPaperPrice} from "../../api/saas" const event = require('../../../utils/event') const util = require('../../../utils/util') const app = getApp() Page({ /** * 页面的初始数据 */ data: { safeBottom: app.globalData.safeBottom, paperList: null, form: null, deductType: 1, columns: [], visible: false }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if(options.id){ wx.showLoading({ title: '正在获取', mask: true }) getPaperPrice().then(result => { this.setData({ safeBottom: app.globalData.safeBottom, paperList: result.data }) }).catch(err => { wx.hideLoading() util.showToast(err) }) getFactoryOrderInfo(options.id).then(result => { wx.hideLoading() this.setData({ form: result.data }) }).catch(err => { wx.hideLoading() 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 }) } }, showCategory: function(){ this.setData({ visible: true }) }, onConfirm: function({ picker, value, index }){ this.setData({ visible: false }) }, onHide: function(){ this.setData({ visible: false }) }, changeDeductType: function(e){ if(e.currentTarget.dataset.type == 1){ this.setData({ deductType: e.currentTarget.dataset.type, [form.deductPercent]: null }) } else { this.setData({ deductType: e.currentTarget.dataset.type, [form.deductWeight]: null }) } }, bindInput: function (e) { this.data.form[e.target.id] = e.detail.value }, onChange: function({ detail }) { // 需要手动对 checked 状态进行更新 this.setData({ ['form.isDefault']: detail ? 1 : 0 }) }, paddingOrder: function(){ this.setData({ ['form.weighingType']: !this.data.form.weighingType }) }, cancelOrder: function(e){ Dialog.confirm({ title: '温馨提示', message: '确定取消该订单?' }).then(() => { wx.showLoading({ title: '处理中', mask: true }) cancelOrder({ id: this.data.form.id }).then(result => { wx.hideLoading() util.showBackToast('订单已经删除') event.emit('OrderMessage', { what: 12, desc: 'cancelOrder' }) }).catch(err => { wx.hideLoading() util.showToast(err) }) }) }, priceOrder: function(){ wx.showLoading({ title: '处理中', mask: true }) pricingOrder(this.data.form).then(result => { wx.hideLoading() util.showBackToast('定价成功') event.emit('OrderMessage', { what: 12, desc: 'pricingOrder' }) }).catch(err => { wx.hideLoading() util.showToast(err) }) }, viewImage: function (e) { var imgList = [] for (let index = 0; index < this.data.form.preWeighingPicture.length; index++) { imgList.push(this.data.this.data.form.preWeighingPicture[index].url) } wx.previewImage({ urls: imgList, current: e.currentTarget.dataset.url }) } })