61 lines
1.6 KiB
TypeScript
61 lines
1.6 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 {
|
|
public mediaTest
|
|
private params: Params
|
|
private context: any
|
|
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) {
|
|
console.error('surenjun =>拍照异常' + JSON.stringify(e))
|
|
promptAction.showToast({
|
|
message: '拍照异常,请联系工程人员!',
|
|
duration: 2000
|
|
});
|
|
return ''
|
|
}
|
|
}
|
|
}
|
|
private fileUtil: FileUtil
|
|
|
|
constructor(context) {
|
|
(async () => {
|
|
//TODO 309参数 获取拍照摄像头拍照通道
|
|
const fileUtil = new FileUtil(context)
|
|
const strConfig =
|
|
await fileUtil.readFile('/mnt/hmdfs/100/account/device_view/local/files/duolun/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
|
|
})()
|
|
}
|
|
} |