// pages/service/settle/settle.js Page({ /** * 页面的初始数据 */ data: { detail:'', text:true, imgUrl:[], img:[], message:0, save:true, type:9, tp:1, array: ['融创', '时代国际'], index:'' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, photo:function(){ var th = this; var img = th.data.img; var count = img.length; var num = 9 - count; if(num <= 0){ wx.showToast({ title: '最多能选9张图片', icon: 'none', duration: 2000 }) return; } wx.chooseImage({ count: num, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success(res) { // tempFilePath可以作为img标签的src属性显示图片 const tempFilePaths = res.tempFilePaths console.log(tempFilePaths); img = img.concat(tempFilePaths); th.setData({ text:false, img: img }) } }) }, del:function(e){ // console.log(e); var id = e.currentTarget.dataset.id; var th = this; var img = th.data.img; img.splice(id,1); th.setData({ img:img }) }, })