// pages/project/check/index.js const app = getApp() Page({ toastShow(msgTitle) { const toast = this.selectComponent('#submitToast'); toast.linShow({ title: msgTitle, duration: 5000 }); }, toastHide(msgType) { const toast = this.selectComponent('#submitToast'); toast.linHide(); if (msgType == '1') { wx.navigateBack({delta: 2}); } }, //上传文件 uploadFile() { let that = this; wx.chooseMessageFile({ success(res) { const tempFiles = res.tempFiles for (let i = 0; i < tempFiles.length; i++) { let _path = tempFiles[i].path; let _name = tempFiles[i].name; if (tempFiles[i] == 'image') { _name = '图片文件.jpg'; } wx.uploadFile({ url: app.globalData.serverUrl + '/baseService/gtzz/uploadFile', filePath: _path, name: 'file', formData: { 'progress_id': that.data.progressId, 'document_type_id': that.data.documentTypeId, 'fileName': _name }, success(res) { that.getProgressFiles(); } }); } } }); }, //上传图片 uploadImg() { let that = this; wx.chooseImage({ success(res) { const tempFilePaths = res.tempFilePaths for (let i = 0; i < tempFilePaths.length; i++) { let tempFilePath = tempFilePaths[i]; wx.uploadFile({ url: app.globalData.serverUrl + '/baseService/gtzz/uploadFile', filePath: tempFilePath, name: 'file', formData: { 'progress_id': that.data.progressId, 'document_type_id': that.data.documentTypeId, 'fileName': '图片文件.jpg' }, success(res) { that.getProgressFiles(); } }); } } }); }, //获取指定步骤下的文件 getProgressFiles() { let that = this; wx.request({ url: app.globalData.serverUrl + '/baseService/gtzz/getProgressFiles', method: "GET", header: { 'content-type': 'application/json; charset=utf-8', 'cookie': wx.getStorageSync('sessionid') }, data: { progress_id: that.data.progressId }, success(res) { that.setData({ fileList: res.data.data }); } }); }, //监听输入框内容 inputValue(e) { this.setData({ message: e.detail.value }) }, /** * 页面的初始数据 */ data: { //1:通过 2:退回 3:不通过 checkType: '', documentTypeId: '', progressId: '', message: '', fileList: [] }, checkSubmit() { let that = this; let _message = this.data.message; if (_message.length == 0) { that.toastShow('验收意见不允许为空!'); setTimeout(function(){that.toastHide('0')}, 3000); return; } let _url = ''; let _checkType = this.data.checkType; if (_checkType == '1') { _url = '/gtzz/pass'; } else if (_checkType == '2') { _url = '/gtzz/back'; } else { _url = '/gtzz/refuse'; } wx.request({ url: app.globalData.serverUrl + '/baseService' + _url, method: "POST", header: { 'content-type': 'application/x-www-form-urlencoded', 'cookie': wx.getStorageSync('sessionid') }, data: { progress_id: this.data.progressId, message: _message }, success(res) { if (res.data.success) { that.toastShow('提交成功!'); setTimeout(function () { that.toastHide('1') }, 1500); } else { that.toastShow(res.data.message); setTimeout(function () { that.toastHide('0') }, 3000); } } }); }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ checkType: options.checkType, documentTypeId: options.documentTypeId, progressId: options.progressId }); this.getProgressFiles(); }, /** * 生命周期函数--监听页面显示 */ onShow: function () { } })