Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
wangliang_wd
2024-08-05 16:11:43 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6ad683c192c46417d2e2fb3e78e76ed87772d6ec
6ad683c1
1 parent
b7879e13
feat:调整相机调用库
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
16 deletions
sight_harmony/features/wdComponent/src/main/ets/components/page/EditUserInfoPage.ets
sight_harmony/features/wdComponent/src/main/ets/utils/CameraPickerUtils.ets
sight_harmony/features/wdComponent/src/main/ets/utils/PhotoPickerUtils.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/EditUserInfoPage.ets
View file @
6ad683c
...
...
@@ -15,6 +15,7 @@ import { TrackConstants } from 'wdTracking/Index';
import { SPHelper } from 'wdKit/Index';
import { SpConstants } from 'wdConstant/Index';
import { photoPickerUtils} from '../../utils/PhotoPickerUtils';
import { cameraPickerUtils } from '../../utils/CameraPickerUtils';
@Entry
@Component
...
...
@@ -104,7 +105,7 @@ struct EditUserInfoPage {
}
})
}else {
photo
PickerUtils.getCamera().then(value => {
camera
PickerUtils.getCamera().then(value => {
if (value.length > 0) {
this.headerImg = value
}
...
...
sight_harmony/features/wdComponent/src/main/ets/utils/CameraPickerUtils.ets
0 → 100644
View file @
6ad683c
import { abilityAccessCtrl, common, Permissions } from '@kit.AbilityKit';
import { camera, cameraPicker as picker } from '@kit.CameraKit';
let mContext = getContext(this) as common.Context;
const PERMISSIONS: Array<Permissions> = [
'ohos.permission.READ_IMAGEVIDEO',
];
export class CameraPickerUtils {
async getCamera(){
this.pickerPermissions()
let pickerProfile: picker.PickerProfile = {
cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK
};
let pickerResult: picker.PickerResult = await picker.pick(mContext,
[picker.PickerMediaType.PHOTO], pickerProfile);
return new Promise<string>((success, fail) => {
if (pickerResult['resultCode'] === 0) {
success(pickerResult['resultUri'])
}
})
}
async pickerPermissions(){
///权限查询
const context = getContext(this) as common.UIAbilityContext;
const atManager = abilityAccessCtrl.createAtManager();
await atManager.requestPermissionsFromUser(context, PERMISSIONS);
}
}
export const cameraPickerUtils: CameraPickerUtils = new CameraPickerUtils();
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/utils/PhotoPickerUtils.ets
View file @
6ad683c
...
...
@@ -30,21 +30,21 @@ export class PhotoPickerUtils {
})
}
async getCamera(){
this.pickerPermissions()
let pickerProfile: cameraPicker.PickerProfile = {
cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK
};
let pickerResult: cameraPicker.PickerResult = await cameraPicker.pick(mContext,
[cameraPicker.PickerMediaType.PHOTO, cameraPicker.PickerMediaType.VIDEO], pickerProfile);
return new Promise<string>((success, fail) => {
if (pickerResult['resultCode'] === 0) {
success(pickerResult['resultUri'])
}
})
}
// async getCamera(){
// this.pickerPermissions()
//
// let pickerProfile: cameraPicker.PickerProfile = {
// cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK
// };
// let pickerResult: cameraPicker.PickerResult = await cameraPicker.pick(mContext,
// [cameraPicker.PickerMediaType.PHOTO, cameraPicker.PickerMediaType.VIDEO], pickerProfile);
//
// return new Promise<string>((success, fail) => {
// if (pickerResult['resultCode'] === 0) {
// success(pickerResult['resultUri'])
// }
// })
// }
async pickerPermissions(){
///权限查询
...
...
Please
register
or
login
to post a comment