<view class="center">
<view class="controller" bindtap="addimg">
<text class="add">+</text><text class="add_text">添加图片</text>
</view>
<view class="hint">
<text>添加相关合作截图,会提高差评精准度和权威性,最多只支持9张图哦~</text>
</view>
</view>
<view class="addimg">
<image class="images" wx:for="{{tempFilePaths}}" wx:key="index" src="{{item}}">
<image class="del" src="/images/del.png" bindtap="delete" data-index="{{index}}"></image>
</image>
</view>
.center {
width: 90%;
margin: auto;
margin-top: 30rpx;
height: 100rpx;
}
.controller {
width: 200rpx;
height: 100rpx;
border-radius: 8rpx;
border: 1px dashed #0078E4;
float: left;
}
.hint {
width: 400rpx;
height: 100rpx;
float: left;
padding-left: 20rpx;
}
.hint text {
font-size: 24rpx;
}
.add {
font-size: 70rpx;
color: #0078E4;
float: left;
padding-left: 15rpx;
}
.add_text {
font-size: 30rpx;
float: left;
line-height: 100rpx;
}
addimg: function () {
var that = this
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
console.log(res.tempFilePaths, 'res.tempFilePaths')
let addimg = that.data.tempFilePaths
addimg.push(res.tempFilePaths)
that.setData({
tempFilePaths: addimg
})
}
})
},
delete: function (e) {
var imgs = this.data.tempFilePaths;
var index = e.currentTarget.dataset.index;
imgs.splice(index, 1);
this.setData({
tempFilePaths: imgs
});
},