goose.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. <text v-if="growthType!==3" class="game-progress-text">{{growth}}/{{growthTotal}}</text>
  7. <image :src="imgUrl" class="goose-img-box" @click="handleTouch"></image>
  8. </view>
  9. </template>
  10. <script setup>
  11. import {
  12. ref,
  13. computed,
  14. watch,
  15. toRefs
  16. } from "vue";
  17. import upLineProgress from "uview-plus/components/u-line-progress/u-line-progress.vue";
  18. import {
  19. useAudio,
  20. useHuDong
  21. } from "./useAudio.js"
  22. const props = defineProps({
  23. growthType: {
  24. type: [String, Number]
  25. },
  26. progress: {
  27. type: [String, Number],
  28. default: 0
  29. },
  30. growth: {
  31. type: [String, Number],
  32. default: 0
  33. },
  34. growthTotal: {
  35. type: [String, Number],
  36. default: 0
  37. }
  38. })
  39. const {growthType} = toRefs(props);
  40. const Emits = defineEmits(['onPlay','onEnd'])
  41. const {
  42. init,
  43. doTouch,
  44. imgUrl
  45. } = useHuDong(props);
  46. const {
  47. innerAudioContext,
  48. handlePlay
  49. } = useAudio(growthType);
  50. init();
  51. watch(growthType, () => {
  52. init();
  53. })
  54. function handleTouch() {
  55. if (!innerAudioContext.value.paused) {
  56. return;
  57. }
  58. doTouch(handlePlay);
  59. }
  60. </script>
  61. <style>
  62. </style>