advertPopup.vue 1.64 KB
<template>
  <view class="ad-modal">
    <u-popup
      :show="show"
      mode="center"
      @close="close"
      bgColor="transparent"
      :safeAreaInsetBottom="false"
    >
      <view class="ad-container">
        <view class="swiper-wrapper">
          <u-swiper
            :list="list"
            keyName="image"
            height="700rpx"
            :autoplay="false"
            circular
            @click="handleAdClick"
            radius="16rpx"
            indicator
            bgColor="transparent"
            indicatorMode="dot"
          ></u-swiper>
        </view>

        <view class="close-section" @click="close">
          <u-icon name="close-circle" color="#ffffff" size="34"></u-icon>
        </view>
      </view>
    </u-popup>
  </view>
</template>

<script setup>
  const props = defineProps({
    show: {
      type: Boolean,
      default: false,
    },
    list: {
      type: Array,
      default: () => [],
    },
  });

  const emit = defineEmits(['updateShow', 'clickAd', 'close']);

  // 关闭弹窗
  const close = () => {
    emit('close', false);
  };

  // 点击广告图触发
  const handleAdClick = (index) => {
    emit('clickAd', props.list[index]);
  };
</script>

<style lang="scss" scoped>
  .ad-container {
    width: 580rpx; // 弹窗宽度
    display: flex;
    flex-direction: column;
    align-items: center;

    .swiper-wrapper {
      width: 100%;
      overflow: hidden;
    }

    .close-section {
      margin-top: 40rpx;
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;

      /* 增加点击区域面积 */
      padding: 20rpx;
    }
  }
</style>