pop-up.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="pop_up" v-if="isShow">
  3. <view class="pop_con">
  4. <image src="../static/fail.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. this.$emit('close');
  34. }
  35. }, 1000);
  36. },
  37. clearTime() {
  38. //清除定时器
  39. clearInterval(this.clearTimeSet);
  40. },
  41. closePop() {
  42. this.$emit('close');
  43. }
  44. }
  45. };
  46. </script>
  47. <style lang="scss">
  48. .pop_up {
  49. width: 100vw;
  50. height: 100vh;
  51. background-color: rgba(0, 0, 0, 0.7);
  52. position: fixed;
  53. top: 0;
  54. left: 0;
  55. display: flex;
  56. align-items: center;
  57. justify-content: center;
  58. .pop_con {
  59. width: 598rpx;
  60. background: #fff;
  61. border-radius: 24rpx;
  62. padding: 30rpx;
  63. box-sizing: border-box;
  64. display: flex;
  65. align-items: center;
  66. justify-content: center;
  67. flex-direction: column;
  68. image {
  69. width: 80rpx;
  70. height: 80rpx;
  71. }
  72. .con {
  73. padding: 30rpx 0;
  74. font-size: 32rpx;
  75. color: #333;
  76. font-weight: bold;
  77. }
  78. .close_btn {
  79. width: 430rpx;
  80. height: 88rpx;
  81. text-align: center;
  82. line-height: 88rpx;
  83. background: linear-gradient(93deg, #a080ff 0%, #5d6bff 100%);
  84. opacity: 1;
  85. border-radius: 44rpx;
  86. color: #fff;
  87. }
  88. }
  89. }
  90. </style>