123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <template>
- <div class="round-comp">
- <template v-if="list.length">
- <div class="round" :class="`round--${length}`">
- <div class="round--center">
- <div v-for="(img, i) in list" :key="i" class="header">
- <van-image width="100%" height="100%" fit="cover" :src="img" />
- </div>
- </div>
- </div>
- </template>
- </div>
- </template>
- <script setup>
- const props = defineProps({
- size: {
- type: Number,
- default: 48
- },
- imgUrls: Array
- })
- const length = ref(0)
- const list = ref([])
- const initStyle = () => {
- const root = document.documentElement
- const size = props.size
- root.style.setProperty('--round-size', size + 'px')
- root.style.setProperty('--round-size-header', (size * 22) / 44 + 'px')
- root.style.setProperty('--round-size-sm-header', (size * 15) / 44 + 'px')
- }
- const initData = () => {
- list.value = (props.imgUrls ?? []).slice(0, 9)
- length.value = list.value.length
- }
- onMounted(() => {
- initStyle()
- initData()
- })
- </script>
- <style scoped lang="scss">
- .round-comp {
- width: var(--round-size);
- height: var(--round-size);
- background: #f7f8fa;
- border-radius: 100%;
- }
- .round {
- margin: 0px auto;
- width: var(--round-size);
- height: var(--round-size);
- background: #f7f8fa;
- border-radius: 100%;
- overflow: clip;
- position: relative;
- .round--center {
- height: 100%;
- position: absolute;
- display: grid;
- gap: 1px;
- align-items: center;
- justify-items: center;
- align-content: center;
- justify-content: center;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- .header {
- text-align: center;
- font-size: 12px;
- }
- }
- }
- .round--1 {
- .round--center {
- .header {
- width: var(--round-size);
- height: var(--round-size);
- }
- }
- }
- .round--2 {
- .round--center {
- grid-template-columns: auto auto;
- grid-template-rows: auto;
- .header {
- width: var(--round-size-header);
- height: var(--round-size-header);
- }
- }
- }
- .round--3 {
- .round--center {
- grid-template-columns: auto auto;
- grid-template-rows: auto auto;
- }
- .header {
- width: var(--round-size-header);
- height: var(--round-size-header);
- &:nth-child(1) {
- grid-column: 1 / span 2;
- }
- }
- }
- .round--4 {
- .round--center {
- grid-template-columns: auto auto;
- grid-template-rows: auto auto;
- .header {
- width: var(--round-size-header);
- height: var(--round-size-header);
- }
- }
- }
- .round--5 {
- .round--center {
- grid-template-columns: auto auto auto auto auto auto;
- grid-template-rows: auto auto;
- .header {
- width: var(--round-size-sm-header);
- height: var(--round-size-sm-header);
- grid-column: span 2;
- &:nth-child(1) {
- grid-column: 2 / span 2;
- }
- &:nth-child(2) {
- grid-column: 4 / span 2;
- }
- }
- }
- }
- .round--6 {
- .round--center {
- grid-template-columns: auto auto auto;
- grid-template-rows: auto auto;
- .header {
- width: var(--round-size-sm-header);
- height: var(--round-size-sm-header);
- }
- }
- }
- .round--7 {
- .round--center {
- grid-template-columns: auto auto auto;
- grid-template-rows: auto auto;
- .header {
- width: var(--round-size-sm-header);
- height: var(--round-size-sm-header);
- &:nth-child(1) {
- grid-column: 1 / span 3;
- }
- }
- }
- }
- .round--8 {
- .round--center {
- grid-template-columns: auto auto auto auto auto auto;
- grid-template-rows: auto auto;
- .header {
- width: var(--round-size-sm-header);
- height: var(--round-size-sm-header);
- grid-column: span 2;
- &:nth-child(1) {
- grid-column: 2 / span 2;
- }
- &:nth-child(2) {
- grid-column: 4 / span 2;
- }
- }
- }
- }
- .round--9 {
- .round--center {
- grid-template-columns: auto auto auto;
- grid-template-rows: auto auto;
- .header {
- width: var(--round-size-sm-header);
- height: var(--round-size-sm-header);
- }
- }
- }
- </style>
|