| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <template>
- <!-- 轮播图 -->
- <view class="swiper-item" @click.stop="adRoute">
- <image class="swiper-img" :src="item?.adImg" mode="heightFix" />
- </view>
- </template>
- <script setup lang="ts" name="ad-item">
- // 移除了不必要的ref导入
- interface AdItem {
- adImg: string;
- adType: string;
- adUrl: string;
- }
- interface Props {
- item: AdItem;
- index: number;
- count: number;
- }
- const props = withDefaults(defineProps<Props>(), {
- item: () => ({} as AdItem),
- index: 0,
- count: 1
- });
- const adRoute = () => {
- if (props.item?.adType == '1') {
- uni.$u.route({
- type: 'navigateTo',
- url: props.item?.adUrl,
- params: {
- ad: 1
- }
- });
- }
- if (props.item?.adType == '2') {
- uni.$u.route({
- type: 'navigateTo',
- url: '/pages/tool/webview/index',
- params: {
- url: props.item?.adUrl
- }
- });
- }
- };
- </script>
- <style lang="scss" scoped>
- .swiper-item {
- position: absolute;
- left: 0;
- top: 0;
- right: 0;
- bottom: 0;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- overflow: hidden;
- }
- .swiper-img {
- width: 100%;
- height: 100%;
- }
- </style>
|