案例:
html:
html
<view class="zhengjianCont fontSize30" style="margin-bottom: 40rpx;">
<view class="kuai">
<image binderror="imageOnloadError" bind:tap="upladPhoto" data-params="businessLicense" data-name="zhengZhaoGuanLi" class="kuaiImg" src="{{businessLicense?businessLicense:'/static/image.png'}}"></image>
<view style="margin-top: 10rpx;">营业执照照片</view>
</view>
</view>
js:
javascript
data: {
businessLicense: '',
},
upladPhoto(e) {
let that = this;
// 定义图片存储路径,增加年月文件夹分类
let folder = e.currentTarget.dataset.name + "/" + TIME.getYearMonth()
this.ossPromise(folder, e.currentTarget.dataset.params).then(resUrl => {
that.setData({
[e.currentTarget.dataset.params + 'OSS']: resUrl.path
})
}).catch(errr => {
console.log(errr)
wx.hideLoading()
return false
})
},