Para abrir a câmera no projeto de aplicativo Android escrito por uniapp, você deve primeiro marcar esta opção no manifest.json:
Após alterar a configuração, você precisa recriar a base customizada para rodar, como fazer uma base customizada está neste link:
Ligue para a câmera e tire uma foto e envie a foto para o back-end:
methods: {
catchPhoto() {
//要保留一下this,不然在其他方法内部拿不到data里的数据
let that = this;
plus.camera.getCamera().captureImage(function(e) {
plus.io.resolveLocalFileSystemURL(e, function(entry) {
entry.file(function(file) {
that.img = entry.toLocalURL() //图片的本地路径
that.imgfile = file.name //图片的文件名
//上传文件到接口
uni.uploadFile({
url: 'http://xxxxxx',//要上传的地址
filePath: that.img,//图片的本地路径
name: that.imgfile,//图片的文件名
success: (res) => { //成功的回调
console.log(res);
},
})
})
}, function(e) {
console.log("读取拍照文件错误:" + e.message);
});
})
}
}