// pages/signReview/signFor.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { id:'', info:{}, unloadWeight:'', fileList:[], }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log(options) this.setData({ id:options.id }) }, //图片上传 afterRead:function(event){ const { file } = event.detail; const { type } = event.currentTarget.dataset app.request.uploadDIY({ url: app.API.uploadImgMap, page: this, filePaths:file.url, setfiled:'file', params: {}, //isToken: false, isLoading: false, successFun: true }).then(res => { const imgArray = this.data[type]; imgArray.push({ ...file, url: app.host.BASEIMG_URL + JSON.parse(res.data).data.imageFile, imgUrl: JSON.parse(res.data).data.imageFile }); this.setData({ [type]: imgArray }); }) }, // 删除图片 deleteImg: function (event) { const { type } = event.currentTarget.dataset let getFileList = this.data[type]; getFileList.splice(event.detail.index, 1) this.setData({ [type]: getFileList }) }, //输入框实时更新 onChange: function (e) { this.setData({ unloadWeight: app.util.digitLength(e.detail) }) }, //表单提交 formSubmit: function ({detail:{value}}) { let warn='' let getfileList = this.data.fileList if (value.unloadWeight == '') { warn = "请填写卸货重量!"; }else if(getfileList.length<1){ warn = "请上传图片!"; } let fileNameList = [] let filePathList = [] getfileList.forEach((element,index) => { fileNameList.push('图片'+(index+1)+'.'+element.imgUrl.split('.')[1]) filePathList.push(element.imgUrl) }); value.fileNameList = fileNameList value.filePathList = filePathList // value.fileNameList = fileNameList.join(',') // value.filePathList = filePathList.join(',') if (warn != '') { app.util.checkForm(warn); } else { app.request.POST({ url: app.API.updateWeight, params: value, page: this, isLoadingTxt: '提交中...', isSubmitting: true, successFun: true }).then(res => { wx.showToast({ title: '签收成功', icon: 'success', duration: 2000, mask:true, complete: function () { setTimeout(() => { wx.navigateBack() }, 1500) //延迟时间 } }) }) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })