CurrencySelect.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <van-popup v-model:show="show" round position="bottom" :style="{ background: 'transparent', boxShadow: 'none' }">
  3. <div class="currency-mask">
  4. <div class="currency-select">
  5. <div
  6. v-for="item in options"
  7. :key="item.value"
  8. class="currency-item"
  9. @click="select(item)"
  10. >
  11. {{ item.label }}
  12. </div>
  13. <div class="cancel-btn" @click="close">取消</div>
  14. </div>
  15. </div>
  16. </van-popup>
  17. </template>
  18. <script setup lang="ts">
  19. import { ref, watch } from 'vue'
  20. const props = defineProps<{
  21. modelValue: boolean
  22. options: Array<{ label: string; value: string }>
  23. }>()
  24. const emit = defineEmits(['update:modelValue', 'select'])
  25. const show = ref(props.modelValue)
  26. watch(() => props.modelValue, val => (show.value = val))
  27. watch(show, val => emit('update:modelValue', val))
  28. function select(item: { label: string; value: string }) {
  29. emit('select', item)
  30. show.value = false
  31. }
  32. function close() {
  33. show.value = false
  34. }
  35. </script>
  36. <style scoped>
  37. .currency-mask {
  38. position: fixed;
  39. inset: 0;
  40. background: rgba(0, 0, 0, 0.45);
  41. display: flex;
  42. align-items: flex-end;
  43. justify-content: center;
  44. z-index: 1;
  45. }
  46. .currency-select {
  47. width: 100vw;
  48. padding: 0 0 22px 0;
  49. display: flex;
  50. flex-direction: column;
  51. align-items: center;
  52. z-index: 2;
  53. }
  54. .currency-item {
  55. width: 90vw;
  56. padding: 20px 0;
  57. text-align: center;
  58. font-size: 22px;
  59. background: #eaff00;
  60. color: #111;
  61. margin-bottom: 16px;
  62. border-radius: 20px;
  63. font-weight: 500;
  64. box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  65. }
  66. .cancel-btn {
  67. width: 90vw;
  68. padding: 20px 0;
  69. text-align: center;
  70. color: #111;
  71. background: #eaff00;
  72. border-radius: 20px;
  73. font-weight: bold;
  74. font-size: 22px;
  75. box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  76. }
  77. </style>