//点击选择图片
tapImage: function (e) {
var that= this
wx.chooseImage({
success: function (res) {
var tempFilePaths = res.tempFilePaths
that.setData({
filePath: tempFilePaths[0] //保存图片路径
})
console.log(tempFilePaths[0])
}
})
},
|
// 点击浏览
showImage(){
wx.previewImage({
current: '', // 当前显示图片路径
urls: [this.data.filePath] // 需要预览图片的路径
})
},
//上传文件
upload_data(){
var filePath = this.data.filePath
wx.getImageInfo({
src: filePath,
success: function (res) {
console.log(res.width)
console.log(res.height)
if (res.width != 600 && res.height !=900){
console.log('图片大小非600*900')
}
else{
console.log('准备上传...')
wx.uploadFile({
url: 'http://example.weixin.qq.com/upload', //接口地址
filePath: filePath,//文件路径
name: 'file',//文件名,不要修改,Flask直接读取
formData: {
'user': 'test'
}, // 其他表单数据,如地理位置、标题、内容介绍等
success: function (res) {
var data = res.data
console.log('上传成功...')
}
})
}
}
})
},
|