| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <script setup lang="ts">
- import { useSelectListPopup } from '~/composables/useSelectListPopup'
- import OrderCheckSvg from '~/assets/icons/order/check.svg'
- const { state, close, select } = useSelectListPopup()
- const handleUpdateShow = (value: boolean) => {
- if (!value) {
- close()
- }
- }
- </script>
- <template>
- <van-popup
- :show="state.visible"
- round
- position="bottom"
- class="select-list-popup"
- @update:show="handleUpdateShow"
- >
- <div class="select-list-popup__container">
- <!-- 可选标题 -->
- <h3
- v-if="state.title"
- class="select-list-popup__title"
- >
- {{ state.title }}
- </h3>
- <section class="select-list-popup__card">
- <button
- v-for="item in state.options"
- :key="item.value"
- type="button"
- class="select-list-popup__item"
- @click="select(item)"
- >
- <span class="select-list-popup__item-label">
- <img
- v-if="item.icon"
- :src="item.icon"
- :alt="item.label"
- loading="lazy"
- >
- {{ item.label }}
- </span>
- <OrderCheckSvg
- v-if="state.selectedValue === item.value"
- />
- <span
- v-else
- class="select-list-popup__indicator"
- />
- </button>
- </section>
- </div>
- </van-popup>
- </template>
- <style scoped lang="scss">
- .select-list-popup {
- background-color: transparent;
- &__container {
- position: relative;
- border-radius: 15px 15px 0 0;
- padding: 18px 16px;
- background: #FFF;
- overflow: hidden;
- }
- &__title {
- margin: 0 0 8px;
- text-align: center;
- font-family: var(--font-title);
- font-size: 14px;
- font-weight: 600;
- color: var(--color-text-primary);
- }
- &__card {
- border-radius: 12px;
- background-color: #fff;
- padding: 4px 0;
- max-height: 260px;
- overflow-y: auto;
- }
- &__item {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- background-color: transparent;
- border: none;
- cursor: pointer;
- -webkit-tap-highlight-color: transparent;
- & {
- padding: 12px 0;
- }
- &:first-child {
- padding-top: 0;
- }
- &:last-child {
- padding-bottom: 0;
- }
- &:not(:last-child) {
- border-bottom: 1px solid #f2f3f5;
- }
- }
- &__item-label {
- font-size: 14px;
- font-weight: 600;
- color: var(--color-text-primary);
- display: flex;
- align-items: center;
- gap: 8px;
- img {
- @include size(24px);
- }
- }
- &__indicator {
- @include size(22px);
- border-radius: 999px;
- border: 2px solid #dadce6;
- box-sizing: border-box;
- }
- }
- </style>
- <style lang="scss">
- .van-popup.select-list-popup {
- overflow-y: unset;
- }
- </style>
|