|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function takePhoto() { |
|
|
function takePhoto() { |
|
|
console.log('输出内容', rotateDegree.value) |
|
|
|
|
|
if (prop.showStartPhoto) { |
|
|
|
|
|
let cameraContext = null |
|
|
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
|
|
cameraContext = uni.createCameraContext(); |
|
|
|
|
|
// #endif |
|
|
|
|
|
// #ifdef MP-ALIPAY |
|
|
|
|
|
cameraContext = uni.createCameraContext('camera'); |
|
|
|
|
|
// #endif |
|
|
|
|
|
// 调用拍照方法 |
|
|
|
|
|
cameraContext.takePhoto({ |
|
|
|
|
|
quality: 'normal', |
|
|
|
|
|
success: (res : any) => { |
|
|
|
|
|
// 在这里处理拍照成功后的逻辑,res.tempImagePath 为拍照的图片路径 |
|
|
|
|
|
// srcImg.value = res.tempImagePath |
|
|
|
|
|
startPhoto.value = false |
|
|
|
|
|
cameraContext.stopRecord(); |
|
|
|
|
|
emit('confirmReturn', res) |
|
|
|
|
|
// getViewPosition(res.tempImagePath) |
|
|
|
|
|
return |
|
|
|
|
|
// console.log('拍照成功:', res.tempImagePath); |
|
|
|
|
|
}, |
|
|
|
|
|
fail: (error) => { |
|
|
|
|
|
console.error('拍照失败:', error); |
|
|
|
|
|
emit('failReturn', error); |
|
|
|
|
|
}, |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
rotateDegree.value += 90 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
uni.authorize({ |
|
|
|
|
|
scope: 'scope.camera', |
|
|
|
|
|
complete(res) { |
|
|
|
|
|
console.log("res===",res) |
|
|
|
|
|
// 打开了拍照权限 |
|
|
|
|
|
if(res.errMsg=="authorize:ok"){ |
|
|
|
|
|
console.log('输出内容', rotateDegree.value) |
|
|
|
|
|
if (prop.showStartPhoto) { |
|
|
|
|
|
let cameraContext = null |
|
|
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
|
|
cameraContext = uni.createCameraContext(); |
|
|
|
|
|
// #endif |
|
|
|
|
|
// #ifdef MP-ALIPAY |
|
|
|
|
|
cameraContext = uni.createCameraContext('camera'); |
|
|
|
|
|
// #endif |
|
|
|
|
|
// 调用拍照方法 |
|
|
|
|
|
cameraContext.takePhoto({ |
|
|
|
|
|
quality: 'normal', |
|
|
|
|
|
success: (res : any) => { |
|
|
|
|
|
// 在这里处理拍照成功后的逻辑,res.tempImagePath 为拍照的图片路径 |
|
|
|
|
|
// srcImg.value = res.tempImagePath |
|
|
|
|
|
startPhoto.value = false |
|
|
|
|
|
cameraContext.stopRecord(); |
|
|
|
|
|
emit('confirmReturn', res) |
|
|
|
|
|
// getViewPosition(res.tempImagePath) |
|
|
|
|
|
return |
|
|
|
|
|
// console.log('拍照成功:', res.tempImagePath); |
|
|
|
|
|
}, |
|
|
|
|
|
fail: (error) => { |
|
|
|
|
|
console.error('拍照失败:', error); |
|
|
|
|
|
emit('failReturn', error); |
|
|
|
|
|
}, |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
rotateDegree.value += 90 |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
title: '提示', |
|
|
|
|
|
content: '请打开摄像头权限', |
|
|
|
|
|
success: function (res) { |
|
|
|
|
|
if (res.confirm) { |
|
|
|
|
|
uni.openSetting({ |
|
|
|
|
|
success(res) { |
|
|
|
|
|
console.log("2222") |
|
|
|
|
|
console.log(res.authSetting) |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (res.cancel) { |
|
|
|
|
|
console.log('用户点击取消'); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log('输出内容', '===123') |
|
|
// console.log('输出内容', '===123') |
|
|
|
|
|
|
|
|
} |
|
|
} |