168 lines
3.9 KiB
Plaintext
168 lines
3.9 KiB
Plaintext
<template>
|
|
<view class="page-container">
|
|
<view>
|
|
<live-pusher v-once id="livePusher" ref="livePusher" class="livePusher" mode="FHD" beauty="0" whiteness="0"
|
|
device-position="back" :auto-focus="false" :muted="true" :enable-camera="true" :enable-mic="true"
|
|
:zoom="true" :style="[{height: '350rpx' ,width:'100%'}]">
|
|
</live-pusher>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name:"ocr-camera",
|
|
data() {
|
|
return {
|
|
livePusher: null,
|
|
ready: true,
|
|
cameraHeight: '', //相机画面宽度
|
|
coverImage: null,
|
|
maCode:"",
|
|
codeData:{},
|
|
apDetection:"",
|
|
imgBeseUrl:"",
|
|
};
|
|
},
|
|
onReady() {
|
|
this.cameraHeight = uni.getSystemInfoSync().screenHeight * 0.22
|
|
console.log(this.cameraHeight)
|
|
this.init()
|
|
},
|
|
methods: {
|
|
//初始化相机
|
|
init() {
|
|
this.livePusher = uni.createLivePusherContext('livePusher', this);
|
|
console.log(this.livePusher)
|
|
setTimeout(() => {
|
|
this.startPreview()
|
|
}, 1000)
|
|
},
|
|
// 开始相机
|
|
startPreview() {
|
|
this.livePusher.startPreview({
|
|
success: () => {
|
|
console.log('相机初始化成功');
|
|
switch (plus.os.name) {
|
|
case 'Android':
|
|
break;
|
|
case 'iOS':
|
|
this.livePusher.switchCamera()
|
|
break
|
|
}
|
|
},
|
|
fail: (err) => {
|
|
console.log(err)
|
|
}
|
|
});
|
|
},
|
|
//截屏
|
|
handleInstruct(instruct) {
|
|
if (this.ready) {
|
|
this.ready = false
|
|
this.livePusher.snapshot({
|
|
success: (res) => {
|
|
console.log(res)
|
|
this.ready = true
|
|
this.$emit('getImage', res.message.tempImagePath)
|
|
}
|
|
})
|
|
}
|
|
},
|
|
// //编码检索
|
|
// async getCode(){
|
|
// let param = {
|
|
// "maCode":this.queryCodeParams.maCode,
|
|
// "unitId":this.queryParams.unitId,
|
|
// "proId":this.queryParams.proId
|
|
// }
|
|
// console.log(param)
|
|
// uni.request({
|
|
// url: '/material/back_apply_info/getMachine',
|
|
// method: 'get',
|
|
// data: param,
|
|
// success: res => {
|
|
// res = res.data;
|
|
// console.log(res)
|
|
// if(res.code==200){
|
|
// if(res.data&&res.data.length>0){
|
|
// this.codeData=res.data[0];
|
|
// }
|
|
// }else{
|
|
// uni.showToast({
|
|
// title: res.msg,
|
|
// icon: 'none',
|
|
// })
|
|
// }
|
|
// // if(res.rows&&res.rows.length>0){
|
|
// // this.codeData=res.rows[0];
|
|
// // }else{
|
|
// // uni.showToast({
|
|
// // title: '未检索到有效的设备编码!',
|
|
// // icon: 'none',
|
|
// // })
|
|
// // }
|
|
// },
|
|
// fail: err => {
|
|
// console.log(err)
|
|
// }
|
|
// })
|
|
// },
|
|
|
|
// //确认按钮
|
|
// async onHandleConfirm(){
|
|
// console.log(this.codeData.maId)
|
|
// if(this.codeData.maId==undefined){
|
|
// uni.showToast({
|
|
// title: '请先识别编码!',
|
|
// icon: 'none',
|
|
// })
|
|
// }else{
|
|
// let obj = {
|
|
// "maId":this.codeData.maId,
|
|
// "maCode":this.codeData.maCode,
|
|
// "typeId":this.codeData.typeId,
|
|
// "apDetection":this.apDetection,
|
|
// "bmFileInfos":this.bmFileInfos
|
|
// }
|
|
// let param = {
|
|
// "backApplyInfo":this.queryParams,
|
|
// "backApplyDetails":obj
|
|
// }
|
|
// console.log('333333333', param)
|
|
// uni.request({
|
|
// url: '/material/back_apply_info/insertApp',
|
|
// method: 'post',
|
|
// data: param,
|
|
// success: res => {
|
|
// res = res.data;
|
|
// console.log(res)
|
|
// if (res.code === 200) {
|
|
// uni.showToast({
|
|
// title: '添加成功!',
|
|
// icon: 'none',
|
|
// })
|
|
// this.queryCodeParams.maCode = ''
|
|
// this.codeData = {}
|
|
// }
|
|
// },
|
|
// fail: err => {
|
|
// console.log(err)
|
|
// }
|
|
// })
|
|
// }
|
|
|
|
// }
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.page-container {
|
|
display: flex;
|
|
height: auto;
|
|
flex-direction: column;
|
|
background-color: #f7f8fa;
|
|
padding: 24rpx;
|
|
}
|
|
</style> |