今天是在第二大学远程实习的第十五天,偷偷发个博客记录一下自己的成长哈哈(今天学习二手校园市场项目)
wxml:
<view class="ShangchuanTupianBiankuang">
<view>
<image wx:for="{{TupianLiebiao}}" wx:key="item" src="{{item}}" class="scTubpiandx"></image>
</view>
<view class="TupianShangchuanBufenAnniu" bindtap="uploadImage"> //绑定点击事件函数uploadImage
<text>+</text>
</view>
</view>
js
// 上传图片
uploadImage(){
var that=this;
var TupianDizhi;
var TupianLiebiao=this.data.TupianLiebiao
var TupianDizhiLiebiao=this.data.TupianDizhiLiebiao;
wx.chooseMedia({
count: 1,
mediaType: ['image'],
sourceType: ['album', 'camera'],
maxDuration: 30,
camera: 'back',
success: function(res){
console.log("得到的信息1",res.tempFiles[0].tempFilePath);
TupianDizhi=res.tempFiles[0].tempFilePath;
TupianLiebiao.push(TupianDizhi)
that.setData({
// 返回给页面展示信息
TupianLiebiao:TupianLiebiao
})
console.log("得到的信息2",TupianLiebiao);
wx.uploadFile({
filePath: TupianDizhi,
name: 'imgfile',
url: 'https://xx.uom.cn/ecmsapi/index.php?mod=ershou&act=pic',
success(res){
console.log("得到的信息3",res.data)
TupianDizhiLiebiao.push(res.data)
console.log("得到的信息4",TupianDizhiLiebiao)
}
})
}
})
},
效果: