dialog-5.uvue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view class="dialog-container">
  3. <view class="dialog-content">
  4. <text>title: {{ title }}</text>
  5. <view class="uni-common-mt flex-row" v-if="pageBody != null">pageBody: {
  6. top: <text id="page-body-top">{{pageBody!.top}}</text>,
  7. right: <text id="page-body-right">{{pageBody!.right}}</text>,
  8. bottom: <text id="page-body-bottom">{{pageBody!.bottom}}</text>,
  9. left: <text id="page-body-left">{{pageBody!.left}}</text>,
  10. width: <text id="page-body-width">{{pageBody!.width}}</text>,
  11. height: <text id="page-body-height">{{pageBody!.height}}</text>
  12. }
  13. </view>
  14. <view class="uni-common-mt flex-row" v-if="safeAreaInsets != null">safeAreaInsets: {
  15. top: <text id="page-safe-area-insets-top">{{safeAreaInsets!.top}}</text>,
  16. right: <text id="page-safe-area-insets-right">{{safeAreaInsets!.right}}</text>,
  17. bottom: <text id="page-safe-area-insets-bottom">{{safeAreaInsets!.bottom}}</text>,
  18. left: <text id="page-safe-area-insets-left">{{safeAreaInsets!.left}}</text>}
  19. </view>
  20. <!-- #ifdef APP-ANDROID || APP-IOS || WEB -->
  21. <view class="uni-common-mt flex-row" v-if="width != null">width: <text>{{width!}}</text>
  22. </view>
  23. <view class="uni-common-mt flex-row" v-if="height != null">height: <text>{{height!}}</text>
  24. </view>
  25. <view class="uni-common-mt flex-row" v-if="statusBarHeight != null">statusBarHeight: <text>{{statusBarHeight!}}</text>
  26. </view>
  27. <!-- #endif -->
  28. <button class="mt-10" @click="closeThisDialog">
  29. closeThisDialog
  30. </button>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. title: 'dialog 5',
  39. pageBody : null as UniPageBody | null,
  40. safeAreaInsets: null as UniSafeAreaInsets | null,
  41. width: null as number | null,
  42. height: null as number | null,
  43. statusBarHeight: null as number | null,
  44. }
  45. },
  46. onShow() {
  47. console.log('dialog 5 onShow')
  48. },
  49. onReady(){
  50. const currentPage = this.$page
  51. this.pageBody = currentPage.pageBody;
  52. this.safeAreaInsets = currentPage.safeAreaInsets
  53. // #ifdef APP-ANDROID || APP-IOS || WEB
  54. this.width = currentPage.width
  55. this.height = currentPage.height
  56. this.statusBarHeight = currentPage.statusBarHeight
  57. // #endif
  58. },
  59. onUnload() {
  60. console.log('dialog 5 onUnload')
  61. },
  62. methods: {
  63. closeThisDialog() {
  64. uni.closeDialogPage({
  65. dialogPage: this.$page,
  66. success(res) {
  67. console.log('closeThisDialog success', res)
  68. },
  69. fail(err) {
  70. console.log('closeThisDialog fail', err)
  71. },
  72. complete(res) {
  73. console.log('closeThisDialog complete', res)
  74. }
  75. })
  76. }
  77. }
  78. }
  79. </script>
  80. <style>
  81. .dialog-container {
  82. width: 100%;
  83. height: 100%;
  84. background-color: rgba(0, 0, 0, 0.3);
  85. display: flex;
  86. justify-content: center;
  87. align-items: center;
  88. }
  89. .dialog-content {
  90. width: 80%;
  91. padding: 10px;
  92. background-color: #fff;
  93. border-radius: 6px;
  94. }
  95. .mt-10 {
  96. margin-top: 10px;
  97. }
  98. .flex-row{
  99. flex-direction: row;
  100. flex-wrap: wrap;
  101. }
  102. </style>