// pages/comment/cmment.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
mes:{},
content:'',
tempFilePaths:[],
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
images:[],
temp:0,
infoId:'',
sendtype:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options.infoId+"infoID")
this.setData({
infoId: options.infoId,
sendtype: options.sendtype
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
confirmSubmit:function(e){
console.log(e.detail.value)
},
//点击选择图片
chooseimage:function(){
var that = this;
wx.chooseImage({
count: 9, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function(res) {
that.setData({
tempFilePaths: that.data.tempFilePaths.concat(res.tempFilePaths)//在已有的基础上进行拼接
})
that.upload();
that.setData({
temp: that.data.tempFilePaths.length//用来解决 for 循环比 异步 快
})
}
})
},
//点击删除图片
delete: function (e){
var index = e.currentTarget.dataset.id;
this.data.tempFilePaths.splice(index,1)
//渲染数据
this.setData({
tempFilePaths: this.data.tempFilePaths
})
},
//提交评论