提交 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 @@ ...@@ -599,12 +599,6 @@
"navigationBarTitleText": "get-app-authorize-setting" "navigationBarTitleText": "get-app-authorize-setting"
} }
}, },
{
"path": "pages/API/save-image-to-photos-album/save-image-to-photos-album",
"style": {
"navigationBarTitleText": "保存图片到相册"
}
},
// #endif // #endif
{ {
"path": "pages/API/preview-image/preview-image", "path": "pages/API/preview-image/preview-image",
...@@ -618,7 +612,7 @@ ...@@ -618,7 +612,7 @@
"navigationBarTitleText": "拍摄图片或从相册中选择图片" "navigationBarTitleText": "拍摄图片或从相册中选择图片"
} }
}, },
// #ifdef APP-ANDROID // #ifdef APP-ANDROID || WEB
{ {
"path" : "pages/API/get-image-info/get-image-info", "path" : "pages/API/get-image-info/get-image-info",
"style" : "style" :
...@@ -626,6 +620,8 @@ ...@@ -626,6 +620,8 @@
"navigationBarTitleText" : "获取图片信息" "navigationBarTitleText" : "获取图片信息"
} }
}, },
// #endif
// #ifdef APP-ANDROID
{ {
"path" : "pages/API/compress-image/compress-image", "path" : "pages/API/compress-image/compress-image",
"style" : "style" :
...@@ -634,7 +630,6 @@ ...@@ -634,7 +630,6 @@
} }
}, },
// #endif // #endif
// #ifdef APP
{ {
"path" : "pages/API/choose-video/choose-video", "path" : "pages/API/choose-video/choose-video",
"style" : "style" :
...@@ -642,6 +637,13 @@ ...@@ -642,6 +637,13 @@
"navigationBarTitleText" : "拍摄视频或从相册中选择视频" "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", "path" : "pages/API/save-video-to-photos-album/save-video-to-photos-album",
"style" : "style" :
...@@ -650,7 +652,7 @@ ...@@ -650,7 +652,7 @@
} }
}, },
// #endif // #endif
// #ifdef APP-ANDROID // #ifdef APP-ANDROID || WEB
{ {
"path" : "pages/API/get-video-info/get-video-info", "path" : "pages/API/get-video-info/get-video-info",
"style" : "style" :
...@@ -658,6 +660,8 @@ ...@@ -658,6 +660,8 @@
"navigationBarTitleText" : "获取视频信息" "navigationBarTitleText" : "获取视频信息"
} }
}, },
// #endif
// #ifdef APP-ANDROID
{ {
"path" : "pages/API/compress-video/compress-video", "path" : "pages/API/compress-video/compress-video",
"style" : "style" :
......
...@@ -4,13 +4,15 @@ ...@@ -4,13 +4,15 @@
<!-- #endif --> <!-- #endif -->
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="uni-padding-wrap"> <view class="uni-padding-wrap">
<video class="video" :src="src"></video> <video class="video" :src="src" :controls="true"></video>
<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>
<enum-data title="摄像头" :items="cameraItemTypes" @change="onCameraChange"></enum-data> <enum-data title="摄像头" :items="cameraItemTypes" @change="onCameraChange"></enum-data>
<input-data title="最长拍摄时间,单位秒" defaultValue="60" type="number" @confirm="onMaxDurationConfirm"></input-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> <boolean-data title="是否压缩" :defaultValue="true" @change="onCompressedChange"></boolean-data>
</view> </view>
<!-- #ifdef APP --> <!-- #ifdef APP -->
...@@ -19,7 +21,7 @@ ...@@ -19,7 +21,7 @@
</template> </template>
<script> <script>
import { ItemType } from '@/components/enum-data/enum-data' import { ItemType } from '@/components/enum-data/enum-data';
export default { export default {
data() { data() {
return { return {
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
</view> </view>
<input-data defaultValue="80" title="压缩质量,范围0~100,数值越小,质量越低,压缩率越高(仅对jpg有效)" type="number" <input-data defaultValue="80" title="压缩质量,范围0~100,数值越小,质量越低,压缩率越高(仅对jpg有效)" type="number"
@confirm="onQualityConfirm"></input-data> @confirm="onQualityConfirm"></input-data>
<input-data title="压缩后图片的宽度,单位px" type="number" @confirm="onCompressedWidthConfirm"></input-data> <input-data title="压缩后图片的宽度,单位px" type="string" @confirm="onCompressedWidthConfirm"></input-data>
<input-data title="压缩后图片的高度,单位px" type="number" @confirm="onCompressedHeightConfirm"></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="onWidthConfirm"></input-data>
<input-data defaultValue="auto" title="压缩后图片的高度,支持px、%、auto" type="string" @confirm="onHeightConfirm"></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> <input-data defaultValue="0" title="旋转度数,范围0~360" type="number" @confirm="onRotateConfirm"></input-data>
...@@ -36,6 +36,9 @@ ...@@ -36,6 +36,9 @@
</template> </template>
<script> <script>
// #ifdef APP-ANDROID
import FileInputStream from 'java.io.FileInputStream';
// #endif
export default { export default {
data() { data() {
return { return {
...@@ -82,7 +85,11 @@ ...@@ -82,7 +85,11 @@
uni.getImageInfo({ uni.getImageInfo({
src: res.tempFilePath, src: res.tempFilePath,
success: (_res) => { 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 @@ ...@@ -108,7 +115,11 @@
uni.getImageInfo({ uni.getImageInfo({
src: res.tempFilePaths[0], src: res.tempFilePaths[0],
success: (_res) => { 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 @@ ...@@ -117,11 +128,11 @@
onQualityConfirm(value : number) { onQualityConfirm(value : number) {
this.quality = value; this.quality = value;
}, },
onCompressedWidthConfirm(value : number) { onCompressedWidthConfirm(value : string) {
this.compressedWidth = value; this.compressedWidth = parseInt(value);
}, },
onCompressedHeightConfirm(value : number) { onCompressedHeightConfirm(value : string) {
this.compressedHeight = value; this.compressedHeight = parseInt(value);
}, },
onWidthConfirm(value : string) { onWidthConfirm(value : string) {
this.width = value; this.width = value;
......
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
<!-- #endif --> <!-- #endif -->
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="uni-padding-wrap"> <view class="uni-padding-wrap">
<video class="video" :src="src"></video> <video class="video" :src="beforeCompressPath" :controls="true"></video>
<view class="uni-title"> <view class="uni-title">
<text class="uni-subtitle-text">压缩前视频信息</text> <text class="uni-subtitle-text">压缩前视频信息</text>
</view> </view>
<text>{{beforeCompressVideoInfo}}</text> <text>{{beforeCompressVideoInfo}}</text>
<video class="video" :src="afterCompressPath" :controls="true"></video>
<view class="uni-title"> <view class="uni-title">
<text class="uni-subtitle-text">压缩后视频信息</text> <text class="uni-subtitle-text">压缩后视频信息</text>
</view> </view>
...@@ -19,11 +20,8 @@ ...@@ -19,11 +20,8 @@
<view class="uni-btn-v"> <view class="uni-btn-v">
<button type="primary" @click="compressVideo">压缩视频</button> <button type="primary" @click="compressVideo">压缩视频</button>
</view> </view>
<enum-data title="压缩质量" :items="qualityItemTypes" @change="onQualityChange"></enum-data>
</view> </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" <input-data :defaultValue="null" title="相对于原视频的分辨率比例,取值范围(0, 1]" type="string"
@confirm="onResolutionConfirm"></input-data> @confirm="onResolutionConfirm"></input-data>
<!-- #ifdef APP --> <!-- #ifdef APP -->
...@@ -32,11 +30,11 @@ ...@@ -32,11 +30,11 @@
</template> </template>
<script> <script>
import { ItemType } from '@/components/enum-data/enum-data';
export default { export default {
data() { data() {
return { return {
title: "compressVideo", title: "compressVideo",
src: "",
beforeCompressVideoInfo: "", beforeCompressVideoInfo: "",
afterCompressVideoInfo: "", afterCompressVideoInfo: "",
beforeCompressPath: "", beforeCompressPath: "",
...@@ -45,6 +43,8 @@ ...@@ -45,6 +43,8 @@
bitrate: null as number | null, bitrate: null as number | null,
fps: null as number | null, fps: null as number | null,
resolution: 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: { methods: {
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
resolution: this.resolution, resolution: this.resolution,
success: (res) => { success: (res) => {
console.log("compressVideo success", JSON.stringify(res)); console.log("compressVideo success", JSON.stringify(res));
this.src = res.tempFilePath; this.afterCompressPath = res.tempFilePath;
uni.showToast({ uni.showToast({
title: "压缩成功", title: "压缩成功",
icon: null icon: null
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
uni.getVideoInfo({ uni.getVideoInfo({
src: res.tempFilePath, src: res.tempFilePath,
success: (_res) => { 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 @@ ...@@ -95,24 +95,17 @@
compressed: false, compressed: false,
success: (res) => { success: (res) => {
this.beforeCompressPath = res.tempFilePath; this.beforeCompressPath = res.tempFilePath;
this.src = res.tempFilePath;
uni.getVideoInfo({ uni.getVideoInfo({
src: res.tempFilePath, src: res.tempFilePath,
success: (_res) => { 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) { onQualityChange(value : number) {
this.quality = value; this.quality = this.qualityItems[value];
},
onBitrateConfirm(value : number) {
this.bitrate = value;
},
onFpsConfirm(value : number) {
this.fps = value;
}, },
onResolutionConfirm(value : string) { onResolutionConfirm(value : string) {
this.resolution = parseFloat(value); this.resolution = parseFloat(value);
......
...@@ -33,7 +33,9 @@ describe('getCurrentPages', () => { ...@@ -33,7 +33,9 @@ describe('getCurrentPages', () => {
expect(isEnablePullDownRefresh1).toBe(true) expect(isEnablePullDownRefresh1).toBe(true)
// setPageStyle // setPageStyle
await page.callMethod('setPageStyle', false) await page.callMethod('setPageStyle', {
enablePullDownRefresh: false
})
await page.waitFor(200) await page.waitFor(200)
await page.callMethod('getPageStyle') await page.callMethod('getPageStyle')
...@@ -50,7 +52,9 @@ describe('getCurrentPages', () => { ...@@ -50,7 +52,9 @@ describe('getCurrentPages', () => {
expect(image2).toSaveImageSnapshot(); expect(image2).toSaveImageSnapshot();
await page.waitFor(3500) await page.waitFor(3500)
await page.callMethod('setPageStyle', true) await page.callMethod('setPageStyle', {
enablePullDownRefresh: true
})
await page.waitFor(200) await page.waitFor(200)
await page.callMethod('startPullDownRefresh') await page.callMethod('startPullDownRefresh')
await page.waitFor(500) await page.waitFor(500)
......
<template> <template>
<page-head title="getCurrentPages"></page-head> <!-- #ifdef APP -->
<view class="uni-padding-wrap"> <scroll-view class="page-scroll-view">
<button @click="_getCurrentPages">getCurrentPages</button> <!-- #endif -->
<view v-if="pages.length" style="padding: 15px 0px"> <page-head title="getCurrentPages"></page-head>
<text>当前页面栈中 {{ pages.length }} 个页面,列表如下:</text> <view class="uni-padding-wrap">
<template v-for="(page, index) in pages" :key="page.route"> <button @click="_getCurrentPages">getCurrentPages</button>
<text style="margin-top: 5px">index: {{ index }}, route: {{ page.route }}</text> <view v-if="pages.length" style="padding: 15px 0px">
</template> <text>当前页面栈中 {{ pages.length }} 个页面,列表如下:</text>
</view> <template v-for="(page, index) in pages" :key="page.route">
<button class="btn btn-get-page-style" type="default" @click="getPageStyle">getPageStyle</button> <text style="margin-top: 5px">index: {{ index }}, route: {{ page.route }}</text>
<button class="btn btn-set-page-style-1" type="default" @click="setPageStyle(true)">setPageStyle(true)</button> </template>
<button class="btn btn-set-page-style-0" type="default" @click="setPageStyle(false)">setPageStyle(false)</button> </view>
<text class="page-style">当前 PageStyle</text> </view>
<text class="page-style-value">{{pageStyleText}}</text>
<text class="status">状态:</text> <page-head title="currentPageStyle"></page-head>
<view class="status-list"> <view class="page-style-item" v-for="(value, key) in currentPageStyle" :key="key">
<text>enablePullDownRefresh: {{enablePullDownRefreshStatus}}</text> <view class="item-text">
</view> <text class="item-text-key">{{key}}:</text>
<text class="tips">当前版本仅支持设置属性 enablePullDownRefresh</text> <text class="item-text-value">{{value}}</text>
</view> </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> </template>
<script> <script>
import { PageStyleItem, PageStyleMap } from './page-style.uts';
class Page { class Page {
constructor(public route : string) { constructor(public route : string) {
} }
...@@ -31,7 +53,8 @@ ...@@ -31,7 +53,8 @@
data() { data() {
return { return {
checked: false, checked: false,
pages: [] as Page[], pages: [] as Page[],
PageStyleMap: PageStyleMap as Map<string, PageStyleItem>,
currentPageStyle: {} as UTSJSONObject, currentPageStyle: {} as UTSJSONObject,
currentPageStyleIsUTSJSONObject: true, currentPageStyleIsUTSJSONObject: true,
// TODO // TODO
...@@ -42,13 +65,19 @@ ...@@ -42,13 +65,19 @@
pageStyleText() : string { pageStyleText() : string {
return JSON.stringify(this.currentPageStyle) return JSON.stringify(this.currentPageStyle)
} }
},
onLoad() {
this.getPageStyle();
}, },
onPullDownRefresh() { onPullDownRefresh() {
setTimeout(() => { setTimeout(() => {
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
}, 3000) }, 2000)
}, },
methods: { methods: {
startPullDownRefresh() {
uni.startPullDownRefresh()
},
_getCurrentPages: function () { _getCurrentPages: function () {
this.pages.length = 0 this.pages.length = 0
const pages = getCurrentPages() const pages = getCurrentPages()
...@@ -62,25 +91,57 @@ ...@@ -62,25 +91,57 @@
this.checked = false this.checked = false
} }
} }
},
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
}, },
startPullDownRefresh() { /// get-set-page-style
uni.startPullDownRefresh() 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.currentPageStyleIsUTSJSONObject = this.currentPageStyle instanceof UTSJSONObject
return this.currentPageStyle;
},
setPageStyle(style : UTSJSONObject) {
console.log('setPageStyle:', style);
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.$setPageStyle(style);
},
// 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 { // getCurrentPage(): Page {
// const pages = getCurrentPages(); // const pages = getCurrentPages();
// const currentPage = pages[pages.length - 1]; // const currentPage = pages[pages.length - 1];
...@@ -90,37 +151,44 @@ ...@@ -90,37 +151,44 @@
} }
</script> </script>
<style> <style>
.btn { .page {
margin-top: 10px; flex: 1;
padding: 10px;
} }
.page-style { .page-style {
margin-top: 15px; margin-top: 15px;
} }
.page-style-value { .page-style-item {
margin-top: 5px; padding: 10px;
padding: 5px; margin-top: 10px;
background-color: #fff; background-color: #ffffff;
width: 100%; border-radius: 5px;
/* #ifdef WEB */
overflow-wrap: break-word;
/* #endif */
} }
.status { .item-text {
margin-top: 20px; flex-direction: row;
} }
.status-list { .item-text-key {
margin-top: 5px; font-weight: bold;
} }
.tips { .item-text-value {
font-size: 12px; margin-left: 32px;
margin-top: 15px; }
opacity: .8;
.set-value {
margin-top: 10px;
}
.radio-set-value {
flex-direction: row;
}
.split-h {
width: 15px;
} }
</style> </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 @@ ...@@ -164,12 +164,12 @@
this.statsRet = res.stats this.statsRet = res.stats
console.log('this.statsRet', this.statsRet) console.log('this.statsRet', this.statsRet)
}, },
fail: (res : UniError) => { fail: (res:IUniError ) => {
if (this.logAble) { if (this.logAble) {
this.log += 'statFileInfoTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'statFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('statFileInfoTest fail', res) console.log('statFileInfoTest fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
console.log("statFileInfoTest complete", res) console.log("statFileInfoTest complete", res)
...@@ -195,12 +195,12 @@ ...@@ -195,12 +195,12 @@
this.getFileInfoSize = res.size this.getFileInfoSize = res.size
this.getFileInfoDigest = res.digest this.getFileInfoDigest = res.digest
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'getFileInfoTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'getFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
console.log("complete", res) console.log("complete", res)
...@@ -224,12 +224,12 @@ ...@@ -224,12 +224,12 @@
} }
console.log('success', res) console.log('success', res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
console.log("complete", res) console.log("complete", res)
...@@ -253,12 +253,12 @@ ...@@ -253,12 +253,12 @@
} }
console.log('success', res) console.log('success', res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'renameFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'renameFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
this.done = true this.done = true
...@@ -281,12 +281,12 @@ ...@@ -281,12 +281,12 @@
console.log("success", res) console.log("success", res)
this.fileListSuccess = res.files this.fileListSuccess = res.files
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'readDirTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'readDirTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
console.log("complete", res) console.log("complete", res)
...@@ -313,12 +313,12 @@ ...@@ -313,12 +313,12 @@
} }
console.log('success', res) console.log('success', res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'writeFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'writeFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail') console.log('fail')
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
this.done = true this.done = true
...@@ -344,12 +344,12 @@ ...@@ -344,12 +344,12 @@
console.log('success', res) console.log('success', res)
this.readFileRet = res.data this.readFileRet = res.data
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'readFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'readFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
console.log("complete", res) console.log("complete", res)
...@@ -372,12 +372,12 @@ ...@@ -372,12 +372,12 @@
} }
console.log('success', res) console.log('success', res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'rmdirTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'rmdirTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
console.log("complete", res) console.log("complete", res)
...@@ -402,12 +402,13 @@ ...@@ -402,12 +402,13 @@
} }
console.log('success', res) console.log('success', res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'mkdirTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'mkdirTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
if (res instanceof UniError) { if (res instanceof UniError) {
...@@ -431,12 +432,13 @@ ...@@ -431,12 +432,13 @@
console.log('success', res) console.log('success', res)
this.accessFileRet = res.errMsg this.accessFileRet = res.errMsg
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'accessFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'accessFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
if (res instanceof UniError) { if (res instanceof UniError) {
...@@ -459,12 +461,13 @@ ...@@ -459,12 +461,13 @@
} }
console.log('success', res) console.log('success', res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'unlinkTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'unlinkTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
if (res instanceof UniError) { if (res instanceof UniError) {
...@@ -497,12 +500,13 @@ ...@@ -497,12 +500,13 @@
} }
console.log('success unlink', res) console.log('success unlink', res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'unlinkAllFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'unlinkAllFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail unlink', res) console.log('fail unlink', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
if (res instanceof UniError) { if (res instanceof UniError) {
...@@ -514,12 +518,13 @@ ...@@ -514,12 +518,13 @@
} as UnLinkOptions) } as UnLinkOptions)
}); });
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'unlinkAllFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'unlinkAllFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail to readdir', res) console.log('fail to readdir', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
console.log("complete readdir", res) console.log("complete readdir", res)
...@@ -544,12 +549,13 @@ ...@@ -544,12 +549,13 @@
} }
console.log('success', res) console.log('success', res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
console.log("complete", res) console.log("complete", res)
...@@ -573,12 +579,13 @@ ...@@ -573,12 +579,13 @@
} }
console.log('success', res) console.log('success', res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'appendFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'appendFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail') console.log('fail')
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
this.done = true this.done = true
...@@ -757,12 +764,13 @@ ...@@ -757,12 +764,13 @@
this.saveFileRet = res.savedFilePath this.saveFileRet = res.savedFilePath
this.done = true this.done = true
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'saveFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'saveFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('saveFileTest fail', res) console.log('saveFileTest fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
this.done = true this.done = true
}, },
complete: (_) => { complete: (_) => {
...@@ -801,12 +809,13 @@ ...@@ -801,12 +809,13 @@
} }
console.log('success', res) console.log('success', res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'unzipFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'unzipFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (_) => { complete: (_) => {
this.done = true this.done = true
...@@ -825,12 +834,13 @@ ...@@ -825,12 +834,13 @@
this.fileListSuccess = res.fileList this.fileListSuccess = res.fileList
this.getSavedFileListRet = "getSavedFileList:ok" this.getSavedFileListRet = "getSavedFileList:ok"
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'getSavedFileListTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'getSavedFileListTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('getSavedFileListTest fail', res) console.log('getSavedFileListTest fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
this.getSavedFileListRet = JSON.stringify(res) this.getSavedFileListRet = JSON.stringify(res)
}, },
complete: (res : any) => { complete: (res : any) => {
...@@ -855,12 +865,13 @@ ...@@ -855,12 +865,13 @@
} }
console.log("success", res) console.log("success", res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'truncateFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'truncateFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
console.log("complete", res) console.log("complete", res)
...@@ -894,12 +905,13 @@ ...@@ -894,12 +905,13 @@
} }
console.log("success", res) console.log("success", res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'readCompressedFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'readCompressedFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (_) => { complete: (_) => {
this.done = true this.done = true
...@@ -937,7 +949,7 @@ ...@@ -937,7 +949,7 @@
this.removeSavedFileRet = res.errMsg this.removeSavedFileRet = res.errMsg
console.log("removeSavedFileTest success", res) console.log("removeSavedFileTest success", res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'removeSavedFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'removeSavedFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
...@@ -981,12 +993,13 @@ ...@@ -981,12 +993,13 @@
console.log("success", res) console.log("success", res)
this.fd = res.fd this.fd = res.fd
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'openFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'openFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (_) => { complete: (_) => {
this.done = true this.done = true
...@@ -1047,12 +1060,13 @@ ...@@ -1047,12 +1060,13 @@
this.closeFileRet = res.errMsg this.closeFileRet = res.errMsg
console.log("success", res) console.log("success", res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'closeTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'closeTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (_) => { complete: (_) => {
this.done = true this.done = true
...@@ -1079,12 +1093,13 @@ ...@@ -1079,12 +1093,13 @@
console.log("success", res) console.log("success", res)
this.bytesWritten = res.bytesWritten this.bytesWritten = res.bytesWritten
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'writeTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'writeTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (_) => { complete: (_) => {
this.done = true this.done = true
...@@ -1128,12 +1143,13 @@ ...@@ -1128,12 +1143,13 @@
this.done = true this.done = true
} }
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'openFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'openFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
this.done = true this.done = true
} }
} as OpenFileOptions) } as OpenFileOptions)
...@@ -1150,12 +1166,13 @@ ...@@ -1150,12 +1166,13 @@
console.log("success", res) console.log("success", res)
this.fstat = res.stats this.fstat = res.stats
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'fstatTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'fstatTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (_) => { complete: (_) => {
this.done = true this.done = true
...@@ -1193,12 +1210,13 @@ ...@@ -1193,12 +1210,13 @@
} }
this.ftruncateRet = res.errMsg this.ftruncateRet = res.errMsg
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'ftruncateFileTest fail:' + JSON.stringify(res) + '\n\n' this.log += 'ftruncateFileTest fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
}, },
complete: (res : any) => { complete: (res : any) => {
console.log("complete", res) console.log("complete", res)
...@@ -1239,12 +1257,13 @@ ...@@ -1239,12 +1257,13 @@
} }
console.log("success", res) console.log("success", res)
}, },
fail: (res : UniError) => { fail: (res : IUniError) => {
if (this.logAble) { if (this.logAble) {
this.log += 'readZipEntry fail:' + JSON.stringify(res) + '\n\n' this.log += 'readZipEntry fail:' + JSON.stringify(res) + '\n\n'
} }
console.log('fail', res) console.log('fail', res)
this.lastFailError = res this.lastFailError=new UniError(res.errSubject, res.errCode, res.errMsg)
} }
} as ReadZipEntryOptions) } as ReadZipEntryOptions)
}, },
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<view class="uni-title"> <view class="uni-title">
<text class="uni-subtitle-text">获取本地绝对路径视频信息</text> <text class="uni-subtitle-text">获取本地绝对路径视频信息</text>
</view> </view>
<video class="video" :src="absoluteVideoPath"></video> <video class="video" :src="absoluteVideoPath" :controls="true"></video>
<text class="margin-top-10">{{absoluteVideoInfo}}</text> <text class="margin-top-10">{{absoluteVideoInfo}}</text>
<view class="uni-btn-v"> <view class="uni-btn-v">
<button type="primary" @click="chooseVideo">拍摄视频或从相册中选择视频</button> <button type="primary" @click="chooseVideo">拍摄视频或从相册中选择视频</button>
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
src: res.tempFilePath, src: res.tempFilePath,
success: (_res) => { success: (_res) => {
console.log("getVideoInfo success", JSON.stringify(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) => { fail: (err) => {
uni.showModal({ uni.showModal({
......
<template> <template>
<page-head title="发起支付"></page-head> <page-head title="发起支付"></page-head>
<template v-if="providerList.length > 0"> <template v-if="providerList.length > 0">
<button style="margin-top: 20px;" type="primary" v-for="(item,index) in providerList" :key="index" <button style="margin-top: 20px;" type="primary" v-for="(item,index) in providerList" :key="index"
@click="requestPayment(item)">{{item.name}}支付</button> @click="requestPayment(item)">{{item.name}}支付</button>
</template> </template>
</template> </template>
<script> <script>
export type PayItem = { id : string, name : string } export type PayItem = { id : string, name : string, provider ?: UniProvider }
export default { export default {
data() { data() {
return { return {
btnText: "支付宝支付", btnText: "支付宝支付",
btnType: "primary", btnType: "primary",
orderInfo: "", orderInfo: "",
errorCode: 0, errorCode: 0,
errorMsg: "", errorMsg: "",
complete: false, complete: false,
providerList: [] as PayItem[] providerList: [] as PayItem[]
} }
}, },
onLoad: function () { onLoad: function () {
uni.getProvider({ uni.getProvider({
service: "payment", service: "payment",
success: (e) => { success: (e) => {
console.log("payment success:" + JSON.stringify(e)); console.log("payment success:" + JSON.stringify(e));
let array = e.provider as string[] let array = e.provider as string[]
array.forEach((value : string) => { array.forEach((value : string) => {
switch (value) { switch (value) {
case 'alipay': case 'alipay':
this.providerList.push({ this.providerList.push({
name: '支付宝', name: '支付宝',
id: "alipay", id: "alipay",
} as PayItem); provider: e.providers.find((item) : boolean => {
break; return item?.id == 'alipay'
case 'wxpay': })
this.providerList.push({ } as PayItem);
name: '微信', break;
id: "wxpay", case 'wxpay':
} as PayItem); this.providerList.push({
break; name: '微信',
default: id: "wxpay",
break; provider: e.providers.find((item) : boolean => {
} return item?.id == 'wxpay'
}) })
}, } as PayItem);
fail: (e) => { break;
console.log("获取支付通道失败:", e); default:
} break;
}); }
}, })
methods: { },
requestPayment(e : PayItem) { fail: (e) => {
const provider = e.id console.log("获取支付通道失败:", e);
if (provider == "alipay") { }
this.payAli() });
} else if (provider == "wxpay") { },
this.payWX() methods: {
} requestPayment(e : PayItem) {
}, const provider = e.id
payAli() { if (provider == "alipay") {
uni.showLoading({ this.payAli()
title: "请求中..." } else if (provider == "wxpay") {
})
uni.request({
url: 'https://demo.dcloud.net.cn/payment/alipay/?total=0.01',
method: 'GET',
timeout: 6000,
success: (res) => {
this.orderInfo = JSON.stringify(res.data);
console.log("====" + this.orderInfo)
uni.hideLoading()
uni.requestPayment({
provider: "alipay",
orderInfo: res.data as string,
fail: (res) => {
console.log(JSON.stringify(res))
this.errorCode = res.errCode
uni.showToast({
icon: 'error',
title: 'errorCode:' + this.errorCode
});
},
success: (res) => {
console.log(JSON.stringify(res))
uni.showToast({
icon: 'success',
title: '支付成功'
});
}
})
},
fail: (e) => {
console.log(e)
uni.hideLoading()
},
});
},
payWX() {
uni.showLoading({
title: "请求中..."
})
let url = 'https://demo.dcloud.net.cn/payment/wxpayv3.__UNI__uniappx/?total=1'
const res = uni.getAppBaseInfo();
if (res.packageName == 'io.dcloud.hellouniappx') {//hello uniappx
url = 'https://demo.dcloud.net.cn/payment/wxpayv3.__UNI__HelloUniAppX/?total=1'
}
uni.request({
url: url,
method: 'GET',
timeout: 6000,
header: {
"Content-Type": "application/json"
} as UTSJSONObject,
success: (res) => {
console.log(res.data)
uni.hideLoading()
uni.requestPayment({
provider: "wxpay",
orderInfo: JSON.stringify(res.data),
fail: (res) => {
console.log(JSON.stringify(res))
this.errorCode = res.errCode
uni.showToast({
duration: 5000,
icon: 'error',
title: 'errorCode:' + this.errorCode,
});
},
success: (res) => {
console.log(JSON.stringify(res))
uni.showToast({
duration: 5000,
icon: 'success',
title: '支付成功'
});
}
})
},
fail: (res) => {
uni.hideLoading()
console.log(res)
},
});
},
//自动化测试使用 if (e.provider != null && e.provider?.isAppExist==false) {
jest_pay() { uni.showToast({
uni.requestPayment({ title: "微信没有安装",
provider: "alipay", icon:'error'
orderInfo: this.orderInfo, })
fail: (res : RequestPaymentFail) => { } else {
this.errorCode = res.errCode this.payWX()
this.complete = true }
},
success: (res : RequestPaymentSuccess) => { }
console.log(JSON.stringify(res)) },
this.complete = true payAli() {
} uni.showLoading({
} as RequestPaymentOptions) title: "请求中..."
} })
} uni.request({
} url: 'https://demo.dcloud.net.cn/payment/alipay/?total=0.01',
method: 'GET',
timeout: 6000,
success: (res) => {
this.orderInfo = JSON.stringify(res.data);
console.log("====" + this.orderInfo)
uni.hideLoading()
uni.requestPayment({
provider: "alipay",
orderInfo: res.data as string,
fail: (res) => {
console.log(JSON.stringify(res))
this.errorCode = res.errCode
uni.showToast({
icon: 'error',
title: 'errorCode:' + this.errorCode
});
},
success: (res) => {
console.log(JSON.stringify(res))
uni.showToast({
icon: 'success',
title: '支付成功'
});
}
})
},
fail: (e) => {
console.log(e)
uni.hideLoading()
},
});
},
payWX() {
uni.showLoading({
title: "请求中..."
})
let url = 'https://demo.dcloud.net.cn/payment/wxpayv3.__UNI__uniappx/?total=1'
const res = uni.getAppBaseInfo();
if (res.packageName == 'io.dcloud.hellouniappx') {//hello uniappx
url = 'https://demo.dcloud.net.cn/payment/wxpayv3.__UNI__HelloUniAppX/?total=1'
}
uni.request({
url: url,
method: 'GET',
timeout: 6000,
header: {
"Content-Type": "application/json"
} as UTSJSONObject,
success: (res) => {
console.log(res.data)
uni.hideLoading()
uni.requestPayment({
provider: "wxpay",
orderInfo: JSON.stringify(res.data),
fail: (res) => {
console.log(JSON.stringify(res))
this.errorCode = res.errCode
uni.showToast({
duration: 5000,
icon: 'error',
title: 'errorCode:' + this.errorCode,
});
},
success: (res) => {
console.log(JSON.stringify(res))
uni.showToast({
duration: 5000,
icon: 'success',
title: '支付成功'
});
}
})
},
fail: (res) => {
uni.hideLoading()
console.log(res)
},
});
},
//自动化测试使用
jest_pay() {
uni.requestPayment({
provider: "alipay",
orderInfo: this.orderInfo,
fail: (res : RequestPaymentFail) => {
this.errorCode = res.errCode
this.complete = true
},
success: (res : RequestPaymentSuccess) => {
console.log(JSON.stringify(res))
this.complete = true
}
} as RequestPaymentOptions)
}
}
}
</script> </script>
<style> <style>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<!-- #endif --> <!-- #endif -->
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="uni-padding-wrap"> <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> <button type="primary" class="margin-top-10" @click="saveVideo">将视频保存到手机相册</button>
</view> </view>
<!-- #ifdef APP --> <!-- #ifdef APP -->
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
title: '视频下载中' title: '视频下载中'
}); });
uni.downloadFile({ 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) => { success: (res) => {
console.log("download video success", res.tempFilePath); console.log("download video success", res.tempFilePath);
this.src = res.tempFilePath; this.src = res.tempFilePath;
......
...@@ -348,65 +348,57 @@ ...@@ -348,65 +348,57 @@
url: 'save-image-to-photos-album' url: 'save-image-to-photos-album'
}, },
// #endif // #endif
// #ifdef APP-ANDROID // #ifdef APP-ANDROID || WEB
{ {
name: "获取图片信息", name: "获取图片信息",
url: 'get-image-info' url: 'get-image-info'
}, },
// #endif
// #ifdef APP-ANDROID
{ {
name: "压缩图片", name: "压缩图片",
url: 'compress-image' url: 'compress-image'
}, },
// #endif // #endif
// #ifdef APP
{ {
name: "拍摄视频或从相册中选择视频", name: "拍摄视频或从相册中选择视频",
url: 'choose-video' url: 'choose-video'
}, },
// #ifdef APP
{ {
name: "保存视频到相册", name: "保存视频到相册",
url: 'save-video-to-photos-album' url: 'save-video-to-photos-album'
}, },
// #endif // #endif
// #ifdef APP-ANDROID // #ifdef APP-ANDROID || WEB
{ {
name: "获取视频信息", name: "获取视频信息",
url: 'get-video-info' url: 'get-video-info'
}, },
// #endif
// #ifdef APP-ANDROID
{ {
name: "压缩视频", name: "压缩视频",
url: 'compress-video' url: 'compress-video'
}, },
// #endif // #endif
/* { /* {
name: "图片选择和拍照",
url: "image",
enable: false
},{
name: "音频", name: "音频",
url: "inner-audio", url: "inner-audio",
}, },
{
name: "录音",
url: "voice",
},
{ {
name: "背景音频", name: "背景音频",
url: "background-audio", url: "background-audio",
}, },
{ {
name: "视频选择和拍照", name: "录音",
url: "video", url: "rec",
enable: false
}, },
{ {
name: "文件", name: "文件",
url: "file", url: "file",
}, },
{ */
name: "保存媒体到本地",
url: "save-media",
}, */
] as Page[], ] as Page[],
}, },
{ {
...@@ -446,7 +438,7 @@ ...@@ -446,7 +438,7 @@
} }
] as Page[], ] as Page[],
}, },
// #ifdef APP-ANDROID || APP-IOS // #ifdef APP
{ {
id: 'file', id: 'file',
name: '文件', name: '文件',
...@@ -496,78 +488,52 @@ ...@@ -496,78 +488,52 @@
] as Page[], ] as Page[],
}, },
// #endif // #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", id: "payment",
name: "支付", name: "支付",
pages: [ pages: [
// #ifndef WEB
{ {
name: "简易支付示例", name: "简易支付示例",
url: "request-payment", url: "request-payment",
}, },
// #endif
{ {
name: "uni-pay支付示例", name: "uni-pay支付示例",
url: "request-payment-uni-pay", url: "request-payment-uni-pay",
} }
] as Page[], ] as Page[],
}, },
// #endif // #ifdef APP-ANDROID
// #ifdef WEB
{ {
id: "payment", id: 'ad',
name: "支付", name: '广告',
pages: [ pages: [
{ {
name: "uni-pay支付示例", name: '激励视频广告',
url: "request-payment-uni-pay", url: 'rewarded-video-ad',
} }
/* {
id: "full-screen-video-ad",
url: "full-screen-video-ad",
name: "全屏视频广告",
enable: false,
pages: [] as Page[]
}, */
] as Page[], ] as Page[],
}, },
// #endif
/*
{
id: "full-screen-video-ad",
url: "full-screen-video-ad",
name: "全屏视频广告",
enable: false,
pages: [] as Page[]
},
{ {
id: "login", id: 'permission-listener',
name: "登录", name: '权限申请监听',
pages: [ pages: [
{ {
name: "登录", name: '权限申请监听',
url: "login", url: 'create-request-permission-listener',
}, }
{ ] as Page[]
name: "获取用户信息",
url: "get-user-info",
},
] as Page[],
}, },
// #endif
/*
{ {
id: "share", id: "share",
name: "分享", name: "分享",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册