Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
d63d8923
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
d63d8923
编写于
11月 09, 2024
作者:
DCloud_iOS_WZT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update chooseImage、chooseVideo添加pageOrientation测试例
上级
41860ab9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
129 addition
and
92 deletion
+129
-92
pages/API/choose-image/choose-image.uvue
pages/API/choose-image/choose-image.uvue
+32
-4
pages/API/choose-video/choose-video.uvue
pages/API/choose-video/choose-video.uvue
+97
-88
未找到文件。
pages/API/choose-image/choose-image.uvue
浏览文件 @
d63d8923
...
...
@@ -32,7 +32,17 @@
<input class="click-t" :value="countIndex+1" type="number" :maxlength="1" @confirm="chooseImageCount"
confirm-type="done" />
</view>
</view>
</view>
<view class="uni-list-cell cell-pd">
<view class="uni-list-cell-left uni-label">
屏幕方向
</view>
<view class="uni-list-cell-right" @click="chooseOrientationType">
<text class="click-t">{{orientationType[orientationTypeIndex]}}</text>
</view>
</view>
<view class="uni-list-cell cell-pd">
<view class="uni-list-cell-left uni-label">
图像裁剪
...
...
@@ -111,6 +121,11 @@
['compressed'],
['original'],
['compressed', 'original']
]
var orientationTypeArray = [
'portrait',
'landscape',
'auto'
]
export default {
data() {
...
...
@@ -120,7 +135,9 @@
sourceTypeIndex: 2,
sourceType: ['拍照', '相册', '拍照或相册'],
sizeTypeIndex: 2,
sizeType: ['压缩', '原图', '压缩或原图'],
sizeType: ['压缩', '原图', '压缩或原图'],
orientationTypeIndex: 0,
orientationType: ['竖屏', '横屏', '自动'],
countIndex: 8,
count: [1, 2, 3, 4, 5, 6, 7, 8, 9],
isCrop: false,
...
...
@@ -136,7 +153,9 @@
this.sourceType = ['拍照', '相册', '拍照或相册']
this.sizeTypeIndex = 2
this.sizeType = ['压缩', '原图', '压缩或原图']
this.countIndex = 8
this.countIndex = 8
this.orientationTypeIndex = 0
this.orientationType = ['竖屏', '横屏', '自动']
},
methods: {
cropHeightConfim(e : InputConfirmEvent) {
...
...
@@ -196,6 +215,14 @@
this.sizeTypeIndex = e.tapIndex!
}
})
},
chooseOrientationType(){
uni.showActionSheet({
itemList: ['竖屏', '横屏', '自动'],
success: (e) => {
this.orientationTypeIndex = e.tapIndex!
}
})
},
chooseImageCount(event : InputConfirmEvent) {
let count = parseInt(event.detail.value) - 1
...
...
@@ -221,7 +248,8 @@
sourceType: sourceTypeArray[this.sourceTypeIndex],
sizeType: sizeTypeArray[this.sizeTypeIndex],
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],
success: (res) => {
this.imageList = this.imageList.concat(res.tempFilePaths);
},
...
...
pages/API/choose-video/choose-video.uvue
浏览文件 @
d63d8923
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<video class="video" :src="src" :controls="true"></video>
<view class="uni-title">
<text class="uni-subtitle-text">视频信息</text>
</view>
<text>{{videoInfo}}</text>
<view class="uni-btn-v">
<button type="primary" @click="chooseVideo">选取视频</button>
</view>
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<video class="video" :src="src" :controls="true"></video>
<view class="uni-title">
<text class="uni-subtitle-text">视频信息</text>
</view>
<text>{{videoInfo}}</text>
<view class="uni-btn-v">
<button type="primary" @click="chooseVideo">选取视频</button>
</view>
<enum-data title="视频来源" :items="sourceTypeItemTypes" @change="onSourceTypeChange"></enum-data>
<enum-data title="摄像头" :items="cameraItemTypes" @change="onCameraChange"></enum-data>
</view>
<input-data title="最长拍摄时间,单位秒" defaultValue="60" type="number" @confirm="onMaxDurationConfirm"></input-data>
<!-- #ifdef APP -->
<view class="uni-padding-wrap">
<boolean-data title="是否压缩" :defaultValue="true" @change="onCompressedChange"></boolean-data>
</view>
<!-- #endif -->
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
import { ItemType } from '@/components/enum-data/enum-data';
type Camera = "back" | "front"
type Source = "album" | "camera"
export default {
data() {
return {
title: "chooseVideo",
<enum-data title="屏幕方向" :items="orientationTypeItemTypes" @change="onOrientationTypeChange"></enum-data>
<enum-data title="摄像头" :items="cameraItemTypes" @change="onCameraChange"></enum-data>
</view>
<input-data title="最长拍摄时间,单位秒" defaultValue="60" type="number" @confirm="onMaxDurationConfirm"></input-data>
<!-- #ifdef APP -->
<view class="uni-padding-wrap">
<boolean-data title="是否压缩" :defaultValue="true" @change="onCompressedChange"></boolean-data>
</view>
<!-- #endif -->
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
import { ItemType } from '@/components/enum-data/enum-data-types';
type Camera = "back" | "front"
type Source = "album" | "camera"
export default {
data() {
return {
title: "chooseVideo",
src: "",
sourceTypeItemTypes: [{ "value": 0, "name": "从相册中选择视频" }, { "value": 1, "name": "拍摄视频" }, { "value": 2, "name": "从相册中选择视频或拍摄视频" }] as ItemType[],
sourceTypeItems: [["album"], ["camera"], ["album", "camera"]] as Source[][],
cameraItemTypes: [{ "value": 0, "name": "后置摄像头" }, { "value": 1, "name": "前置摄像头" }] as ItemType[],
cameraItems: ["back", "front"] as Camera[],
orientationTypeItemTypes: [{ "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[][],
cameraItemTypes: [{ "value": 0, "name": "后置摄像头" }, { "value": 1, "name": "前置摄像头" }] as ItemType[],
cameraItems: ["back", "front"] as Camera[],
sourceType: ["album", "camera"] as Source[],
compressed: true,
maxDuration: 60,
camera: "back" as Camera,
videoInfo: ""
}
},
methods: {
chooseVideo() {
uni.chooseVideo({
sourceType: this.sourceType,
// #ifdef APP
orientationType: "portrait",
orientationTypeItems: ["portrait", "landscape", "auto"],
compressed: true,
maxDuration: 60,
camera: "back" as Camera,
videoInfo: ""
}
},
methods: {
chooseVideo() {
uni.chooseVideo({
sourceType: this.sourceType,
// #ifdef APP
compressed: this.compressed,
// #endif
pageOrientation: this.orientationType,
// #endif
maxDuration: this.maxDuration,
camera: this.camera,
success: (res) => {
console.log("chooseVideo success", JSON.stringify(res));
this.src = res.tempFilePath;
this.videoInfo = `视频长度: ${res.duration}s\n视频大小: ${Math.ceil(res.size / 1024)}KB\n视频宽度: ${res.width}\n视频高度: ${res.height}\n`;
},
fail: (err) => {
uni.showModal({
title: "选择视频失败",
content: JSON.stringify(err),
showCancel: false
});
}
});
camera: this.camera,
success: (res) => {
console.log("chooseVideo success", JSON.stringify(res));
this.src = res.tempFilePath;
this.videoInfo = `视频长度: ${res.duration}s\n视频大小: ${Math.ceil(res.size / 1024)}KB\n视频宽度: ${res.width}\n视频高度: ${res.height}\n`;
},
fail: (err) => {
uni.showModal({
title: "选择视频失败",
content: JSON.stringify(err),
showCancel: false
});
}
});
},
onSourceTypeChange(value : number) {
this.sourceType = this.sourceTypeItems[value];
},
onCompressedChange(value : boolean) {
this.compressed = value;
},
onMaxDurationConfirm(value : number) {
this.maxDuration = value;
},
onCameraChange(value : number) {
this.camera = this.cameraItems[value];
}
}
}
</script>
<style>
.video {
align-self: center;
width: 300px;
height: 225px;
}
</style>
onOrientationTypeChange(value : number) {
this.orientationType = this.orientationTypeItems[value];
},
onSourceTypeChange(value : number) {
this.sourceType = this.sourceTypeItems[value];
},
onCompressedChange(value : boolean) {
this.compressed = value;
},
onMaxDurationConfirm(value : number) {
this.maxDuration = value;
},
onCameraChange(value : number) {
this.camera = this.cameraItems[value];
}
}
}
</script>
<style>
.video {
align-self: center;
width: 300px;
height: 225px;
}
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录