// pages/voyages/uploadDischarge/uploadDischarge.js import { postApi } from "../../../apis/api" import { uploadImage } from "../../../utils/uploadImage" Page({ data: { weighTime: '', carNum: '', receivingUnit: '', grossWeight: 0, tare: 0, netWeight: 0, fileObj: {} }, async uploadBill(e) { let { type } = e.currentTarget.dataset let postData = { type, voyageId: this.data.voyageId } let res = await uploadImage("/voyage/uploadVoyageWayBill", postData) let { fileKey, viewUrl, downloadUrl } = res.result this.setData({ fileKey, viewUrl, downloadUrl }) }, preview(e) { wx.previewImage({ urls: [e.currentTarget.dataset.src], }) }, reupload(e) { wx.showModal({ content: "是否重新上传?", confirmText: "确定", cancelText: "取消", success: res => { if (res.confirm) { this.uploadBill(e) } } }) }, async submit() { let { weighTime, carNum, receivingUnit, grossWeight, tare, netWeight, portId, voyageId, fileKey, viewUrl, downloadUrl } = this.data let postData = { loginAccountId: wx.getStorageSync('loginAccountId'), voyageId, portId, carNum, receivingUnit, grossWeight, tare, netWeight, weighTime: weighTime.replaceAll('-', '/') + " 00:00:00", fileKey, viewUrl, downloadUrl } let res = await postApi("/voyage/addCarLoadRecord", postData) wx.setStorageSync('addStatus', 'success') wx.navigateBack() }, onLoad(options) { this.setData({ voyageId: options.voyageId, portId: options.portId }) }, })