1.动态加载class
<view class='{{paytypeindex==1? "row": "rowhide"}}' bindtap="searchSupplier">
<label class="required">付款公司</label>
<input placeholder-class="place-holder" placeholder="付款公司" value="{{supplier.item.text}}" readonly="readonly" />
<mp-icon icon="arrow" color="orange" size="{{10}}"></mp-icon>
</view>
2.选取图片js代码
choose: function() { //这里是选取图片的方法
let that = this;
const url= config.order_uploadimgUrl
wx.chooseImage({
count: 9, // 最多可以选择的图片张数,默认9
sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
success: function(res) {
//----------
wx.uploadFile({
filePath: res.tempFilePaths[0],
name: 'ycwx',
url: url,
header: {
'Content-Type': 'multipart/form-data',
},
formData:{
method: 'POST'
},
success:function(upres){
//"{"data":["1_54f71248-37ea-472e-93a7-460be7c69c8a.jpg"],"code":1,"message":""}"
let updata = JSON.parse(upres.data)
if(updata.code===1){
let img=updata.data[0]
let imgs=that.data.imageList
if (that.data.imageList.length <= 8) {
imgs.push({localimg:res.tempFilePaths,simg:img})
that.setData({imageList: imgs})
} else {
wx.showModal({
title: '提示',
content: '一次上传不要超过10张',
})
}
}
},
fail:function(upres){
console.log(upres)
}
})
//----------
console.log("res", res.tempFilePaths);
// let imgs=that.data.imageList
// if (that.data.imageList.length <= 8) {
// imgs.push(res.tempFilePaths)
// that.setData({
// imageList: imgs
// })
// } else {
// wx.showModal({
// title: '提示',
// content: '一次上传不要超过10张',
// })
// }
}
})
},