// pages/storage/index/index.js import Scene from '../../index/scene' import Dialog from '../../../components/dialog/dialog' import { getPoundInfo, repeatPound, deletePound } from "../../../api/saas" const app = getApp() Scene({ /** * 页面的初始数据 */ data: { safeBottom: app.globalData.safeBottom, form: null, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if(options.id){ wx.showLoading({ title: '正在获取', mask: true }) getPoundInfo(options.id).then(result => { wx.hideLoading() this.setData({ safeBottom: app.globalData.safeBottom, form: result.data }) }).catch(err => { wx.hideLoading() util.showToast(err) }) } }, repeatForm: function(){ Dialog.confirm({ title: '温馨提示', message: '磅单数据有问题,确定重新过磅?' }).then(() => { wx.showLoading({ title: '正在处理', mask: true }) repeatPound(this.data.form.id).then(result => { wx.hideLoading() util.showBackToast('磅单处理成功') }).catch(err => { wx.hideLoading() util.showToast(err) }) }) }, deleteForm: function(){ Dialog.confirm({ title: '温馨提示', message: '确定删除该磅单?' }).then(() => { wx.showLoading({ title: '正在处理', mask: true }) deletePound(this.data.form.id).then(result => { wx.hideLoading() util.showBackToast('磅单已经删除') }).catch(err => { wx.hideLoading() util.showToast(err) }) }) }, submitForm: function(){ wx.redirectTo({ url: `/pages/storage/order-create/index?id=${this.data.form.id}` }) }, 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 }) } })