55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import FileUtil from '../../../common/utils/File'
|
|
import { takePhoto } from '../../../common/service/videoService';
|
|
import promptAction from '@ohos.promptAction';
|
|
import {judgeConfig} from './judgeConfig'
|
|
|
|
interface Params{
|
|
userName:string
|
|
pwd:string
|
|
ip:string
|
|
port:string
|
|
rlls:string
|
|
pztd:string
|
|
}
|
|
|
|
export default class FilePhoto{
|
|
|
|
private params:Params
|
|
private context:any
|
|
private fileUtil:FileUtil
|
|
public mediaTest
|
|
|
|
constructor(context) {
|
|
(async ()=>{
|
|
//TODO 309参数 获取拍照摄像头拍照通道
|
|
const fileUtil = new FileUtil(context)
|
|
const strConfig = await fileUtil.readFile('/mnt/hmdfs/100/account/device_view/local/files/config/config3.txt');
|
|
const config = JSON.parse(strConfig)
|
|
const {userName,ip,pwd,port,rlls,pztd} = config
|
|
this.params = {userName,pwd,ip,port,rlls,pztd}
|
|
this.context = context
|
|
this.fileUtil = fileUtil
|
|
})()
|
|
}
|
|
|
|
public getPhoto = async () => {
|
|
const {params} = this;
|
|
if(!judgeConfig.isPhotoOpen){
|
|
return ''
|
|
}else{
|
|
try {
|
|
console.info('surenjun','拍照开始')
|
|
const res = await takePhoto(params, this.context, 'pz/',2);
|
|
console.info('surenjun','拍照结束' + JSON.stringify(res))
|
|
return res.base64
|
|
} catch (e) {
|
|
promptAction.showToast({
|
|
message: '拍照异常,请重新' + JSON.stringify(e),
|
|
duration: 2000
|
|
});
|
|
return ''
|
|
}
|
|
}
|
|
}
|
|
|
|
} |