Files
SkinCamera/pages/index/index.uvue
T
2026-03-12 20:25:20 +08:00

77 lines
1.8 KiB
Plaintext

<template>
<!-- #ifdef APP -->
<scroll-view class="page-scroll-view">
<!-- #endif -->
<view>
<button @click="_takePhoto">拍照</button>
<xf-camera style="height:750rpx; background-color: red;" @error="onError" :flash="flash"
:position="device"></xf-camera>
<image v-if="imagePath" mode="aspectFit" :src="imagePath"></image>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
import {
takePhoto,
TakePhotoOption,
TakePhotoSuccessCallbackResult,
GeneralCallbackResult
} from '@/uni_modules/XF-cameraUTS'
export default {
data() {
return {
yanse: "red",
widthNum: 750,
heightNum: 200,
flash: "on",
device: "front",
imagePath: "",
videoPath: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4"
}
},
onLoad() {
// let permissionNeed = ["android.permission.CAMERA", "android.permission.RECORD_AUDIO",
// "android.permission.WRITE_EXTERNAL_STORAGE"]
// // 请求权限
// UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permissionNeed, function (allRight : boolean, _ : string[]) {
// if (allRight) {
// // 权限请求成功
// } else {
// //用户拒绝了部分权限
// }
// }, function (_ : boolean, _ : string[]) {
// //用户拒绝了部分权限
// })
},
methods: {
onError(res : any) {
console.log(res)
},
_takePhoto() {
takePhoto({
success: (res : TakePhotoSuccessCallbackResult) => {
console.log('takePhoto', res)
this.imagePath = res.tempImagePath;
// _previewImage();
},
fail: (res : GeneralCallbackResult) => {
console.log('takePhoto', res)
}
} as TakePhotoOption)
}
}
}
</script>
<style>
.video {
width: 100%;
height: 200px;
}
</style>