app-dialog.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="app-dialog cross-center" :class="iVisible ? 'show' : '' ">
  3. <view class="background" @click="close"></view>
  4. <view class="container">
  5. <view class="header">
  6. <view class="title">{{title}}</view>
  7. <view class="close" @click="close">
  8. <image src="/static/image/icon/icon-close.png"
  9. style="width: 30rpx;height: 30rpx;"></image>
  10. </view>
  11. </view>
  12. <view style="padding: 0 34rpx">
  13. <scroll-view scroll-y class="body">
  14. <text>{{content}}</text>
  15. </scroll-view>
  16. </view>
  17. <view class="footer">
  18. <view class="confirm" @click="confirm">{{confirmText}}</view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. name: "app-dialog",
  26. props: {
  27. title: {
  28. default: '',
  29. },
  30. content: {
  31. default: '',
  32. },
  33. visible: {
  34. type: Boolean,
  35. default: false,
  36. },
  37. confirmText: {
  38. default: '确认',
  39. },
  40. },
  41. data() {
  42. return {
  43. iVisible: this.visible,
  44. };
  45. },
  46. watch: {
  47. visible(v) {
  48. this.iVisible = v;
  49. },
  50. },
  51. methods: {
  52. close() {
  53. this.iVisible = false;
  54. this.$emit('update:visible', this.iVisible);
  55. },
  56. confirm() {
  57. this.iVisible = false;
  58. this.$emit('update:visible', this.iVisible);
  59. },
  60. },
  61. }
  62. </script>
  63. <style scoped lang="scss">
  64. .app-dialog {
  65. position: fixed;
  66. top: 0;
  67. left: 0;
  68. width: 100%;
  69. height: 100%;
  70. z-index: 100;
  71. padding: #{50rpx};
  72. visibility: hidden;
  73. .background {
  74. position: fixed;
  75. top: 0;
  76. left: 0;
  77. width: 100%;
  78. height: 100%;
  79. background: rgba(0, 0, 0, .5);
  80. z-index: 1;
  81. }
  82. .container {
  83. z-index: 2;
  84. background: #fff;
  85. border-radius: #{15rpx};
  86. overflow: hidden;
  87. width: 100%;
  88. .header {
  89. padding: #{40rpx} #{100rpx};
  90. position: relative;
  91. margin-bottom: #{2rpx};
  92. .title {
  93. white-space: nowrap;
  94. overflow: hidden;
  95. text-overflow: ellipsis;
  96. text-align: center;
  97. font-size: #{32rpx};
  98. }
  99. .close {
  100. position: absolute;
  101. top: 0;
  102. right: 0;
  103. padding: #{24rpx};
  104. }
  105. }
  106. .body {
  107. padding: #{22rpx} #{32rpx};
  108. border: #{1rpx} solid #e2e2e2;
  109. border-radius: #{15rpx};
  110. margin-bottom: #{32rpx};
  111. height: #{517rpx};
  112. word-break: break-all;
  113. }
  114. .footer {
  115. border-top: #{1rpx} solid #e2e2e2;
  116. .confirm {
  117. text-align: center;
  118. padding: #{29rpx};
  119. font-size: #{32rpx};
  120. color: #666666;
  121. }
  122. }
  123. }
  124. }
  125. .app-dialog.show {
  126. visibility: visible;
  127. }
  128. </style>