提交 0bec2cfe 编写于 作者: 张磊

调整chooseImage和chooseVideo的示例支持useSystem。

上级 5296309a
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
confirm-type="done" /> confirm-type="done" />
</view> </view>
</view> </view>
<!-- #ifdef APP -->
<view class="uni-list-cell cell-pd"> <view class="uni-list-cell cell-pd">
<view class="uni-list-cell-left uni-label"> <view class="uni-list-cell-left uni-label">
屏幕方向 屏幕方向
...@@ -41,8 +41,18 @@ ...@@ -41,8 +41,18 @@
<view class="uni-list-cell-right" @click="chooseOrientationType"> <view class="uni-list-cell-right" @click="chooseOrientationType">
<text class="click-t">{{orientationType[orientationTypeIndex]}}</text> <text class="click-t">{{orientationType[orientationTypeIndex]}}</text>
</view> </view>
</view> </view>
<!-- #endif -->
<!-- #ifdef APP-ANDROID -->
<view class="uni-list-cell cell-pd">
<view class="uni-list-cell-left uni-label">
系统相册
</view>
<view class="uni-list-cell-right">
<switch :checked="useSystemChecked" @change="useSystemChange"></switch>
</view>
</view>
<!-- #endif -->
<view class="uni-list-cell cell-pd"> <view class="uni-list-cell cell-pd">
<view class="uni-list-cell-left uni-label"> <view class="uni-list-cell-left uni-label">
图像裁剪 图像裁剪
...@@ -144,7 +154,8 @@ ...@@ -144,7 +154,8 @@
cropPercent: 80, cropPercent: 80,
cropWidth: 100, cropWidth: 100,
cropHeight: 100, cropHeight: 100,
cropResize: false cropResize: false,
useSystemChecked:false
} }
}, },
onUnload() { onUnload() {
...@@ -191,6 +202,9 @@ ...@@ -191,6 +202,9 @@
}) })
} }
}, },
useSystemChange(e : UniSwitchChangeEvent){
this.useSystemChecked = e.detail.value
},
cropResizeChange(e : UniSwitchChangeEvent) { cropResizeChange(e : UniSwitchChangeEvent) {
this.cropResize = e.detail.value this.cropResize = e.detail.value
}, },
...@@ -250,6 +264,7 @@ ...@@ -250,6 +264,7 @@
crop: this.isCrop ? { "quality": this.cropPercent, "width": this.cropWidth, "height": this.cropHeight, "resize": this.cropResize } as ChooseImageCropOptions : null, crop: this.isCrop ? { "quality": this.cropPercent, "width": this.cropWidth, "height": this.cropHeight, "resize": this.cropResize } as ChooseImageCropOptions : null,
count: this.imageList.length + this.count[this.countIndex] > 9 ? 9 - this.imageList.length : this.count[this.countIndex], count: this.imageList.length + this.count[this.countIndex] > 9 ? 9 - this.imageList.length : this.count[this.countIndex],
pageOrientation: orientationTypeArray[this.orientationTypeIndex], pageOrientation: orientationTypeArray[this.orientationTypeIndex],
useSystem:this.useSystemChecked,
success: (res) => { success: (res) => {
this.imageList = this.imageList.concat(res.tempFilePaths); this.imageList = this.imageList.concat(res.tempFilePaths);
}, },
......
...@@ -12,8 +12,10 @@ ...@@ -12,8 +12,10 @@
<view class="uni-btn-v"> <view class="uni-btn-v">
<button type="primary" @click="chooseVideo">选取视频</button> <button type="primary" @click="chooseVideo">选取视频</button>
</view> </view>
<enum-data title="视频来源" :items="sourceTypeItemTypes" @change="onSourceTypeChange"></enum-data> <enum-data title="视频来源" :items="sourceTypeItemTypes" @change="onSourceTypeChange"></enum-data>
<!-- #ifdef APP -->
<enum-data title="屏幕方向" :items="orientationTypeItemTypes" @change="onOrientationTypeChange"></enum-data> <enum-data title="屏幕方向" :items="orientationTypeItemTypes" @change="onOrientationTypeChange"></enum-data>
<!-- #endif -->
<enum-data title="摄像头" :items="cameraItemTypes" @change="onCameraChange"></enum-data> <enum-data title="摄像头" :items="cameraItemTypes" @change="onCameraChange"></enum-data>
</view> </view>
<input-data title="最长拍摄时间,单位秒" defaultValue="60" type="number" @confirm="onMaxDurationConfirm"></input-data> <input-data title="最长拍摄时间,单位秒" defaultValue="60" type="number" @confirm="onMaxDurationConfirm"></input-data>
...@@ -22,6 +24,11 @@ ...@@ -22,6 +24,11 @@
<boolean-data title="是否压缩" :defaultValue="true" @change="onCompressedChange"></boolean-data> <boolean-data title="是否压缩" :defaultValue="true" @change="onCompressedChange"></boolean-data>
</view> </view>
<!-- #endif --> <!-- #endif -->
<!-- #ifdef APP-ANDROID -->
<view class="uni-padding-wrap">
<boolean-data title="使用系统相册" :defaultValue="false" @change="useSystemChange"></boolean-data>
</view>
<!-- #endif -->
<!-- #ifdef APP --> <!-- #ifdef APP -->
</scroll-view> </scroll-view>
<!-- #endif --> <!-- #endif -->
...@@ -35,19 +42,20 @@ ...@@ -35,19 +42,20 @@
data() { data() {
return { return {
title: "chooseVideo", title: "chooseVideo",
src: "", src: "",
orientationTypeItemTypes: [{ "value": 0, "name": "竖屏" }, { "value": 1, "name": "横屏" }, { "value": 2, "name": "自动" }] as ItemType[], orientationTypeItemTypes: [{ "value": 0, "name": "竖屏" }, { "value": 1, "name": "横屏" }, { "value": 2, "name": "自动" }] as ItemType[],
sourceTypeItemTypes: [{ "value": 0, "name": "从相册中选择视频" }, { "value": 1, "name": "拍摄视频" }, { "value": 2, "name": "从相册中选择视频或拍摄视频" }] as ItemType[], sourceTypeItemTypes: [{ "value": 0, "name": "从相册中选择视频" }, { "value": 1, "name": "拍摄视频" }, { "value": 2, "name": "从相册中选择视频或拍摄视频" }] as ItemType[],
sourceTypeItems: [["album"], ["camera"], ["album", "camera"]] as Source[][], sourceTypeItems: [["album"], ["camera"], ["album", "camera"]] as Source[][],
cameraItemTypes: [{ "value": 0, "name": "后置摄像头" }, { "value": 1, "name": "前置摄像头" }] as ItemType[], cameraItemTypes: [{ "value": 0, "name": "后置摄像头" }, { "value": 1, "name": "前置摄像头" }] as ItemType[],
cameraItems: ["back", "front"] as Camera[], cameraItems: ["back", "front"] as Camera[],
sourceType: ["album", "camera"] as Source[], sourceType: ["album", "camera"] as Source[],
orientationType: "portrait", orientationType: "portrait",
orientationTypeItems: ["portrait", "landscape", "auto"], orientationTypeItems: ["portrait", "landscape", "auto"],
compressed: true, compressed: true,
maxDuration: 60, maxDuration: 60,
camera: "back" as Camera, camera: "back" as Camera,
videoInfo: "" videoInfo: "",
useSystem: false
} }
}, },
methods: { methods: {
...@@ -55,11 +63,11 @@ ...@@ -55,11 +63,11 @@
uni.chooseVideo({ uni.chooseVideo({
sourceType: this.sourceType, sourceType: this.sourceType,
// #ifdef APP // #ifdef APP
compressed: this.compressed, compressed: this.compressed,
pageOrientation: this.orientationType, pageOrientation: this.orientationType,
// #endif // #endif
maxDuration: this.maxDuration, maxDuration: this.maxDuration,
useSystem:this.useSystem,
camera: this.camera, camera: this.camera,
success: (res) => { success: (res) => {
console.log("chooseVideo success", JSON.stringify(res)); console.log("chooseVideo success", JSON.stringify(res));
...@@ -74,9 +82,9 @@ ...@@ -74,9 +82,9 @@
}); });
} }
}); });
}, },
onOrientationTypeChange(value : number) { onOrientationTypeChange(value : number) {
this.orientationType = this.orientationTypeItems[value]; this.orientationType = this.orientationTypeItems[value];
}, },
onSourceTypeChange(value : number) { onSourceTypeChange(value : number) {
this.sourceType = this.sourceTypeItems[value]; this.sourceType = this.sourceTypeItems[value];
...@@ -89,6 +97,9 @@ ...@@ -89,6 +97,9 @@
}, },
onCameraChange(value : number) { onCameraChange(value : number) {
this.camera = this.cameraItems[value]; this.camera = this.cameraItems[value];
},
useSystemChange(value : boolean) {
this.useSystem = value
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册