// packageH/newDraw/lotteryComplaint/lotteryComplaint.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { reason: "", photosize: 1024 * 1024 * 3, fileList: [], imgList: [], sendStatus: false }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, afterRead(event) { let that = this; const { file } = event.detail; let urlStr = app.getNetAddresss('upload.uploadPic'); // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式 wx.uploadFile({ url: urlStr, filePath: file.url, name: 'file', formData: null, success(res) { // 上传完成需要更新 fileList let _res = JSON.parse(res.data); const { fileList = [] } = that.data; fileList.push({ ...file, url: _res.data.img_url }); that.data.imgList.push(_res.data.img_url); that.setData({ fileList }); }, }); }, bindinput(event){ this.setData({ reason: event.detail.value }); }, ondelete(event){ this.data.imgList.splice(event.detail.index, 1); this.data.fileList.splice(event.detail.index, 1); }, send(){ let that = this; if(this.data.reason == ''){ wx.showToast({ title: '请描述投诉的内容', duration: 1000, icon: 'none' }); return; } if(this.data.sendStatus){ return; } this.setData({ sendStatus:true }); let urlStr = app.getNetAddresss('plugin.luck-draw.frontend.index.complaint'); app._postNetWork({ url: urlStr, data: { activity_id: this.options.id, reason: this.data.reason, image: this.data.imgList }, success: (resdata) => { let res = resdata.data; if (res.result == 1) { that.data.sendStatus = false; wx.showToast({ title: res.msg, duration: 1000, icon: 'none' }); setTimeout(() => { wx.navigateBack({ delta: 1 }); }, 1000); } else { that.data.sendStatus = false; wx.showToast({ title: res.msg, duration: 1000, icon: 'none' }); } }, fail: function (res) { that.data.sendStatus = false; console.log(res.msg); } }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } });