You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
3.6 KiB

4 weeks ago
  1. <template>
  2. <view>
  3. <view v-if="internalVisible" class="fm-overlay"></view>
  4. <view v-if="internalVisible" class="fm-wrap">
  5. <view class="fm-card" :style="{ width: _width }">
  6. <text class="fm-title">{{ _title }}</text>
  7. <view class="fm-icon-wrap">
  8. <image :src="imgSrcComputed" mode="aspectFit" class="fm-icon-img" />
  9. </view>
  10. <text class="fm-sub">{{ _subtitle }}</text>
  11. <view class="fm-btn-wrap">
  12. <button class="fm-btn" @click="onConfirm">{{ _buttonText }}</button>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. name: 'FeedbackModal',
  21. props: {
  22. title: {
  23. type: String,
  24. default: '提交成功'
  25. },
  26. subtitle: {
  27. type: String,
  28. default: '— 感谢您的反馈 —'
  29. },
  30. buttonText: {
  31. type: String,
  32. default: '确定'
  33. },
  34. status: {
  35. type: String,
  36. default: 'success'
  37. },
  38. lockScroll: {
  39. type: Boolean,
  40. default: true
  41. },
  42. width: {
  43. type: String,
  44. default: '600rpx'
  45. }
  46. },
  47. data() {
  48. return {
  49. internalVisible: false,
  50. _title: this.title,
  51. _subtitle: this.subtitle,
  52. _buttonText: this.buttonText,
  53. _status: this.status,
  54. _width: this.width,
  55. };
  56. },
  57. computed: {
  58. imgSrcComputed() {
  59. return this._status === 'fail' ?
  60. '/static/customer-service-platform/fail-icon.png' :
  61. '/static/customer-service-platform/success-icon.png';
  62. }
  63. },
  64. methods: {
  65. show(options = {}) {
  66. if (options.title) this._title = options.title;
  67. if (options.subtitle) this._subtitle = options.subtitle;
  68. if (options.buttonText) this._buttonText = options.buttonText;
  69. if (options.status) this._status = options.status;
  70. if (options.width) this._width = options.width;
  71. if (this.lockScroll) this._lockScroll();
  72. this.internalVisible = true;
  73. },
  74. hide() {
  75. this.internalVisible = false;
  76. if (this.lockScroll) this._unlockScroll();
  77. },
  78. onConfirm() {
  79. this.hide();
  80. this.$nextTick(() => {
  81. this.$emit('confirm', {
  82. status: this._status
  83. });
  84. });
  85. },
  86. //整个页面的滚动条被禁用,防止用户无法上下滚动页面
  87. _lockScroll() {
  88. try {
  89. document.body.style.overflow = 'hidden';
  90. } catch (e) {}
  91. },
  92. _unlockScroll() {
  93. try {
  94. document.body.style.overflow = '';
  95. } catch (e) {}
  96. }
  97. },
  98. beforeDestroy() {
  99. if (this.lockScroll) this._unlockScroll();
  100. }
  101. };
  102. </script>
  103. <style scoped>
  104. .fm-overlay {
  105. position: fixed;
  106. left: 0;
  107. right: 0;
  108. top: 0;
  109. bottom: 0;
  110. background: rgba(0, 0, 0, 0.35);
  111. z-index: 999;
  112. }
  113. .fm-wrap {
  114. position: fixed;
  115. left: 0;
  116. right: 0;
  117. top: 0;
  118. bottom: 0;
  119. display: flex;
  120. align-items: center;
  121. justify-content: center;
  122. z-index: 1000;
  123. padding: 40rpx;
  124. box-sizing: border-box;
  125. }
  126. .fm-card {
  127. background: #fff;
  128. border-radius: 24rpx;
  129. padding: 40rpx;
  130. box-sizing: border-box;
  131. text-align: center;
  132. box-shadow: 0 6rpx 30rpx rgba(0, 0, 0, 0.12);
  133. }
  134. .fm-title {
  135. display: block;
  136. font-size: 48rpx;
  137. font-weight: 700;
  138. color: #333333;
  139. margin-bottom: 40rpx;
  140. }
  141. .fm-icon-wrap {
  142. width: 200rpx;
  143. height: 200rpx;
  144. margin: 0 auto 40rpx;
  145. display: flex;
  146. align-items: center;
  147. justify-content: center;
  148. }
  149. .fm-icon-img {
  150. width: 100%;
  151. height: 100%;
  152. }
  153. .fm-sub {
  154. display: block;
  155. color: #666666;
  156. font-size: 32rpx;
  157. margin-bottom: 40rpx;
  158. font-weight: 500;
  159. }
  160. .fm-btn-wrap {
  161. display: flex;
  162. justify-content: center;
  163. }
  164. .fm-btn {
  165. width: 220rpx;
  166. height: 60rpx;
  167. border-radius: 32rpx;
  168. background: #000;
  169. color: #ffffff;
  170. font-weight: 700;
  171. font-size: 32rpx;
  172. font-style: normal;
  173. border: none;
  174. display: flex;
  175. align-items: center;
  176. justify-content: center;
  177. margin-bottom: 20rpx;
  178. }
  179. </style>