shengBoChuChen.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <view class="content p-rel pdt-100" :style="{ paddingTop: statusBarHeight + 'px' }">
  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. var statusBarHeight = uni.getStorageSync('statusBarHeight')
  19. const open = ref(false)
  20. const statusNum = ref(0)
  21. var timer = null
  22. const handleClick = () =>{
  23. if(!open.value){
  24. open.value = true
  25. uni.vibrateLong({
  26. success: function () {
  27. console.log('success');
  28. }
  29. });
  30. uni.vibrateShort({
  31. type: 'heavy',
  32. success: function () {
  33. console.log('success');
  34. }
  35. });
  36. }else{
  37. return
  38. }
  39. if(open.value){
  40. timer = setInterval(() => {
  41. if(statusNum.value < 100){
  42. let num = Math.ceil(Math.random()*3)
  43. statusNum.value += statusNum.value + num > 100 ? 1 : num
  44. }else{
  45. clearInterval(timer)
  46. open.value = false
  47. statusNum.value = 0
  48. timer = null
  49. uni.showToast({
  50. title:'除尘结束'
  51. })
  52. }
  53. }, 30)
  54. }
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. .content{
  59. height: 100vh;
  60. background: linear-gradient(to bottom, #a9d4ff, #cce6ff);
  61. }
  62. </style>