123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455 |
- <template>
- <!-- #ifdef APP -->
- <scroll-view style="flex: 1;">
- <!-- #endif -->
- <view class="uni-padding-wrap">
- <view class="uni-common-mt flex-row" v-if="pageBody != null">pageBody: {
- top: <text id="page-body-top">{{pageBody!.top}}</text>,
- right: <text id="page-body-right">{{pageBody!.right}}</text>,
- bottom: <text id="page-body-bottom">{{pageBody!.bottom}}</text>,
- left: <text id="page-body-left">{{pageBody!.left}}</text>,
- width: <text id="page-body-width">{{pageBody!.width}}</text>,
- height: <text id="page-body-height">{{pageBody!.height}}</text>
- }
- </view>
- <view class="uni-common-mt flex-row" v-if="safeAreaInsets != null">safeAreaInsets: {
- top: <text id="page-safe-area-insets-top">{{safeAreaInsets!.top}}</text>,
- right: <text id="page-safe-area-insets-right">{{safeAreaInsets!.right}}</text>,
- bottom: <text id="page-safe-area-insets-bottom">{{safeAreaInsets!.bottom}}</text>,
- left: <text id="page-safe-area-insets-left">{{safeAreaInsets!.left}}</text>}
- </view>
- <!-- #ifdef APP-ANDROID || APP-IOS || APP-HARMONY || WEB -->
- <view class="uni-common-mt flex-row" v-if="width != null">width: <text id="page-width">{{width!}}</text>
- </view>
- <view class="uni-common-mt flex-row" v-if="height != null">height: <text id="page-height">{{height!}}</text>
- </view>
- <view class="uni-common-mt flex-row" v-if="statusBarHeight != null">statusBarHeight: <text id="page-statusBarHeight">{{statusBarHeight!}}</text>
- </view>
- <!-- #endif -->
- <button class="uni-common-mt" id="go-next-page" @click="goNextPage">
- go next page
- </button>
- <button class="uni-common-mt" id="open-dialog1" @click="openDialog1">
- open dialog 1
- </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>
- <button class="uni-common-mt" id="open-dialog4" @click="openDialogWithTriggerParentHide">
- openDialog with triggerParentHide
- </button>
- <button class="uni-common-mt" id="open-dialog5" @click="openDialogCheckMoreAttribute">
- openDialog check more attribute
- </button>
- <button class="uni-common-mt" id="open-dialog5" @click="openDialogWithRelativePath">
- openDialog with relative path
- </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>
- <!-- #ifdef APP -->
- </scroll-view>
- <!-- #endif -->
- </template>
- <script lang="uts">
- import {
- state,
- setLifeCycleNum
- } 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 {
- data() {
- return {
- pageBody : null as UniPageBody | null,
- safeAreaInsets: null as UniSafeAreaInsets | null,
- width: null as number | null,
- height: null as number | null,
- statusBarHeight: null as number | null,
- jest_click_x: -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() {
- console.log('dialogPage parent onLoad')
- },
- onShow() {
- console.log('dialogPage parent onShow')
- setLifeCycleNum(state.lifeCycleNum + 10)
- },
- onReady() {
- console.log('dialogPage parent onReady')
- const currentPage = this.$page
- this.pageBody = currentPage.pageBody;
- this.safeAreaInsets = currentPage.safeAreaInsets
- // #ifdef APP-ANDROID || APP-IOS || APP-HARMONY || WEB
- this.width = currentPage.width
- this.height = currentPage.height
- this.statusBarHeight = currentPage.statusBarHeight
- // #endif
- },
- onHide() {
- console.log('dialogPage parent onHide')
- setLifeCycleNum(state.lifeCycleNum - 10)
- },
- onUnload() {
- console.log('dialogPage parent onUnload')
- },
- methods: {
- goNextPage() {
- uni.navigateTo({
- url: '/pages/API/dialog-page/next-page'
- })
- },
- openDialog1() {
- uni.openDialogPage({
- url: '/pages/API/dialog-page/dialog-1?name=dialog1',
- animationType: this.openAnimationType,
- success(res) {
- console.log('openDialogPage1 success', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- },
- fail(err) {
- console.log('openDialogPage1 fail', err)
- setLifeCycleNum(state.lifeCycleNum - 4)
- },
- complete(res) {
- console.log('openDialogPage1 complete', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- }
- })
- },
- openDialog2() {
- uni.openDialogPage({
- url: '/pages/API/dialog-page/dialog-2',
- animationType: this.openAnimationType,
- disableEscBack: true,
- success(res) {
- console.log('openDialog2 success', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- },
- fail(err) {
- console.log('openDialog2 fail', err)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum - 4)
- },
- complete(res) {
- console.log('openDialog2 complete', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- }
- })
- },
- openDialog1WrongPath() {
- uni.openDialogPage({
- url: '/pages/API/dialog-page/dialog-11?name=dialog1',
- success(res) {
- console.log('openDialogPage1 success', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- },
- fail(err) {
- console.log('openDialogPage1 fail', err)
- setLifeCycleNum(state.lifeCycleNum - 4)
- },
- complete(res) {
- console.log('openDialogPage1 complete', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- }
- })
- },
- goNextPageOpenDialog1() {
- uni.navigateTo({
- url: '/pages/API/dialog-page/next-page',
- success() {
- setTimeout(() => {
- uni.openDialogPage({
- url: '/pages/API/dialog-page/dialog-1?name=dialog1',
- animationType: this.openAnimationType,
- success(res) {
- console.log('openDialogPage1 success', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- },
- fail(err) {
- console.log('openDialogPage1 fail', err)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum - 4)
- },
- complete(res) {
- console.log('openDialogPage1 complete', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- }
- })
- }, 2000)
- }
- })
- },
- closeDialog() {
- uni.closeDialogPage({
- success(res) {
- console.log('closeDialog success', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- },
- fail(err) {
- console.log('closeDialog fail', err)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum - 4)
- },
- complete(res) {
- console.log('closeDialog complete', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- }
- })
- },
- closeSpecifiedDialog(index : number) {
- const dialogPages = this.$page.getDialogPages()
- uni.closeDialogPage({
- dialogPage: dialogPages[index],
- success(res) {
- console.log('closeSomeOneDialog success', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- },
- fail(err) {
- console.log('closeSomeOneDialog fail', err)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum - 4)
- },
- complete(res) {
- console.log('closeSomeOneDialog complete', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- }
- })
- },
- // 自动化测试
- openDialog4() {
- uni.openDialogPage({
- url: '/pages/API/dialog-page/dialog-4',
- })
- },
- openDialogWithTriggerParentHide() {
- uni.openDialogPage({
- url: `/pages/API/dialog-page/dialog-4?tag=${Date.now()}`,
- triggerParentHide: true,
- success(res) {
- console.log('openDialogWithTriggerParentHide success', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- },
- fail(err) {
- console.log('openDialogWithTriggerParentHide fail', err)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum - 4)
- },
- complete(res) {
- console.log('openDialogWithTriggerParentHide complete', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- }
- })
- },
- openDialogCheckMoreAttribute(){
- uni.openDialogPage({
- url: '/pages/API/dialog-page/dialog-5',
- })
- },
- setLifeCycleNum(value : number) {
- setLifeCycleNum(value)
- },
- getLifeCycleNum() : number {
- return state.lifeCycleNum
- },
- jest_OpenDialog1() {
- uni.openDialogPage({
- url: '/pages/API/dialog-page/dialog-1?name=dialog1'
- })
- },
- jest_CloseDialog1() {
- uni.closeDialogPage({})
- },
- jest_getTapPoint() {
- const systemInfo = uni.getSystemInfoSync()
- let ratio = 1
- if (systemInfo.platform == 'android') {
- ratio = systemInfo.devicePixelRatio
- }
- this.jest_click_x = systemInfo.screenWidth / 2 * ratio
- this.jest_click_y = systemInfo.statusBarHeight * ratio + 10
- },
- openDialog2ForTest() {
- uni.openDialogPage({
- url: '/pages/API/dialog-page/dialog-2'
- });
- },
- closeDialog2ForTest() {
- uni.closeDialogPage({});
- },
- setPageStyleForTest(style : UTSJSONObject) {
- const pages = this.$page.getDialogPages();
- if (pages.length > 0) pages[pages.length - 1].setPageStyle(style);
- },
- setPageStyleForTest2(style : UTSJSONObject) {
- this.$page.setPageStyle(style);
- },
- openDialog3() {
- uni.openDialogPage({ url: '/pages/API/dialog-page/dialog-3', animationType: this.openAnimationType })
- },
- handleOpenAnimationType(e : RadioGroupChangeEvent) {
- this.openAnimationType = e.detail.value as OpenAnimationType
- },
- openDialogWithRelativePath(){
- uni.openDialogPage({
- url: './dialog-1?name=dialog1',
- animationType: this.openAnimationType,
- success(res) {
- console.log('openDialogPage1 success', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- },
- fail(err) {
- console.log('openDialogPage1 fail', err)
- setLifeCycleNum(state.lifeCycleNum - 4)
- },
- complete(res) {
- console.log('openDialogPage1 complete', res)
- // 自动化测试
- setLifeCycleNum(state.lifeCycleNum + 1)
- }
- })
- },
- // 自动化测试
- getDialogPage() : UniPage | null {
- const dialogPages = this.$page.getDialogPages()
- return dialogPages.length > 0 ? dialogPages[0] : null
- },
- // 自动化测试
- getDialogPageRoute() : string {
- const dialogPage = this.getDialogPage()
- if(dialogPage != null){
- return dialogPage.route
- }
- return ''
- },
- // 自动化测试
- dialogPageCheckGetDialogPages() : boolean {
- const dialogPage = this.getDialogPage()!
- const dialogPages = dialogPage.getDialogPages()
- const res = dialogPages.length == 0
- return res
- },
- // 自动化测试
- dialogPageGetPageStyle() : UTSJSONObject {
- const dialogPage = this.getDialogPage()!
- return dialogPage.getPageStyle()
- },
- // 自动化测试
- dialogPageSetPageStyle() {
- const dialogPage = this.getDialogPage()!
- dialogPage.setPageStyle({
- backgroundColorContent: 'red'
- })
- },
- // 自动化测试
- dialogPageCheckGetElementById() : boolean {
- const dialogPage = this.getDialogPage()!
- const element = dialogPage.getElementById('dialog1-go-next-page')
- let res = element != null
- // #ifndef APP-ANDROID
- if (res) {
- const elPage = element!.getPage()
- console.log('elPage', elPage)
- res = elPage === dialogPage
- }
- // #endif
- return res
- },
- // 自动化测试
- dialogCheckGetAndroidView() : boolean {
- const dialogPage = this.getDialogPage()!
- const androidView = dialogPage.getAndroidView()
- const res = androidView != null
- return res
- },
- // 自动化测试
- dialogCheckGetIOSView() : boolean {
- const dialogPage = this.getDialogPage()!
- const IOSView = dialogPage.getIOSView()
- const res = IOSView != null
- return res
- },
- // 自动化测试
- dialogCheckGetHTMLElement() : boolean {
- const dialogPage = this.getDialogPage()!
- const HTMLView = dialogPage.getHTMLElement()
- const res = HTMLView != null
- return res
- },
- }
- }
- </script>
- <style>
- .uni-padding-wrap{
- padding-bottom: var(--uni-safe-area-inset-bottom);
- }
- .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;
- margin-bottom: 20px;
- }
- .flex-row{
- flex-direction: row;
- flex-wrap: wrap;
- }
- </style>style>
|