提交 074e4d4c 编写于 作者: DCloud_iOS_WZT's avatar DCloud_iOS_WZT

Merge branch 'dev' of gitcode.net:dcloud/hello-uni-app-x into dev

......@@ -599,12 +599,6 @@
"navigationBarTitleText": "get-app-authorize-setting"
}
},
{
"path": "pages/API/save-image-to-photos-album/save-image-to-photos-album",
"style": {
"navigationBarTitleText": "保存图片到相册"
}
},
// #endif
{
"path": "pages/API/preview-image/preview-image",
......@@ -618,7 +612,7 @@
"navigationBarTitleText": "拍摄图片或从相册中选择图片"
}
},
// #ifdef APP-ANDROID
// #ifdef APP-ANDROID || WEB
{
"path" : "pages/API/get-image-info/get-image-info",
"style" :
......@@ -626,6 +620,8 @@
"navigationBarTitleText" : "获取图片信息"
}
},
// #endif
// #ifdef APP-ANDROID
{
"path" : "pages/API/compress-image/compress-image",
"style" :
......@@ -634,7 +630,6 @@
}
},
// #endif
// #ifdef APP
{
"path" : "pages/API/choose-video/choose-video",
"style" :
......@@ -642,6 +637,13 @@
"navigationBarTitleText" : "拍摄视频或从相册中选择视频"
}
},
// #ifndef WEB
{
"path": "pages/API/save-image-to-photos-album/save-image-to-photos-album",
"style": {
"navigationBarTitleText": "保存图片到相册"
}
},
{
"path" : "pages/API/save-video-to-photos-album/save-video-to-photos-album",
"style" :
......@@ -650,7 +652,7 @@
}
},
// #endif
// #ifdef APP-ANDROID
// #ifdef APP-ANDROID || WEB
{
"path" : "pages/API/get-video-info/get-video-info",
"style" :
......@@ -658,6 +660,8 @@
"navigationBarTitleText" : "获取视频信息"
}
},
// #endif
// #ifdef APP-ANDROID
{
"path" : "pages/API/compress-video/compress-video",
"style" :
......
......@@ -4,13 +4,15 @@
<!-- #endif -->
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<video class="video" :src="src"></video>
<video class="video" :src="src" :controls="true"></video>
<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>
<view class="uni-padding-wrap">
<boolean-data title="是否压缩" :defaultValue="true" @change="onCompressedChange"></boolean-data>
</view>
<!-- #ifdef APP -->
......@@ -19,7 +21,7 @@
</template>
<script>
import { ItemType } from '@/components/enum-data/enum-data'
import { ItemType } from '@/components/enum-data/enum-data';
export default {
data() {
return {
......
......@@ -25,8 +25,8 @@
</view>
<input-data defaultValue="80" title="压缩质量,范围0~100,数值越小,质量越低,压缩率越高(仅对jpg有效)" type="number"
@confirm="onQualityConfirm"></input-data>
<input-data title="压缩后图片的宽度,单位px" type="number" @confirm="onCompressedWidthConfirm"></input-data>
<input-data title="压缩后图片的高度,单位px" type="number" @confirm="onCompressedHeightConfirm"></input-data>
<input-data title="压缩后图片的宽度,单位px" type="string" @confirm="onCompressedWidthConfirm"></input-data>
<input-data title="压缩后图片的高度,单位px" type="string" @confirm="onCompressedHeightConfirm"></input-data>
<input-data defaultValue="auto" title="压缩后图片的宽度,支持px、%、auto" type="string" @confirm="onWidthConfirm"></input-data>
<input-data defaultValue="auto" title="压缩后图片的高度,支持px、%、auto" type="string" @confirm="onHeightConfirm"></input-data>
<input-data defaultValue="0" title="旋转度数,范围0~360" type="number" @confirm="onRotateConfirm"></input-data>
......@@ -36,6 +36,9 @@
</template>
<script>
// #ifdef APP-ANDROID
import FileInputStream from 'java.io.FileInputStream';
// #endif
export default {
data() {
return {
......@@ -82,7 +85,11 @@
uni.getImageInfo({
src: res.tempFilePath,
success: (_res) => {
this.afterCompressImageInfo = `图片宽度: ${_res.width}, 图片高度: ${_res.height}`;
this.afterCompressImageInfo = `图片宽度: ${_res.width}\n图片高度: ${_res.height}\n`;
// #ifdef APP-ANDROID
const size = new FileInputStream(res.tempFilePath.substring("file://".length)).available() / 1024;
this.afterCompressImageInfo = this.afterCompressImageInfo.concat(`图片大小: ${size}KB`);
// #endif
}
});
},
......@@ -108,7 +115,11 @@
uni.getImageInfo({
src: res.tempFilePaths[0],
success: (_res) => {
this.beforeCompressImageInfo = `图片宽度: ${_res.width}, 图片高度: ${_res.height}`;
this.beforeCompressImageInfo = `图片宽度: ${_res.width}\n图片高度: ${_res.height}\n`;
// #ifdef APP-ANDROID
const size = new FileInputStream(res.tempFilePaths[0].substring("file://".length)).available() / 1024;
this.beforeCompressImageInfo = this.beforeCompressImageInfo.concat(`图片大小: ${size}KB`);
// #endif
}
});
}
......@@ -117,11 +128,11 @@
onQualityConfirm(value : number) {
this.quality = value;
},
onCompressedWidthConfirm(value : number) {
this.compressedWidth = value;
onCompressedWidthConfirm(value : string) {
this.compressedWidth = parseInt(value);
},
onCompressedHeightConfirm(value : number) {
this.compressedHeight = value;
onCompressedHeightConfirm(value : string) {
this.compressedHeight = parseInt(value);
},
onWidthConfirm(value : string) {
this.width = value;
......
......@@ -4,11 +4,12 @@
<!-- #endif -->
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<video class="video" :src="src"></video>
<video class="video" :src="beforeCompressPath" :controls="true"></video>
<view class="uni-title">
<text class="uni-subtitle-text">压缩前视频信息</text>
</view>
<text>{{beforeCompressVideoInfo}}</text>
<video class="video" :src="afterCompressPath" :controls="true"></video>
<view class="uni-title">
<text class="uni-subtitle-text">压缩后视频信息</text>
</view>
......@@ -19,11 +20,8 @@
<view class="uni-btn-v">
<button type="primary" @click="compressVideo">压缩视频</button>
</view>
<enum-data title="压缩质量" :items="qualityItemTypes" @change="onQualityChange"></enum-data>
</view>
<input-data :defaultValue="null" title="压缩质量,low(低) medium(中) high(高)" type="string"
@confirm="onQualityConfirm"></input-data>
<!-- <input-data :defaultValue="null" title="码率,单位kbps" type="number" @confirm="onBitrateConfirm"></input-data> -->
<!-- <input-data :defaultValue="null" title="帧率" type="number" @confirm="onFpsConfirm"></input-data> -->
<input-data :defaultValue="null" title="相对于原视频的分辨率比例,取值范围(0, 1]" type="string"
@confirm="onResolutionConfirm"></input-data>
<!-- #ifdef APP -->
......@@ -32,11 +30,11 @@
</template>
<script>
import { ItemType } from '@/components/enum-data/enum-data';
export default {
data() {
return {
title: "compressVideo",
src: "",
beforeCompressVideoInfo: "",
afterCompressVideoInfo: "",
beforeCompressPath: "",
......@@ -45,6 +43,8 @@
bitrate: null as number | null,
fps: null as number | null,
resolution: null as number | null,
qualityItemTypes: [{ "value": 0, "name": "low(低)" }, { "value": 1, "name": "medium(中)" }, { "value": 2, "name": "high(高)" }] as ItemType[],
qualityItems: ["low", "medium", "high"]
}
},
methods: {
......@@ -65,7 +65,7 @@
resolution: this.resolution,
success: (res) => {
console.log("compressVideo success", JSON.stringify(res));
this.src = res.tempFilePath;
this.afterCompressPath = res.tempFilePath;
uni.showToast({
title: "压缩成功",
icon: null
......@@ -73,7 +73,7 @@
uni.getVideoInfo({
src: res.tempFilePath,
success: (_res) => {
this.afterCompressVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${Math.ceil(_res.size / 1024)}kB\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`;
this.afterCompressVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${Math.ceil(_res.size / 1024)}KB\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`;
}
});
},
......@@ -95,24 +95,17 @@
compressed: false,
success: (res) => {
this.beforeCompressPath = res.tempFilePath;
this.src = res.tempFilePath;
uni.getVideoInfo({
src: res.tempFilePath,
success: (_res) => {
this.beforeCompressVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${Math.ceil(_res.size / 1024)}kB\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`;
this.beforeCompressVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${Math.ceil(_res.size / 1024)}KB\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`;
}
});
}
});
},
onQualityConfirm(value : string) {
this.quality = value;
},
onBitrateConfirm(value : number) {
this.bitrate = value;
},
onFpsConfirm(value : number) {
this.fps = value;
onQualityChange(value : number) {
this.quality = this.qualityItems[value];
},
onResolutionConfirm(value : string) {
this.resolution = parseFloat(value);
......
......@@ -33,7 +33,9 @@ describe('getCurrentPages', () => {
expect(isEnablePullDownRefresh1).toBe(true)
// setPageStyle
await page.callMethod('setPageStyle', false)
await page.callMethod('setPageStyle', {
enablePullDownRefresh: false
})
await page.waitFor(200)
await page.callMethod('getPageStyle')
......@@ -50,7 +52,9 @@ describe('getCurrentPages', () => {
expect(image2).toSaveImageSnapshot();
await page.waitFor(3500)
await page.callMethod('setPageStyle', true)
await page.callMethod('setPageStyle', {
enablePullDownRefresh: true
})
await page.waitFor(200)
await page.callMethod('startPullDownRefresh')
await page.waitFor(500)
......
<template>
<!-- #ifdef APP -->
<scroll-view class="page-scroll-view">
<!-- #endif -->
<page-head title="getCurrentPages"></page-head>
<view class="uni-padding-wrap">
<button @click="_getCurrentPages">getCurrentPages</button>
......@@ -8,20 +11,39 @@
<text style="margin-top: 5px">index: {{ index }}, route: {{ page.route }}</text>
</template>
</view>
<button class="btn btn-get-page-style" type="default" @click="getPageStyle">getPageStyle</button>
<button class="btn btn-set-page-style-1" type="default" @click="setPageStyle(true)">setPageStyle(true)</button>
<button class="btn btn-set-page-style-0" type="default" @click="setPageStyle(false)">setPageStyle(false)</button>
<text class="page-style">当前 PageStyle</text>
<text class="page-style-value">{{pageStyleText}}</text>
<text class="status">状态:</text>
<view class="status-list">
<text>enablePullDownRefresh: {{enablePullDownRefreshStatus}}</text>
</view>
<text class="tips">当前版本仅支持设置属性 enablePullDownRefresh</text>
<page-head title="currentPageStyle"></page-head>
<view class="page-style-item" v-for="(value, key) in currentPageStyle" :key="key">
<view class="item-text">
<text class="item-text-key">{{key}}:</text>
<text class="item-text-value">{{value}}</text>
</view>
<view class="set-value" v-if="typeof value == 'boolean'">
<switch :checked="getStyleValue(key).getBoolean('oldValue')"
@change="switchChange(key, $event as UniSwitchChangeEvent)">
</switch>
</view>
<view class="set-value" v-if="typeof value == 'number'">
<slider :value="getStyleValue(key).getNumber('oldValue')" :show-value="true"
@change="sliderChange(key, $event as UniSliderChangeEvent)" />
</view>
<view class="set-value" v-else-if="typeof value == 'string'">
<radio-group class="radio-set-value" @change="radioChange(key, $event as RadioGroupChangeEvent)">
<radio :value="getStyleValue(key).getString('oldValue')">{{getStyleValue(key).getString('oldValue')}}</radio>
<text class="split-h"></text>
<radio :value="getStyleValue(key).getString('newValue')">{{getStyleValue(key).getString('newValue')}}</radio>
</radio-group>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
import { PageStyleItem, PageStyleMap } from './page-style.uts';
class Page {
constructor(public route : string) {
}
......@@ -32,6 +54,7 @@
return {
checked: false,
pages: [] as Page[],
PageStyleMap: PageStyleMap as Map<string, PageStyleItem>,
currentPageStyle: {} as UTSJSONObject,
currentPageStyleIsUTSJSONObject: true,
// TODO
......@@ -43,12 +66,18 @@
return JSON.stringify(this.currentPageStyle)
}
},
onLoad() {
this.getPageStyle();
},
onPullDownRefresh() {
setTimeout(() => {
uni.stopPullDownRefresh()
}, 3000)
}, 2000)
},
methods: {
startPullDownRefresh() {
uni.startPullDownRefresh()
},
_getCurrentPages: function () {
this.pages.length = 0
const pages = getCurrentPages()
......@@ -63,24 +92,56 @@
}
}
},
getPageStyle() {
/// get-set-page-style
radioChange(key : string, e : RadioGroupChangeEvent) {
this.setStyleValue(key, e.detail.value);
},
sliderChange(key : string, e : UniSliderChangeEvent) {
this.setStyleValue(key, e.detail.value);
},
switchChange(key : string, e : UniSwitchChangeEvent) {
this.setStyleValue(key, e.detail.value);
},
setStyleValue(key : string, value : any) {
const style = {}
style[key] = value
this.setPageStyle(style)
this.getPageStyle()
},
getStyleValue(key : string) : UTSJSONObject {
if (PageStyleMap.has(key))
return PageStyleMap.get(key)!.value;
else
return {}
},
getPageStyle() : UTSJSONObject {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
this.currentPageStyle = currentPage.$getPageStyle();
this.currentPageStyle = currentPage.$getPageStyle()
this.currentPageStyleIsUTSJSONObject = this.currentPageStyle instanceof UTSJSONObject
return this.currentPageStyle;
},
setPageStyle(enable : boolean) {
// 目前仅支持 enablePullDownRefresh
setPageStyle(style : UTSJSONObject) {
console.log('setPageStyle:', style);
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.$setPageStyle({
enablePullDownRefresh: enable
});
this.enablePullDownRefreshStatus = enable
currentPage.$setPageStyle(style);
},
startPullDownRefresh() {
uni.startPullDownRefresh()
}
// getPageStyle() {
// const pages = getCurrentPages();
// const currentPage = pages[pages.length - 1];
// this.currentPageStyle = currentPage.$getPageStyle();
// this.currentPageStyleIsUTSJSONObject = this.currentPageStyle instanceof UTSJSONObject
// },
// setPageStyle(enable : boolean) {
// // 目前仅支持 enablePullDownRefresh
// const pages = getCurrentPages();
// const currentPage = pages[pages.length - 1];
// currentPage.$setPageStyle({
// enablePullDownRefresh: enable
// });
// this.enablePullDownRefreshStatus = enable
// },
// getCurrentPage(): Page {
// const pages = getCurrentPages();
// const currentPage = pages[pages.length - 1];
......@@ -90,37 +151,44 @@
}
</script>
<style>
.btn {
margin-top: 10px;
.page {
flex: 1;
padding: 10px;
}
.page-style {
margin-top: 15px;
}
.page-style-value {
margin-top: 5px;
padding: 5px;
background-color: #fff;
width: 100%;
/* #ifdef WEB */
overflow-wrap: break-word;
/* #endif */
.page-style-item {
padding: 10px;
margin-top: 10px;
background-color: #ffffff;
border-radius: 5px;
}
.item-text {
flex-direction: row;
}
.status {
margin-top: 20px;
.item-text-key {
font-weight: bold;
}
.status-list {
margin-top: 5px;
.item-text-value {
margin-left: 32px;
}
.tips {
font-size: 12px;
margin-top: 15px;
opacity: .8;
.set-value {
margin-top: 10px;
}
.radio-set-value {
flex-direction: row;
}
.split-h {
width: 15px;
}
</style>
export type PageStyleItem = {
type : string
value : UTSJSONObject
}
export const PageStyleMap = new Map<string, PageStyleItem>([
["navigationBarBackgroundColor", {
type: "string",
value: {
oldValue: "#F8F8F8",
newValue: "#F0F0F0",
}
} as PageStyleItem],
["navigationBarTextStyle", {
type: "string",
value: {
oldValue: "white",
newValue: "black",
}
} as PageStyleItem],
["navigationBarTitleText", {
type: "string",
value: {
oldValue: "old title",
newValue: "new title",
}
} as PageStyleItem],
["navigationStyle", {
type: "string",
value: {
oldValue: "default",
newValue: "custom",
}
} as PageStyleItem],
["backgroundColor", {
type: "string",
value: {
oldValue: "#ffffff",
newValue: "#000000",
}
} as PageStyleItem],
["backgroundColorContent", {
type: "string",
value: {
oldValue: "#ffffff",
newValue: "#000000",
}
} as PageStyleItem],
["backgroundTextStyle", {
type: "string",
value: {
oldValue: "dark",
newValue: "light",
}
} as PageStyleItem],
["enablePullDownRefresh", {
type: "boolean",
value: {
oldValue: true,
newValue: false,
}
} as PageStyleItem],
["onReachBottomDistance", {
type: "number",
value: {
oldValue: 50,
newValue: 100,
}
} as PageStyleItem],
["pageOrientation", {
type: "string",
value: {
oldValue: "auto",
newValue: "portrait",
}
} as PageStyleItem],
["backgroundColorTop", {
type: "string",
value: {
oldValue: "#ffffff",
newValue: "#000000",
}
} as PageStyleItem],
["backgroundColorBottom", {
type: "string",
value: {
oldValue: "#ffffff",
newValue: "#000000",
}
} as PageStyleItem],
["navigationBarAutoBackButton", {
type: "boolean",
value: {
oldValue: true,
newValue: false,
}
} as PageStyleItem],
])
......@@ -164,12 +164,12 @@
this.statsRet = res.stats
console.log('this.statsRet', this.statsRet)
},
fail: (res : UniError) => {
fail: (res:IUniError ) => {
if (this.logAble) {
this.log += 'statFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('statFileInfoTest fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
console.log("statFileInfoTest complete", res)
......@@ -195,12 +195,12 @@
this.getFileInfoSize = res.size
this.getFileInfoDigest = res.digest
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'getFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
console.log("complete", res)
......@@ -224,12 +224,12 @@
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
console.log("complete", res)
......@@ -253,12 +253,12 @@
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'renameFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
this.done = true
......@@ -281,12 +281,12 @@
console.log("success", res)
this.fileListSuccess = res.files
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'readDirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
console.log("complete", res)
......@@ -313,12 +313,12 @@
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'writeFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail')
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
this.done = true
......@@ -344,12 +344,12 @@
console.log('success', res)
this.readFileRet = res.data
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'readFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
console.log("complete", res)
......@@ -372,12 +372,12 @@
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'rmdirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
console.log("complete", res)
......@@ -402,12 +402,13 @@
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'mkdirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
if (res instanceof UniError) {
......@@ -431,12 +432,13 @@
console.log('success', res)
this.accessFileRet = res.errMsg
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'accessFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
if (res instanceof UniError) {
......@@ -459,12 +461,13 @@
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'unlinkTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
if (res instanceof UniError) {
......@@ -497,12 +500,13 @@
}
console.log('success unlink', res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'unlinkAllFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail unlink', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
if (res instanceof UniError) {
......@@ -514,12 +518,13 @@
} as UnLinkOptions)
});
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'unlinkAllFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail to readdir', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
console.log("complete readdir", res)
......@@ -544,12 +549,13 @@
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
console.log("complete", res)
......@@ -573,12 +579,13 @@
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'appendFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail')
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
this.done = true
......@@ -757,12 +764,13 @@
this.saveFileRet = res.savedFilePath
this.done = true
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'saveFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('saveFileTest fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
this.done = true
},
complete: (_) => {
......@@ -801,12 +809,13 @@
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'unzipFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (_) => {
this.done = true
......@@ -825,12 +834,13 @@
this.fileListSuccess = res.fileList
this.getSavedFileListRet = "getSavedFileList:ok"
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'getSavedFileListTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('getSavedFileListTest fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
this.getSavedFileListRet = JSON.stringify(res)
},
complete: (res : any) => {
......@@ -855,12 +865,13 @@
}
console.log("success", res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'truncateFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
console.log("complete", res)
......@@ -894,12 +905,13 @@
}
console.log("success", res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'readCompressedFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (_) => {
this.done = true
......@@ -937,7 +949,7 @@
this.removeSavedFileRet = res.errMsg
console.log("removeSavedFileTest success", res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'removeSavedFileTest fail:' + JSON.stringify(res) + '\n\n'
}
......@@ -981,12 +993,13 @@
console.log("success", res)
this.fd = res.fd
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'openFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (_) => {
this.done = true
......@@ -1047,12 +1060,13 @@
this.closeFileRet = res.errMsg
console.log("success", res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'closeTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (_) => {
this.done = true
......@@ -1079,12 +1093,13 @@
console.log("success", res)
this.bytesWritten = res.bytesWritten
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'writeTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (_) => {
this.done = true
......@@ -1128,12 +1143,13 @@
this.done = true
}
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'openFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
this.done = true
}
} as OpenFileOptions)
......@@ -1150,12 +1166,13 @@
console.log("success", res)
this.fstat = res.stats
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'fstatTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (_) => {
this.done = true
......@@ -1193,12 +1210,13 @@
}
this.ftruncateRet = res.errMsg
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'ftruncateFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
},
complete: (res : any) => {
console.log("complete", res)
......@@ -1239,12 +1257,13 @@
}
console.log("success", res)
},
fail: (res : UniError) => {
fail: (res : IUniError) => {
if (this.logAble) {
this.log += 'readZipEntry fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}
} as ReadZipEntryOptions)
},
......
......@@ -7,7 +7,7 @@
<view class="uni-title">
<text class="uni-subtitle-text">获取本地绝对路径视频信息</text>
</view>
<video class="video" :src="absoluteVideoPath"></video>
<video class="video" :src="absoluteVideoPath" :controls="true"></video>
<text class="margin-top-10">{{absoluteVideoInfo}}</text>
<view class="uni-btn-v">
<button type="primary" @click="chooseVideo">拍摄视频或从相册中选择视频</button>
......@@ -37,7 +37,7 @@
src: res.tempFilePath,
success: (_res) => {
console.log("getVideoInfo success", JSON.stringify(res));
this.absoluteVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${Math.ceil(_res.size / 1024)}kB\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`;
this.absoluteVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${Math.ceil(_res.size / 1024)}KB\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`;
},
fail: (err) => {
uni.showModal({
......
......@@ -8,7 +8,7 @@
</template>
<script>
export type PayItem = { id : string, name : string }
export type PayItem = { id : string, name : string, provider ?: UniProvider }
export default {
data() {
return {
......@@ -33,12 +33,18 @@
this.providerList.push({
name: '支付宝',
id: "alipay",
provider: e.providers.find((item) : boolean => {
return item?.id == 'alipay'
})
} as PayItem);
break;
case 'wxpay':
this.providerList.push({
name: '微信',
id: "wxpay",
provider: e.providers.find((item) : boolean => {
return item?.id == 'wxpay'
})
} as PayItem);
break;
default:
......@@ -57,8 +63,17 @@
if (provider == "alipay") {
this.payAli()
} else if (provider == "wxpay") {
if (e.provider != null && e.provider?.isAppExist==false) {
uni.showToast({
title: "微信没有安装",
icon:'error'
})
} else {
this.payWX()
}
}
},
payAli() {
uni.showLoading({
......
......@@ -4,7 +4,7 @@
<!-- #endif -->
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<video class="video" :src="src"></video>
<video class="video" :src="src" :controls="true"></video>
<button type="primary" class="margin-top-10" @click="saveVideo">将视频保存到手机相册</button>
</view>
<!-- #ifdef APP -->
......@@ -47,7 +47,7 @@
title: '视频下载中'
});
uni.downloadFile({
url: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.mp4',
url: 'https://qiniu-web-assets.dcloud.net.cn/uni-app-x/static/video/swiper-vertical-video/uts.mp4',
success: (res) => {
console.log("download video success", res.tempFilePath);
this.src = res.tempFilePath;
......
......@@ -348,65 +348,57 @@
url: 'save-image-to-photos-album'
},
// #endif
// #ifdef APP-ANDROID
// #ifdef APP-ANDROID || WEB
{
name: "获取图片信息",
url: 'get-image-info'
},
// #endif
// #ifdef APP-ANDROID
{
name: "压缩图片",
url: 'compress-image'
},
// #endif
// #ifdef APP
{
name: "拍摄视频或从相册中选择视频",
url: 'choose-video'
},
// #ifdef APP
{
name: "保存视频到相册",
url: 'save-video-to-photos-album'
},
// #endif
// #ifdef APP-ANDROID
// #ifdef APP-ANDROID || WEB
{
name: "获取视频信息",
url: 'get-video-info'
},
// #endif
// #ifdef APP-ANDROID
{
name: "压缩视频",
url: 'compress-video'
},
// #endif
/* {
name: "图片选择和拍照",
url: "image",
enable: false
},{
name: "音频",
url: "inner-audio",
},
{
name: "录音",
url: "voice",
},
{
name: "背景音频",
url: "background-audio",
},
{
name: "视频选择和拍照",
url: "video",
enable: false
name: "录音",
url: "rec",
},
{
name: "文件",
url: "file",
},
{
name: "保存媒体到本地",
url: "save-media",
}, */
*/
] as Page[],
},
{
......@@ -446,7 +438,7 @@
}
] as Page[],
},
// #ifdef APP-ANDROID || APP-IOS
// #ifdef APP
{
id: 'file',
name: '文件',
......@@ -496,78 +488,52 @@
] as Page[],
},
// #endif
// #ifdef APP-ANDROID
{
id: 'ad',
name: '广告',
pages: [
{
name: '激励视频广告',
url: 'rewarded-video-ad',
}
] as Page[],
},
{
id: 'permission-listener',
name: '权限申请监听',
pages: [
{
name: '权限申请监听',
url: 'create-request-permission-listener',
}
] as Page[]
},
// #endif
// #ifdef APP-ANDROID || APP-IOS
{
id: "payment",
name: "支付",
pages: [
// #ifndef WEB
{
name: "简易支付示例",
url: "request-payment",
},
// #endif
{
name: "uni-pay支付示例",
url: "request-payment-uni-pay",
}
] as Page[],
},
// #endif
// #ifdef WEB
// #ifdef APP-ANDROID
{
id: "payment",
name: "支付",
id: 'ad',
name: '广告',
pages: [
{
name: "uni-pay支付示例",
url: "request-payment-uni-pay",
name: '激励视频广告',
url: 'rewarded-video-ad',
}
] as Page[],
},
// #endif
/*
{
/* {
id: "full-screen-video-ad",
url: "full-screen-video-ad",
name: "全屏视频广告",
enable: false,
pages: [] as Page[]
}, */
] as Page[],
},
{
id: "login",
name: "登录",
id: 'permission-listener',
name: '权限申请监听',
pages: [
{
name: "登录",
url: "login",
},
{
name: "获取用户信息",
url: "get-user-info",
},
] as Page[],
name: '权限申请监听',
url: 'create-request-permission-listener',
}
] as Page[]
},
// #endif
/*
{
id: "share",
name: "分享",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册