市北人才赋能平台 --小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

143 lines
3.2 KiB

// pages/topics/interactive/submitTopic/index.js
Page({
/**
* 页面的初始数据
*/
data: {
topicTitle:String,
topicDetail:String,
files:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
selectFile: this.selectFile.bind(this),
uplaodFile: this.uplaodFile.bind(this)
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
bindTextInput(e){
this.setData({
topicTitle:e.detail.value
})
},
bindTextAreaInput(e){
this.setData({
topicDetail: e.detail.value
})
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
upload: function (e) {
console.log(e)
var that = this;
wx.chooseImage({
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
that.setData({
files: that.data.files.concat(res.tempFilePaths)
});
}
})
},
chooseImage: function (e) {
console.log('啦啦啦')
// console.log(e)
// var that = this;
// wx.chooseImage({
// sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
// sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
// success: function (res) {
// console.log('啦啦啦')
// // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
// that.setData({
// files: res.tempFilePaths
// });
// }
// })
},
// previewImage: function (e) {
// console.log(e)
// wx.previewImage({
// current: e.currentTarget.id, // 当前显示图片的http链接
// urls: this.data.files // 需要预览的图片http链接列表
// })
// },
uploadError(e) {
console.log('upload error', e.detail)
},
uploadSuccess(e) {
console.log('upload success', e.detail)
},
selectFile(files) {
console.log('files', files)
// 返回false可以阻止某次文件上传
},
uplaodFile(files) {
console.log('upload files', files)
// 文件上传的函数,返回一个promise
return new Promise((resolve, reject) => {
setTimeout(() => {
reject('some error')
}, 1000)
})
},
deleteFile(e){
console.log(e.detai)
},
submit(){
console.log(this.data.topicTitle,this.data.topicDetail)
console.log(this.data.files)
}
})