base-popup.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="base-popup">
  3. <u-popup
  4. :show="show"
  5. :round="10"
  6. mode="center"
  7. @close="close"
  8. :customStyle="popupCustomStyle"
  9. :closeOnClickOverlay="false"
  10. >
  11. <view class="header flex justify-between align-center">
  12. <view class="u-font-16 u-font-500" :style="titleStyle">{{ title }}</view>
  13. <u-icon :bold="true" name="close" color="#1E252B" size="16" @click="close()"></u-icon>
  14. </view>
  15. <view class="main">
  16. <slot name="main"></slot>
  17. </view>
  18. <view class="footer flex justify-between">
  19. <view>
  20. <slot name="footerLeft"></slot>
  21. </view>
  22. <view class="flex align-center">
  23. <u-button
  24. class="u-m-r-16"
  25. :customStyle="closeCustomStyle"
  26. @click="close()"
  27. v-if="cancelShow"
  28. >{{ cancelText }}</u-button
  29. >
  30. <u-button type="primary" :customStyle="confirmCustomStyle" @click="confirm()">{{
  31. confirmText
  32. }}</u-button>
  33. </view>
  34. </view>
  35. </u-popup>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. name: 'base-popup',
  41. props: {
  42. show: {
  43. type: Boolean,
  44. default: false,
  45. },
  46. title: {
  47. type: String,
  48. default: '标题',
  49. },
  50. width: {
  51. type: String,
  52. default: '520px',
  53. },
  54. fontWeight: {
  55. type: String,
  56. default: '',
  57. },
  58. cancelText: {
  59. type: String,
  60. default: '取消',
  61. },
  62. confirmText: {
  63. type: String,
  64. default: '确认',
  65. },
  66. cancelShow: {
  67. type: Boolean,
  68. default: true,
  69. },
  70. },
  71. data() {
  72. return {};
  73. },
  74. computed: {
  75. titleStyle() {
  76. let { fontWeight } = this;
  77. return {
  78. fontWeight,
  79. };
  80. },
  81. popupCustomStyle() {
  82. return {
  83. width: this.width,
  84. };
  85. },
  86. closeCustomStyle() {
  87. return {
  88. width: '84px',
  89. height: '36px',
  90. border: '1px solid #d3d6d8',
  91. color: '#1E252B',
  92. };
  93. },
  94. confirmCustomStyle() {
  95. return {
  96. width: '84px',
  97. height: '36px',
  98. background: '#2196F3',
  99. };
  100. },
  101. },
  102. methods: {
  103. close() {
  104. this.$emit('update:show', false);
  105. this.$emit('close');
  106. },
  107. confirm() {
  108. this.$emit('confirm');
  109. },
  110. },
  111. };
  112. </script>
  113. <style lang="scss">
  114. .base-popup {
  115. .header {
  116. padding: 16px 24px;
  117. }
  118. .main {
  119. padding: 24px;
  120. border-top: 1px solid #eaebec;
  121. border-bottom: 1px solid #eaebec;
  122. }
  123. .footer {
  124. padding: 16px 20px;
  125. }
  126. }
  127. </style>