time-hint.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="modal" v-if="visible">
  3. <view class="modal-content">
  4. <image :src="config.ossPathPerfixs + '/pop-up-bg.png'" mode="aspectFill" class="modal-content-bg"></image>
  5. <view class="modal-content-box">
  6. <view class="modal-content-box-title">
  7. <text class="modal-content-box-title-text">{{ title }}</text>
  8. </view>
  9. <view class="modal-content-box-section" v-html="innerHtml" v-if="innerHtml"></view>
  10. <fs-empty padding="100rpx 0" imageWidth="200rpx" v-else></fs-empty>
  11. <view class="modal-content-box-footer-btn">
  12. <fs-button round type="primary" @click="handleSubmit" :disabled="isDisabled">
  13. <text>我已知晓</text>
  14. <text v-if="timerNum > 0">({{ timerNum }}s)</text>
  15. </fs-button>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script setup>
  22. // import timeHint from '@/business/time-hint'
  23. // <time-hint v-if="isShowtimeHint" :text="info.importantInfo" @change="handleReserve"></time-hint>
  24. import config from '@/utils/config'
  25. const props = defineProps({
  26. time: {
  27. type: Number,
  28. default: 5
  29. },
  30. title: {
  31. type: String,
  32. default: '温馨提示'
  33. },
  34. text: {
  35. type: String,
  36. default: ''
  37. }
  38. })
  39. const emits = defineEmits(['change'])
  40. const visible = ref(false)
  41. const timer = ref(null)
  42. const timerNum = ref(0)
  43. const isDisabled = computed(() => timerNum.value > 0)
  44. const innerHtml = ref('')
  45. onMounted(() => {
  46. innerHtml.value = props.text
  47. visible.value = true
  48. timerNum.value = props.time
  49. timer.value = setInterval(() => {
  50. if (timerNum.value <= 0) return clearInterval(timer.value)
  51. timerNum.value -= 1
  52. }, 1000)
  53. })
  54. const handleSubmit = () => {
  55. if (isDisabled.value) return uni.showToast({ title: `${timerNum.value}s后可关闭`, icon: 'none' })
  56. closeModal()
  57. }
  58. const closeModal = () => {
  59. visible.value = false
  60. emits('change', false)
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. .modal {
  65. position: fixed;
  66. top: 0;
  67. left: 0;
  68. right: 0;
  69. bottom: 0;
  70. background-color: rgba(0, 0, 0, 0.5);
  71. z-index: 999;
  72. display: flex;
  73. justify-content: center;
  74. align-items: center;
  75. .modal-content {
  76. width: 100vw;
  77. padding: 50rpx 70rpx 70rpx 70rpx;
  78. border-radius: 50rpx;
  79. position: relative;
  80. .modal-content-bg {
  81. position: absolute;
  82. width: 100vw;
  83. height: 600rpx;
  84. top: 0;
  85. left: 0;
  86. z-index: 0;
  87. }
  88. .modal-content-box {
  89. position: relative;
  90. z-index: 1;
  91. .modal-content-box-title {
  92. font-size: 36rpx;
  93. padding-bottom: 20rpx;
  94. font-weight: 700;
  95. text-align: center;
  96. color: #333;
  97. position: relative;
  98. &-text {
  99. position: relative;
  100. z-index: 1;
  101. }
  102. &::after {
  103. content: '';
  104. position: absolute;
  105. z-index: 0;
  106. bottom: 20rpx;
  107. left: 50%;
  108. transform: translateX(-50%);
  109. width: 160rpx;
  110. height: 16rpx;
  111. border-radius: 8rpx;
  112. background-image: linear-gradient(90deg, #0871FF 0%, #00EEA8 100%);
  113. }
  114. }
  115. .modal-content-box-section {
  116. height: 340rpx;
  117. overflow-y: auto;
  118. word-wrap: break-word;
  119. }
  120. .modal-content-box-footer-btn {
  121. padding-top: 20rpx;
  122. text-align: center;
  123. }
  124. }
  125. }
  126. }
  127. </style>