goose.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <view>
  3. <up-line-progress v-if="growthType!==3" :percentage="progress" :showText="false" activeColor="#54e1fe"
  4. class="game-progress-box"></up-line-progress>
  5. <text v-if="growthType!==3" class="game-progress-text">成长值:{{progress}}%</text>
  6. <image :src="imgUrl" class="goose-img-box" @click="handleTouch"></image>
  7. </view>
  8. </template>
  9. <script setup>
  10. import {
  11. ref,
  12. computed,
  13. watch,
  14. toRefs
  15. } from "vue";
  16. import upLineProgress from "uview-plus/components/u-line-progress/u-line-progress.vue";
  17. import {
  18. useAudio,
  19. useHuDong
  20. } from "./useAudio.js"
  21. const props = defineProps({
  22. growthType: {
  23. type: [String, Number]
  24. },
  25. progress: {
  26. type: [String, Number],
  27. default: 0
  28. }
  29. })
  30. const {growthType} = toRefs(props);
  31. const Emits = defineEmits(['onPlay','onEnd'])
  32. const {
  33. init,
  34. doTouch,
  35. imgUrl
  36. } = useHuDong(props);
  37. const {
  38. innerAudioContext,
  39. handlePlay
  40. } = useAudio(growthType);
  41. init();
  42. watch(growthType, () => {
  43. init();
  44. })
  45. function handleTouch() {
  46. if (!innerAudioContext.value.paused) {
  47. return;
  48. }
  49. doTouch(handlePlay);
  50. }
  51. </script>
  52. <style>
  53. </style>