pop-up.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="pop_up" v-if="isShow">
  3. <view class="pop_con">
  4. <image src="../static/fangwei/fail_icon.png"></image>
  5. <view class="con">{{ con }}</view>
  6. <view class="close_btn" @click="closePop">我知道了({{ count }}s)</view>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. props: ['con'],
  13. data() {
  14. return {
  15. isShow: true,
  16. count: 5
  17. };
  18. },
  19. mounted() {
  20. this.setTime();
  21. },
  22. beforeDestroy() {
  23. //页面关闭时清除定时器
  24. clearInterval(this.clearTimeSet);
  25. },
  26. methods: {
  27. setTime() {
  28. //设置定时器
  29. this.clearTimeSet = setInterval(() => {
  30. this.count--;
  31. if (this.count == 0) {
  32. this.isShow = false;
  33. }
  34. }, 1000);
  35. },
  36. clearTime() {
  37. //清除定时器
  38. clearInterval(this.clearTimeSet);
  39. },
  40. closePop() {
  41. this.$emit('close');
  42. }
  43. }
  44. };
  45. </script>
  46. <style lang="scss">
  47. .pop_up {
  48. width: 100vw;
  49. height: 100vh;
  50. background-color: rgba(0, 0, 0, 0.7);
  51. position: fixed;
  52. top: 0;
  53. left: 0;
  54. display: flex;
  55. align-items: center;
  56. justify-content: center;
  57. .pop_con {
  58. width: 598rpx;
  59. background: #fff;
  60. border-radius: 24rpx;
  61. padding: 30rpx;
  62. box-sizing: border-box;
  63. display: flex;
  64. align-items: center;
  65. justify-content: center;
  66. flex-direction: column;
  67. image {
  68. width: 80rpx;
  69. height: 80rpx;
  70. }
  71. .con {
  72. padding: 30rpx 0;
  73. font-size: 32rpx;
  74. color: #333;
  75. font-weight: bold;
  76. }
  77. .close_btn {
  78. width: 430rpx;
  79. height: 88rpx;
  80. text-align: center;
  81. line-height: 88rpx;
  82. background: linear-gradient(93deg, #a080ff 0%, #5d6bff 100%);
  83. opacity: 1;
  84. border-radius: 44rpx;
  85. color: #fff;
  86. }
  87. }
  88. }
  89. </style>