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-09-16 15:45:15 +08:00
import { judgeConfig } from './judgeConfig'
2024-05-16 11:05:19 +08:00
2025-09-16 15:45:15 +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-09-16 15:45:15 +08:00
export default class FilePhoto {
2024-01-05 11:11:15 +08:00
public mediaTest
2025-09-16 15:45:15 +08:00
private params: Params
private context: any
2024-07-31 13:47:40 +08:00
public getPhoto = async () => {
2025-09-16 15:45:15 +08:00
const { params } = this;
if (!judgeConfig.isPhotoOpen) {
2024-07-31 13:47:40 +08:00
return ''
2025-09-16 15:45:15 +08:00
} else {
2024-07-31 13:47:40 +08:00
try {
2025-09-16 15:45:15 +08:00
console.info('surenjun', '拍照开始')
const res = await takePhoto(params, this.context, 'pz/', 2);
console.info('surenjun', '拍照结束' + JSON.stringify(res))
2024-07-31 13:47:40 +08:00
return res.base64
} catch (e) {
2025-01-02 17:50:08 +08:00
console.error('surenjun =>拍照异常' + JSON.stringify(e))
2024-07-31 13:47:40 +08:00
promptAction.showToast({
2025-01-02 17:50:08 +08:00
message: '拍照异常,请联系工程人员!',
2024-07-31 13:47:40 +08:00
duration: 2000
2024-07-10 19:39:13 +08:00
});
2024-07-31 13:47:40 +08:00
return ''
}
}
2024-01-05 11:11:15 +08:00
}
2025-09-16 15:45:15 +08:00
private fileUtil: FileUtil
2024-07-31 13:47:40 +08:00
2025-09-16 15:45:15 +08:00
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
})()
}
2024-01-05 11:11:15 +08:00
}