微信小程序开发相关

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张',
// })
// }
}
})
},
————————————————
版权声明:本文为CSDN博主「宋军涛」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/songjuntao8/article/details/114071211

posted @ 2021-03-12 13:24  宋军涛  阅读(27)  评论(0编辑  收藏  举报