/* * 手太欠 * 愿这世界都如故事里一样 美好而动人~ */ Page({ /** * 页面的初始数据 */ data: { score : '', //水滴值 albumArr : [], //图片 disabled : false, //按钮状态 popStatus: false, //获得水滴弹出层状态 }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, // 上传商品封面图片 addAlbum(key){ wx.chooseMedia({ success : res => { let path = res.tempFiles.map((val, index) => { return { name: 'uploads' + index, uri : val.tempFilePath } }) for (let i = 0; i < path.length; i++){ wx.$api.file.uploadImg(path[i].uri, {}).then(updRes => { let albumArr = this.data.albumArr albumArr.push({ path: updRes.path, showpath: updRes.url }) this.setData({ albumArr }) }).catch(err => {}) } } }) }, // 图片预览 openImg(index){ let paths = this.data.albumArr.map(val => { return val.showpath }) wx.previewImage({ urls : paths, current : index, indicator: 'number' }) }, // 删除图片 removeImg(e){ wx.showLoading({ title: '加载中' }) let index = e.currentTarget.dataset.index, atalbum = this.data.albumArr wx.showToast({ title: '删除成功', icon : 'none' }) atalbum.splice(index,1) this.setData({ albumArr : atalbum }) }, // 发布反馈 writeform(e) { let newPictures = this.data.albumArr.map(val => { return val.path }) if(this.data.albumArr.length <= 0) { wx.showToast({ title: '缺少反馈图片', icon : 'none' }) return } let data = { content : e.detail.value.content, pictures : newPictures } wx.$api.index.surveysForm(data).then(res => { this.setData({ disabled: true }) if(res.data.score > 0) { this.setData({ score : res.data.score, popStatus: true }) return } wx.redirectTo({ url: "/pages/index/feeling/index" }) }).catch(err => {}) }, // 我知道了 knowClick() { this.setData({ popStatus: false }) wx.redirectTo({ url: "/pages/index/feeling/index" }) } })