123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <template>
- <view>
- <view class="show-view">
- <Ba-CameraView ref="cameraView" class="camera-view" :load="loadData">
- </Ba-CameraView>
- </view>
- <button @click="takePhoto" :sizeLimit="100">拍照</button>
- <button @click="startRecord" :sizeLimit="100">开始录制</button>
- <button @click="stopRecord" :sizeLimit="100">停止录制</button>
- <button @click="changeCamera" :sizeLimit="100">切换摄像头</button>
- <button @click="setPrese" :sizeLimit="100">设置清晰度</button>
-
- </view>
- </template>
- <script>
- const toast = uni.requireNativePlugin('Ba-Toast')
- export default {
- data() {
- return {
- obj: {
- src: null,
- text: null,
- vSrc: null
- },
- loadData: { //配置
- isToast: true,
- isShowVibrate:false,
- },
- msgList: []
- }
- },
- onReady() {
- this.setListener(); //设置监听
- },
- methods: {
- takePhoto() {
- this.$refs.cameraView.takePicture((res) => {
- this.showToast(res.msg)
- });
- },
- //开始录制
- startRecord() {
-
- },
- //停止录制
- stopRecord() {
-
- },
- //切换摄像头
- changeCamera() {
- // const _this = this
- // this.$refs.CameraPreviewPlus.changeCamera({}, res => {
- // _this.obj.text = JSON.stringify(res)
- // })
- },
- //设置清晰度
- setPrese() {
- const _this = this
- // 1 AVCaptureSessionPresetHigh
- // 2 AVCaptureSessionPresetMedium
- // 3 AVCaptureSessionPresetLow
- // 4 AVCaptureSessionPreset640x480
- // 5 AVCaptureSessionPreset1280x720
- // 6 AVCaptureSessionPreset1920x1080
- // 7 AVCaptureSessionPreset3840x2160
- // 0 AVCaptureSessionPresetPhoto
-
- },
-
- setListener() {
- this.$refs.cameraView.setListener((res) => {
- if (res.action == "error") {
- this.showToast(res.msg)
- }
- });
- },
- showToast(msg) {
- toast.showToast({
- title: msg
- });
- }
- }
- }
- </script>
- <style>
- .show-view {
- flex-direction: row;
- }
- .camera-view {
- width: 750rpx;
- height: 640rpx;
- background-color: #333333;
- }
- .r-flex {
- margin-top: 40rpx;
- margin-bottom: 40rpx;
- flex-wrap: wrap;
- flex-direction: row;
- }
- .color-view {
- height: 200rpx;
- width: 200rpx;
- border-width: 1rpx;
- border-style: solid;
- border-color: #333333;
- }
- </style>
|