shengBoChuChen.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. <image v-if="!open" style="width: 130rpx;height: 130rpx;margin-top: 40rpx;" src="/static/image/source/ql_icon.png"></image>
  5. <ourLoading v-else active translateY="50" background-color="transparent" color="#ea9f8a" />
  6. </view>
  7. <view class="p-rel flex ai_center fd_c">
  8. <template v-if="open">
  9. <view class="text-62 mgt-10">{{ statusNum }}%</view>
  10. <view class="text-36 text-500 mgy-30">正在声波初尘中...</view>
  11. <view class="text-24 text-555 mgb-80">手机音量调到最大,可以获得最后的除尘效果</view>
  12. </template>
  13. <view class="h-100" v-else>
  14. <view v-if="!firstClick" class="mgt-10 text-48">除尘结束</view>
  15. </view>
  16. <view class="btn_s w-300" @click="handleClick">{{ open? '结束除尘':'开始除尘' }}</view>
  17. </view>
  18. </view>
  19. </template>
  20. <script setup>
  21. import { ref, onMounted } from "vue";
  22. import { onShow } from "@dcloudio/uni-app";
  23. import ourLoading from '@/components/our-loading/our-loading.vue'
  24. var statusBarHeight = uni.getStorageSync('statusBarHeight')
  25. const open = ref(false)
  26. const statusNum = ref(0)
  27. const firstClick = ref(true)
  28. var timer = null
  29. const handleClick = () =>{
  30. if(!open.value){
  31. open.value = true
  32. firstClick.value = false
  33. // uni.vibrateLong({
  34. // success: function () {
  35. // console.log('success');
  36. // }
  37. // });
  38. uni.vibrateShort({
  39. type: 'heavy',
  40. success: function () {
  41. console.log('success');
  42. }
  43. });
  44. }else{
  45. return
  46. }
  47. if(open.value){
  48. timer = setInterval(() => {
  49. if(statusNum.value < 100){
  50. let num = Math.ceil(Math.random()*3)
  51. statusNum.value += statusNum.value + num > 100 ? 1 : num
  52. }else{
  53. clearInterval(timer)
  54. open.value = false
  55. statusNum.value = 0
  56. timer = null
  57. uni.showToast({
  58. title:'除尘结束'
  59. })
  60. }
  61. }, 100)
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .content{
  67. height: 100vh;
  68. background: linear-gradient(to bottom, #b4daff, #cce6ff);
  69. }
  70. </style>