const app = getApp(); const util = require("../../../util/util.js") Page({ data: { StatusBar: app.globalData.StatusBar, CustomBar: app.globalData.CustomBar, content: '', img_list:[], submit: false, img: '' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({submit:false}) }, confirm: function (e) { let img = this.data.img_list.join(","); let { content } = e.detail.value; let param = { img, content }; if( this.data.submit) return; util.http("User.Suggest", param, (errCode, res) => { util.showToast(errCode, "提交成功", res); if( errCode == 200){ this.setData({submit: true}) } }); }, ChooseImage() { let that = this wx.chooseImage({ count: 3, //默认9 sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 sourceType: ['album', 'camera'], //从相册选择 success: (res) => { for( let i in res.tempFilePaths ){ that.doUpload(res.tempFilePaths[i] ); } } }); }, doUpload(imgPath) { this.setData({ loadModal: true }); let img_list = this.data.img_list; if( img_list.length >3 ){ this.setData({loadModal: false }); return; } util.uploadFile(1, imgPath, (newPath) => { img_list.push( newPath ) this.setData({ img_list, loadModal: false }); }) }, DelImg(e) { var index = e.currentTarget.dataset.index;//获取data-src let img_list = this.data.img_list; wx.showModal({ title: '确认', content: '你确认要删除么?', cancelText: '再想想', confirmText: '确认', success: res => { if (res.confirm) { img_list.splice( index, 1) this.setData({img_list }) } } }) }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, goBack(){ wx.navigateBack({ delta:1 }) } })