ShowModal.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <uni-popup ref="popup" type="center">
  3. <view class="show-modal">
  4. <IconText class="close" @click.native="close" :code="`\ue847`" color="#999" size="10"></IconText>
  5. <view class="title">{{title}}</view>
  6. <view class="content" v-html="content"></view>
  7. <view class="btn-box" :class="{'btn-styl': leftBtnText}">
  8. <view class="btn cancel-btn" @click="close" v-if="leftBtnText">{{leftBtnText}}</view>
  9. <view class="btn" @click="submit">{{btnText}}</view>
  10. </view>
  11. </view>
  12. </uni-popup>
  13. </template>
  14. <script lang="ts">
  15. import {
  16. Component,
  17. Prop,
  18. Vue,
  19. Emit,
  20. Ref,
  21. Watch
  22. } from 'vue-property-decorator';
  23. @Component({})
  24. export default class ShowModal extends Vue {
  25. @Prop({
  26. default: ''
  27. })
  28. private title ? : string; //
  29. @Prop({
  30. default: ''
  31. })
  32. private content ? : string; //
  33. @Prop({
  34. default: ''
  35. })
  36. private btnText ? : string; //
  37. @Prop({
  38. default: ""
  39. })
  40. private leftBtnText ? : string; //
  41. open() {
  42. (this.$refs.popup as any).open();
  43. }
  44. close() {
  45. (this.$refs.popup as any).close();
  46. }
  47. // emit---------------------------
  48. @Emit('submit')
  49. submit() { //弹窗点击确认按钮
  50. this.close();
  51. return '点击确认'
  52. }
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. .show-modal {
  57. background: #fff;
  58. width: vw(300);
  59. @include flex-y();
  60. border-radius: vw(10);
  61. position: relative;
  62. .close {
  63. position: absolute;
  64. right: vw(5);
  65. top: vw(5);
  66. padding: vw(5);
  67. }
  68. .title {
  69. @include word-vw(16, #333);
  70. margin-top: vw(25);
  71. }
  72. .content {
  73. @include word-vw(14, #666);
  74. margin-top: vw(12);
  75. text-align: center;
  76. }
  77. .btn {
  78. width: vw(65);
  79. height: vw(35);
  80. line-height: vw(35);
  81. text-align: center;
  82. background: $btn-color;
  83. @include word-vw(14, #fff);
  84. border-radius: vw(5);
  85. margin-top: vw(16);
  86. margin-bottom: vw(20);
  87. }
  88. .cancel-btn {
  89. margin-right: 32px;
  90. background: #EBEBEB;
  91. @include word-vw(14, #333);
  92. }
  93. .btn-cancel {
  94. width: vw(150);
  95. height: vw(35);
  96. line-height: vw(35);
  97. text-align: center;
  98. background: #1A1A1A;
  99. @include word-vw(14, #fff);
  100. border-radius: vw(4);
  101. margin-top: vw(28);
  102. margin-bottom: vw(15);
  103. }
  104. .btn-box {
  105. border-top: vw(1) solid #F5F5F5;
  106. margin-top: vw(10);
  107. width: vw(200);
  108. @include flex-x(center);
  109. }
  110. .btn-styl {
  111. @include flex-x(center);
  112. .btn {
  113. width: vw(90);
  114. }
  115. .btn-cancel {
  116. width: vw(90);
  117. margin-right: vw(20);
  118. }
  119. }
  120. }
  121. </style>