// pages/report/report.js const request = require("../../utils/request.js"); const login = require("../../utils/login.js"); const uploadImage = require('../../utils/uploadFile.js'); Page({ /** * 页面的初始数据 */ data: { uploadURL: request._debug ? 'test/toktok/report/report_image/' : 'toktok/report/report_image/', TypeList: [ {name: '违法违规', value:'Illegal'}, {name: '色情低俗', value:'Porn'}, {name: '虚假不实', value:'Fake'}, {name: '谩骂攻击', value:'Obloquy'}, {name: '其他', value:'Other'} ], imgList: [], parmas: { targetType: '', reason: '', targetId: '', reportType: '', imgUrls: '' } }, submitFun() { let that = this; that.data.parmas.imgUrls = that.data.imgList.join(';'), request.postData( 'app/op/report', that.data.parmas, res => { wx.showToast({ title: '举报成功', icon: 'none', duration: 2000 }) setTimeout(function () { wx.navigateBack({ delta: 1 }) }, 3000) } ) }, delFun(event) { let index = event.currentTarget.dataset.idx; this.data.imgList.splice(index,1) this.setData({ imgList: this.data.imgList }) }, uploadImg() { let that = this; let count = Number(3 - that.data.imgList.length); wx.chooseMedia({ count: count, mediaType: ['image'], sourceType: ['album', 'camera'], success(res) { console.log(res) const tempFiles = res.tempFiles; tempFiles.forEach(function(value, index) { uploadImage(value.tempFilePath, that.data.uploadURL, function(res) { that.data.imgList.push(res) that.setData({ imgList: that.data.imgList }) }, function(res) { console.log(res) }) }) } }) }, getbindinput(event) { this.data.parmas.reason = event.detail.value; this.setData({ parmas: this.data.parmas }) }, checkTypeFun(event) { this.data.parmas.reportType = event.currentTarget.dataset.value; this.setData({ parmas: this.data.parmas }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { login.getAssumeRole() this.data.parmas.targetType = options.targetType; this.data.parmas.targetId = options.targetId; this.setData({ parmas: this.data.parmas }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })