const app = getApp() const util = require("../../utils/jmsUtil.js"); const api = require('../../api/jms.js'); import moment from 'moment' Page({ data: { id:'', orderInfo:{ state:'', }, itemList:[], showPicker:false, currentItem:'', supplyList:[{name:'',num:1},{name:'',num:1}], columns:['超时补差','携带大型设备'], }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(options); if(options.id){ this.setData({ id:options.id }); } }, getDiffOrderDetail(){ wx.showLoading({ title: '加载中...', }); util.request(api.getDiffDetail, { diffOrderId:this.data.id }, 'GET').then(res => { wx.hideLoading(); if (res.errno === 0) { this.setData({ orderInfo:res.data, itemList:res.data.itemList }); } }).catch(err => { wx.hideLoading(); }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, goEdit(){ app.globalData.diffId=this.data.id; wx.navigateTo({ url: '/pages/serviceSupply/serviceSupply?id='+this.data.id, }); }, minusNum(e){ let index=e.currentTarget.dataset.index; let num=e.currentTarget.dataset.num; if(num<=1){ wx.showToast({ title: '数量不能再少了', icon: 'none', duration: 3000 }); return false; }else{ let item='supplyList['+index+']'+'.num'; this.setData({ [item]:num-1, }); } }, addNum(e){ let index=e.currentTarget.dataset.index; let num=e.currentTarget.dataset.num; let item='supplyList['+index+']'+'.num'; this.setData({ [item]:num+1, }); }, delItem(e){ let index=e.currentTarget.dataset.index; let supplyList=this.data.supplyList; supplyList.splice(index, 1); this.setData({ supplyList: supplyList }); }, addItem(){ this.setData({ supplyList: this.data.supplyList.concat({name:''}), }) }, pickerCancel(){ this.setData({ showPicker:false }); }, showTypePicker(e){ let index=e.currentTarget.dataset.index; this.setData({ currentItem:index, showPicker:true }) }, pickerConfirm(e){ let value=e.detail.value; let index=e.detail.index; let item1='supplyList['+this.data.currentItem+']'+'.name'; this.setData({ [item1]:value, showPicker:false, }); }, previewImage: function () { wx.previewImage({ current: this.data.orderInfo.qrUrl, // 当前显示图片的http链接 urls: [this.data.orderInfo.qrUrl] // 需要预览的图片http链接列表 }) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getDiffOrderDetail(); }, onHide: function () { }, onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, })