提交 7fcb629b 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat(dialogPage): 示例补充打开动画

上级 fad5626d
<template> <template>
<view class="uni-padding-wrap"> <view class="uni-padding-wrap">
<button class="uni-common-mt" id="go-next-page" @click="goNextPage">go next page</button> <button class="uni-common-mt" id="go-next-page" @click="goNextPage">
<button class="uni-common-mt" id="open-dialog1" @click="openDialog1">open dialog 1</button> go next page
<button class="uni-common-mt" id="open-dialog1-wrong-path" @click="openDialog1WrongPath">open dialog page 1 with </button>
wrong path</button> <button class="uni-common-mt" id="open-dialog1" @click="openDialog1">
<button class="uni-common-mt" id="go-next-page-open-dialog1" @click="goNextPageOpenDialog1">go next page & open open dialog 1
dialog1</button> </button>
<button class="uni-common-mt" id="open-dialog1-wrong-path" @click="openDialog1WrongPath">
open dialog page 1 with wrong path
</button>
<button class="uni-common-mt" id="go-next-page-open-dialog1" @click="goNextPageOpenDialog1">
go next page & open dialog1
</button>
<button class="uni-common-mt" id="open-dialog1" @click="openDialog3">
open dialog 3 test page style
</button>
<text class="uni-common-mt choose-open-animation-type-title">choose open dialogPage animationType</text>
<radio-group class="choose-open-animation-type-radio-group" @change="handleOpenAnimationType">
<radio class="ml-10 uni-common-mt" v-for="item in openAnimationTypeList" :key="item" :value="item"
:checked="openAnimationType == item">{{ item }}
</radio>
</radio-group>
</view> </view>
</template> </template>
<script lang='uts'> <script lang="uts">
import { import {
state, state,
setLifeCycleNum setLifeCycleNum
} from '@/store/index.uts' } from '@/store/index.uts'
type OpenAnimationType =
'auto' |
'none' |
'slide-in-right' |
'slide-in-left' |
'slide-in-top' |
'slide-in-bottom' |
'fade-in' |
'zoom-out' |
'zoom-fade-out'
export default { export default {
data() { data() {
return { return {
jest_click_x: -1, jest_click_x: -1,
jest_click_y: -1 jest_click_y: -1,
openAnimationType: 'none' as OpenAnimationType,
openAnimationTypeList: [
'auto',
'none',
'slide-in-right',
'slide-in-left',
'slide-in-top',
'slide-in-bottom',
'fade-in',
'zoom-out',
'zoom-fade-out'
]
} }
}, },
onLoad() { onLoad() {
...@@ -48,6 +86,7 @@ ...@@ -48,6 +86,7 @@
openDialog1() { openDialog1() {
uni.openDialogPage({ uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-1?name=dialog1', url: '/pages/API/dialog-page/dialog-1?name=dialog1',
animationType: this.openAnimationType,
success(res) { success(res) {
console.log('openDialogPage1 success', res) console.log('openDialogPage1 success', res)
// 自动化测试 // 自动化测试
...@@ -67,6 +106,7 @@ ...@@ -67,6 +106,7 @@
openDialog2() { openDialog2() {
uni.openDialogPage({ uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-2', url: '/pages/API/dialog-page/dialog-2',
animationType: this.openAnimationType,
disableEscBack: true, disableEscBack: true,
success(res) { success(res) {
console.log('openDialog2 success', res) console.log('openDialog2 success', res)
...@@ -111,6 +151,7 @@ ...@@ -111,6 +151,7 @@
setTimeout(() => { setTimeout(() => {
uni.openDialogPage({ uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-1?name=dialog1', url: '/pages/API/dialog-page/dialog-1?name=dialog1',
animationType: this.openAnimationType,
success(res) { success(res) {
console.log('openDialogPage1 success', res) console.log('openDialogPage1 success', res)
// 自动化测试 // 自动化测试
...@@ -150,7 +191,7 @@ ...@@ -150,7 +191,7 @@
} }
}) })
}, },
closeSpecifiedDialog(index: number) { closeSpecifiedDialog(index : number) {
const dialogPages = this.$page.getDialogPages() const dialogPages = this.$page.getDialogPages()
uni.closeDialogPage({ uni.closeDialogPage({
dialogPage: dialogPages[index], dialogPage: dialogPages[index],
...@@ -171,10 +212,10 @@ ...@@ -171,10 +212,10 @@
} }
}) })
}, },
setLifeCycleNum(value: number) { setLifeCycleNum(value : number) {
setLifeCycleNum(value) setLifeCycleNum(value)
}, },
getLifeCycleNum(): number { getLifeCycleNum() : number {
return state.lifeCycleNum return state.lifeCycleNum
}, },
jest_OpenDialog1() { jest_OpenDialog1() {
...@@ -202,32 +243,38 @@ ...@@ -202,32 +243,38 @@
closeDialog2ForTest() { closeDialog2ForTest() {
uni.closeDialogPage({}); uni.closeDialogPage({});
}, },
setPageStyleForTest(style: UTSJSONObject) { setPageStyleForTest(style : UTSJSONObject) {
const pages = this.$page.getDialogPages(); const pages = this.$page.getDialogPages();
if (pages.length > 0) pages[pages.length - 1].setPageStyle(style); if (pages.length > 0) pages[pages.length - 1].setPageStyle(style);
}, },
getDialogPage(): UniPage | null { openDialog3() {
uni.openDialogPage({ url: '/pages/API/dialog-page/dialog-3', animationType: this.openAnimationType })
},
handleOpenAnimationType(e : RadioGroupChangeEvent) {
this.openAnimationType = e.detail.value as OpenAnimationType
},
getDialogPage() : UniPage | null {
const dialogPages = this.$page.getDialogPages() const dialogPages = this.$page.getDialogPages()
return dialogPages.length > 0 ? dialogPages[0] : null return dialogPages.length > 0 ? dialogPages[0] : null
}, },
dialogPageCheckGetDialogPages(): boolean { dialogPageCheckGetDialogPages() : boolean {
const dialogPage = this.getDialogPage() ! const dialogPage = this.getDialogPage()!
const dialogPages = dialogPage.getDialogPages() const dialogPages = dialogPage.getDialogPages()
const res = dialogPages.length == 0 const res = dialogPages.length == 0
return res return res
}, },
dialogPageGetPageStyle(): UTSJSONObject { dialogPageGetPageStyle() : UTSJSONObject {
const dialogPage = this.getDialogPage() ! const dialogPage = this.getDialogPage()!
return dialogPage.getPageStyle() return dialogPage.getPageStyle()
}, },
dialogPageSetPageStyle() { dialogPageSetPageStyle() {
const dialogPage = this.getDialogPage() ! const dialogPage = this.getDialogPage()!
dialogPage.setPageStyle({ dialogPage.setPageStyle({
backgroundColorContent: 'red' backgroundColorContent: 'red'
}) })
}, },
dialogPageCheckGetElementById(): boolean { dialogPageCheckGetElementById() : boolean {
const dialogPage = this.getDialogPage() ! const dialogPage = this.getDialogPage()!
const element = dialogPage.getElementById('dialog1-go-next-page') const element = dialogPage.getElementById('dialog1-go-next-page')
let res = element != null let res = element != null
// #ifndef APP-ANDROID // #ifndef APP-ANDROID
...@@ -239,20 +286,20 @@ ...@@ -239,20 +286,20 @@
// #endif // #endif
return res return res
}, },
dialogCheckGetAndroidView(): boolean { dialogCheckGetAndroidView() : boolean {
const dialogPage = this.getDialogPage() ! const dialogPage = this.getDialogPage()!
const androidView = dialogPage.getAndroidView() const androidView = dialogPage.getAndroidView()
const res = androidView != null const res = androidView != null
return res return res
}, },
dialogCheckGetIOSView(): boolean { dialogCheckGetIOSView() : boolean {
const dialogPage = this.getDialogPage() ! const dialogPage = this.getDialogPage()!
const IOSView = dialogPage.getIOSView() const IOSView = dialogPage.getIOSView()
const res = IOSView != null const res = IOSView != null
return res return res
}, },
dialogCheckGetHTMLElement(): boolean { dialogCheckGetHTMLElement() : boolean {
const dialogPage = this.getDialogPage() ! const dialogPage = this.getDialogPage()!
const HTMLView = dialogPage.getHTMLElement() const HTMLView = dialogPage.getHTMLElement()
const res = HTMLView != null const res = HTMLView != null
return res return res
...@@ -260,3 +307,18 @@ ...@@ -260,3 +307,18 @@
} }
} }
</script> </script>
<style>
.ml-10 {
margin-left: 10px;
}
.choose-open-animation-type-title {
font-weight: bold;
}
.choose-open-animation-type-radio-group {
flex-direction: row;
flex-wrap: wrap;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册