// pages/feedback/feedback.js Page({ /** * 页面的初始数据 */ data: { maxlength: 500, number: 0, value: "", imgs: [ { type: "video", url: "http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400" }, { type: "image", url: "https://img1.baidu.com/it/u=202543353,3627416815&fm=26&fmt=auto" }, { type: "image", url: "https://img0.baidu.com/it/u=745609344,230882238&fm=26&fmt=auto" }, { type: "image", url: "https://img0.baidu.com/it/u=286636366,3227707112&fm=26&fmt=auto" }, { type: "image", url: "https://img1.baidu.com/it/u=2450865760,444795162&fm=26&fmt=auto" }, { type: "image", url: "https://img0.baidu.com/it/u=4226275504,4103997964&fm=26&fmt=auto" }, { type: "image", url: "https://img0.baidu.com/it/u=2247422843,411257408&fm=26&fmt=auto" }, ] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, /** * 监听文本域 */ bindTextAreaInput(e) { this.setData({ number: e.detail.cursor, value: e.detail.value }) }, /** * 预览图片和视频 */ previewMedia(e) { let arr = this.data.imgs let current = e.currentTarget.dataset.index wx.previewMedia({ sources: arr, current }) }, /** * 删除列表项 */ onDeleteItem(e) { let imgs = this.data.imgs; imgs.splice(e.currentTarget.dataset.index, 1); this.setData({ imgs }) console.log(imgs) }, /** * 选择图片 */ chooseImage() { let that = this; let imgs = this.data.imgs; let count = 9 - this.data.imgs.length wx.chooseImage({ count, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success (res) { const tempFilePaths = res.tempFilePaths tempFilePaths.forEach((item) => { imgs.push({ type: 'image', url: item }) }) that.setData({ imgs }) } }) } })