<template>
  <van-popup v-model:show="show" round position="bottom" :style="{ background: 'transparent', boxShadow: 'none' }">
    <div class="currency-mask">
      <div class="currency-select">
        <div
          v-for="item in options"
          :key="item.value"
          class="currency-item"
          @click="select(item)"
        >
          {{ item.label }}
        </div>
        <div class="cancel-btn" @click="close">取消</div>
      </div>
    </div>
  </van-popup>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue'

const props = defineProps<{
  modelValue: boolean
  options: Array<{ label: string; value: string }>
}>()
const emit = defineEmits(['update:modelValue', 'select'])

const show = ref(props.modelValue)
watch(() => props.modelValue, val => (show.value = val))
watch(show, val => emit('update:modelValue', val))

function select(item: { label: string; value: string }) {
  emit('select', item)
  show.value = false
}
function close() {
  show.value = false
}
</script>

<style scoped>
.currency-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1;
}
.currency-select {
  width: 100vw;
  padding: 0 0 22px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}
.currency-item {
  width: 90vw;
  padding: 20px 0;
  text-align: center;
  font-size: 22px;
  background: #eaff00;
  color: #111;
  margin-bottom: 16px;
  border-radius: 20px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.cancel-btn {
  width: 90vw;
  padding: 20px 0;
  text-align: center;
  color: #111;
  background: #eaff00;
  border-radius: 20px;
  font-weight: bold;
  font-size: 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
</style>
