dialog-2.uvue 3.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
<template>
  <view id="dialog2" class="dialog-container">
    <view class="dialog-content">
      <text>title: {{title}}</text>
      <text class="mt-10">onBackPress return false</text>
      <button class="mt-10" @click="goNextPage">go next page</button>
      <button class="mt-10" @click="openDialog1">openDialog1</button>
      <button class="mt-10" @click="closeDialog">closeDialog</button>
      <button class="mt-10" @click="closeThisDialog">closeThisDialog</button>
      <button class="mt-10" @click="back">back</button>
    </view>
  </view>
</template>

<script>
  import {
    state,
    setLifeCycleNum
  } from '@/store/index.uts'

  export default {
    data() {
      return {
        title: 'dialog 2',
      }
    },
    onLoad(options : OnLoadOptions) {
      console.log('dialog 2 onLoad', options)
      // 自动化测试
      setLifeCycleNum(state.lifeCycleNum + 1)
    },
    onShow() {
      console.log('dialog 2 onShow')
      // 自动化测试
      setLifeCycleNum(state.lifeCycleNum + 1)
    },
    onReady() {
      console.log('dialog 2 onReady')
      // 自动化测试
      setLifeCycleNum(state.lifeCycleNum + 1)
    },
    onHide() {
      console.log('dialog 2 onHide')
      // 自动化测试
      setLifeCycleNum(state.lifeCycleNum - 1)
    },
    onUnload() {
      console.log('dialog 2 onUnload')
      // 自动化测试
      setLifeCycleNum(state.lifeCycleNum - 5)
    },
    onBackPress(options : OnBackPressOptions) : boolean | null {
      // 自动化测试
      setLifeCycleNum(state.lifeCycleNum + 1)
      return false
    },
    methods: {
      goNextPage() {
        uni.navigateTo({ url: '/pages/API/dialog-page/next-page' })
      },
      openDialog1() {
        uni.openDialogPage({
          url: '/pages/API/dialog-page/dialog-1?name=dialog1',
          success(res) {
            console.log('openDialog1 success', res)
          },
          fail(err) {
            console.log('openDialog1 fail', err)
          },
          complete(res) {
            console.log('openDialog1 complete', res)
          }
        })
      },
      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)
          }
        })
      },
      closeThisDialog() {
        uni.closeDialogPage({
          dialogPage: this.$dialogPage,
          success(res) {
            console.log('closeThisDialog success', res)
            // 自动化测试
            setLifeCycleNum(state.lifeCycleNum + 1)
          },
          fail(err) {
            console.log('closeThisDialog fail', err)
            // 自动化测试
            setLifeCycleNum(state.lifeCycleNum - 4)
          },
          complete(res) {
            console.log('closeThisDialog complete', res)
            // 自动化测试
            setLifeCycleNum(state.lifeCycleNum + 1)
          }
        })
      },
      back() {
        uni.navigateBack()
      }
    }
  }
</script>

<style>
  .dialog-container {
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .dialog-content {
    width: 80%;
    padding: 10px;
    background-color: #fff;
    border-radius: 6px;
  }

  .mt-10 {
    margin-top: 10px;
  }
</style>