shengBoChuChen.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <view class="content p-rel pdt-100">
  3. <view class="p-rel h-200 flex ai_center fd_c">
  4. <ourLoading active translateY="50" background-color="transparent" color="#ea9f8a" />
  5. </view>
  6. <view class="p-rel flex ai_center fd_c">
  7. <view class="text-62 mgt-10">{{ statusNum }}%</view>
  8. <view class="text-36 text-500 mgy-30">正在声波初尘中...</view>
  9. <view class="text-24 text-555 mgb-80">手机音量调到最大,可以获得最后的除尘效果</view>
  10. <view class="btn_s w-300" @click="handleClick">{{ open? '结束除尘':'开始除尘' }}</view>
  11. </view>
  12. </view>
  13. </template>
  14. <script setup>
  15. import { ref, onMounted } from "vue";
  16. import { onShow } from "@dcloudio/uni-app";
  17. import ourLoading from '@/components/our-loading/our-loading.vue'
  18. const open = ref(false)
  19. const statusNum = ref(0)
  20. var timer = null
  21. const handleClick = () =>{
  22. if(!open.value){
  23. open.value = true
  24. }else{
  25. return
  26. }
  27. if(open.value){
  28. timer = setInterval(() => {
  29. if(statusNum.value < 100){
  30. let num = Math.ceil(Math.random()*3)
  31. statusNum.value += statusNum.value + num > 100 ? 1 : num
  32. }else{
  33. clearInterval(timer)
  34. open.value = false
  35. statusNum.value = 0
  36. timer = null
  37. uni.showToast({
  38. title:'除尘结束'
  39. })
  40. }
  41. }, 30)
  42. }
  43. }
  44. </script>
  45. <style lang="scss" scoped>
  46. .content{
  47. height: 100vh;
  48. background: linear-gradient(to bottom, #a9d4ff, #cce6ff);
  49. }
  50. </style>