61 lines
1.6 KiB
TypeScript
Raw Normal View History

2024-01-05 11:11:15 +08:00
import FileUtil from '../../../common/utils/File'
2024-07-31 13:47:40 +08:00
import { takePhoto } from '../../../common/service/videoService';
import promptAction from '@ohos.promptAction';
2025-03-04 21:34:12 +08:00
import { judgeConfig } from './judgeConfig'
2024-05-16 11:05:19 +08:00
2025-03-04 21:34:12 +08:00
interface Params {
userName: string
pwd: string
ip: string
port: string
rlls: string
pztd: string
2024-01-05 11:11:15 +08:00
}
2025-03-04 21:34:12 +08:00
export default class FilePhoto {
public mediaTest
2025-03-04 21:34:12 +08:00
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/', 0);
console.info('surenjun', '拍照结束' + JSON.stringify(res))
return res.base64
} catch (e) {
console.error('surenjun =>拍照异常' + JSON.stringify(e))
promptAction.showToast({
message: '拍照异常,请联系工程人员!',
duration: 2000
});
return ''
}
}
}
2025-03-04 21:34:12 +08:00
private fileUtil: FileUtil
2024-01-05 11:11:15 +08:00
constructor(context) {
2025-03-04 21:34:12 +08:00
(async () => {
2024-07-31 13:47:40 +08:00
//TODO 309参数 获取拍照摄像头拍照通道
2024-02-21 14:53:53 +08:00
const fileUtil = new FileUtil(context)
const strConfig =
await fileUtil.readFile('/mnt/hmdfs/100/account/device_view/local/files/duolun/config/config3.txt');
2024-02-21 14:53:53 +08:00
const config = JSON.parse(strConfig)
const { userName, ip, pwd, port, rlls, pztd } = config
2025-03-04 21:34:12 +08:00
this.params = {
userName,
pwd,
ip,
port,
rlls,
pztd
}
2024-02-21 14:53:53 +08:00
this.context = context
this.fileUtil = fileUtil
})()
2024-01-05 11:11:15 +08:00
}
}