foodSelect.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <!-- 食物图标按钮 -->
  3. <view @click="handleOpen" class="food-btn-box"></view>
  4. <uni-popup ref="popupRef" type="bottom">
  5. <view class="game-popup-box">
  6. <view class="game-popup-head">
  7. <view class="game-popup-title"></view>
  8. <view class="jf-btn-box">
  9. <!-- 积分 -->
  10. <view class="ezy-jf-box game-popup-jf">
  11. <icon class="jf-icon"></icon>
  12. <text class="jf-text" >{{credit}}</text>
  13. </view>
  14. <!-- 关闭按钮 -->
  15. <icon class="popup-close-btn" @click="handleClose"></icon>
  16. </view>
  17. </view>
  18. <view class="food-list-box">
  19. <view v-for="item in foodSpeciesList" :key="item.id" @click="handleSelectFood(item)" class="food-item-box">
  20. <image :src="item.imgUrl" class="food-image"/>
  21. <view class="food-item-jf">
  22. <icon class="jf-icon"></icon>
  23. <text class="jf-text" >{{item.id}}</text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </uni-popup>
  29. </template>
  30. <script setup>
  31. import {foodSpeciesList} from './constantConfig';
  32. import {ref} from "vue";
  33. const emits = defineEmits(['weishi'])
  34. const props = defineProps({
  35. shiwuId: {
  36. type: [String,Number]
  37. },
  38. credit: {
  39. type: [String,Number]
  40. }
  41. })
  42. const popupRef = ref(null);
  43. const isCanShow = ref(true);
  44. function handleOpen() {
  45. if (!isCanShow.value) {
  46. return;
  47. }
  48. popupRef.value.open();
  49. }
  50. function handleClose() {
  51. popupRef.value.close();
  52. }
  53. function handleSelectFood(shiwu) {
  54. emits('weishi',shiwu);
  55. }
  56. uni.$on('play-audio', () => {
  57. isCanShow.value = false;
  58. })
  59. uni.$on('play-audio-ended', () => {
  60. isCanShow.value = true;
  61. })
  62. defineExpose({
  63. handleClose
  64. })
  65. </script>
  66. <style>
  67. </style>