wxImgChoose(type) {
console.log(type, "type");
console.log(this.$isInWXXCX, "111");
//使用jssdk调用摄像头拍照
if (!this.$isInWXXCX) {
return false;
}
var _this = this;
wx.checkJsApi({
jsApiList: ["chooseImage", "getLocalImgData"], // 需要检测的JS接口列表,所有JS接口列表见附录2,
success: function(res) {
wx.chooseImage({
count: 1, // 默认9
sizeType: ["original", "compressed"], // 指定是原图还是压缩图,默认都有
sourceType: ["album", "camera"], // 指定来源是相册还是相机,默认都有
success: function(res) {
var localIds = res.localIds;
wx.getLocalImgData({
// 获取本地图片
localId: localIds[0],
success: function(res) {
let localData = res.localData;
let checkImage = "";
console.log(localData, "localData"); // 在安卓和IOS中获取到格式稍微有点区别,具体看下图
if (localData.indexOf("base64") >= 0) {
//我传给后台的参数是不需要data:image/png;base64,所以去掉了。大家可以根据具体的业务需求对该格式做变化。
checkImage = localData.split(",")[1];
} else {
checkImage = localData;
}
if (type == "A") {
_this.idkCardFaceImg =
"data:image/png;base64," + checkImage;
_this.idShowFaceImg = "data:image/png;base64," + checkImage;
} else if (type == "B") {
_this.idCardBackImg = "data:image/png;base64," + checkImage;
_this.idShowBackImg = "data:image/png;base64," + checkImage;
}
}
});
}
});
},
fail: function(err) {}
});
终端Iphone8 系统13.5.1 微信版本7.0.14
checkJsApi 接口一直返回的是true 但是摄像头和图片选择器就没有唤起来
你好,是否有报错信息呢?