1515 </view >
1616 </view >
1717 </view >
18+ <!-- #ifdef APP-PLUS || MP-WEIXIN -->
19+ <view class =" uni-title uni-common-mt uni-common-pl" >摄像头位置</view >
20+ <view class =" uni-hello-text" >注意:部分 Android 手机下由于系统 ROM 不支持无法生效,打开拍摄界面后可操作切换</view >
21+ <view class =" uni-list" >
22+ <radio-group @change =" radioChange" >
23+ <label class =" uni-list-cell uni-list-cell-pd" v-for =" (item, index) in cameraList" :key =" item.value" >
24+ <radio :value =" item.value" :checked =" index === cameraIndex" >{{item.name}}</radio >
25+ </label >
26+ </radio-group >
27+ </view >
28+ <!-- #endif -->
1829 <template v-if =" ! src " >
1930 <view class =" uni-hello-addfile" @tap =" chooseVideo" >+ 添加视频</view >
2031 </template >
3546 title: ' chooseVideo' ,
3647 sourceTypeIndex: 2 ,
3748 sourceType: [' 拍摄' , ' 相册' , ' 拍摄或相册' ],
38- src: ' '
49+ src: ' ' ,
50+ cameraList: [{
51+ value: ' back' ,
52+ name: ' 后置摄像头' ,
53+ checked: ' true'
54+ },
55+ {
56+ value: ' front' ,
57+ name: ' 前置摄像头'
58+ },
59+ ],
60+ cameraIndex: 0
3961 }
4062 },
41- onUnload (){
63+ onUnload () {
4264 this .src = ' ' ,
43- this .sourceTypeIndex = 2 ,
44- this .sourceType = [' 拍摄' , ' 相册' , ' 拍摄或相册' ];
65+ this .sourceTypeIndex = 2 ,
66+ this .sourceType = [' 拍摄' , ' 相册' , ' 拍摄或相册' ];
4567 },
4668 methods: {
47- sourceTypeChange : function (e ) {
69+ radioChange (evt ) {
70+ for (let i = 0 ; i < this .cameraList .length ; i++ ) {
71+ if (this .cameraList [i].value === evt .target .value ) {
72+ this .cameraIndex = i;
73+ break ;
74+ }
75+ }
76+ },
77+ sourceTypeChange : function (e ) {
4878 this .sourceTypeIndex = e .target .value
4979 },
50- chooseVideo : function () {
80+ chooseVideo : function () {
5181 uni .chooseVideo ({
82+ camera: this .cameraList [this .cameraIndex ].value ,
5283 sourceType: sourceType[this .sourceTypeIndex ],
5384 success : (res ) => {
5485 this .src = res .tempFilePath
6091 </script >
6192
6293<style >
63- .video {width :100% ;}
64- </style >
94+ .video {
95+ width : 100% ;
96+ }
97+ </style >
0 commit comments