uniapp【修复】:首页弹框广告点击跳转

This commit is contained in:
花城
2024-12-17 10:07:49 +08:00
parent c7c32332bc
commit 74b43485c9
2 changed files with 121 additions and 93 deletions

View File

@@ -73,3 +73,15 @@ export enum RouteSwitchTabEnum {
/** 个人中心 */ /** 个人中心 */
member = 'member', member = 'member',
} }
/** 底部导航栏页面路由 */
export enum RouteSwitchNameEnum {
/** 首页 */
home = '/pages/home/home',
/** 商品分类 */
classify = '/pages/classify/classify',
/** 购物车 */
cart = '/pages/cart/cart',
/** 个人中心 */
member = '/pages/member/member',
}

View File

@@ -1,7 +1,8 @@
<template> <template>
<view class="adpop-box" v-if="state.show"> <view class="adpop-box" v-if="state.show">
<view class="img-box"> <view class="img-box">
<image class="img" :src="shopConfigStore.config.indexPopupWindowImageUrl" mode="widthFix"></image> <image class="img" @click="handleJumpPopupUrl" :src="shopConfigStore.config.indexPopupWindowImageUrl"
mode="widthFix"></image>
<view class="btn" @click="hanldeCloseAdpop"> <view class="btn" @click="hanldeCloseAdpop">
<image class="icon" :src="handleStaticResources('/static/images/icon/icon-close.png')"></image> <image class="icon" :src="handleStaticResources('/static/images/icon/icon-close.png')"></image>
</view> </view>
@@ -12,9 +13,8 @@
import { reactive, onMounted } from 'vue'; import { reactive, onMounted } from 'vue';
import type { ShopConfigStoreType } from '@/core/models'; import type { ShopConfigStoreType } from '@/core/models';
import { useShopConfigStore } from '@/core/store'; import { useShopConfigStore } from '@/core/store';
import { ShowPopupWindowEnum } from '@/core/enum'; import { ShowPopupWindowEnum, RouteSwitchNameEnum } from '@/core/enum';
import { handleStaticResources } from '@/core/utils'; import { handleStaticResources, handleRouteNavigateTo } from '@/core/utils';
// 获取项目配置 // 获取项目配置
const shopConfigStore : ShopConfigStoreType = useShopConfigStore(); const shopConfigStore : ShopConfigStoreType = useShopConfigStore();
@@ -33,6 +33,22 @@
state.show = true; state.show = true;
} }
}) })
const handleJumpPopupUrl = () => {
if(!shopConfigStore.config.indexPopupWindowHrefUrl){
return ;
}
if (shopConfigStore.config.indexPopupWindowHrefUrl === RouteSwitchNameEnum.home ||
shopConfigStore.config.indexPopupWindowHrefUrl === RouteSwitchNameEnum.classify ||
shopConfigStore.config.indexPopupWindowHrefUrl === RouteSwitchNameEnum.cart ||
shopConfigStore.config.indexPopupWindowHrefUrl === RouteSwitchNameEnum.member) {
uni.switchTab({ url: shopConfigStore.config.indexPopupWindowHrefUrl });
return;
}
handleRouteNavigateTo(shopConfigStore.config.indexPopupWindowHrefUrl)
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import './home-adpop.scss'; @import './home-adpop.scss';