123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- // 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() {
- }
- })
|