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

@@ -1,75 +1,87 @@
export enum WidgetCodeEnum {
/** 图片 */
imgSingle = 'imgSingle',
/** 服务商品 */
service = 'service',
/** 图片轮播 */
imgSlide = 'imgSlide',
/** 公告 */
notice = 'notice',
/** 优惠券 */
coupon = 'coupon',
/** 拼团 */
pinTuan = 'pinTuan',
/** 搜索 */
search = 'search',
/** 宫格自定义导航 */
navBar = 'navBar',
/** 商品选项卡 */
goodTabBar = 'goodTabBar',
/** 文章 */
article = 'article',
/** 文章分类 */
articleClassify = 'articleClassify',
/** 视频 */
video = 'video',
/** 商品 */
goods = 'goods',
/** 浏览记录 */
record = 'record',
/** 空格 */
blank = 'blank',
/** 多行文本输入区 */
textarea = 'textarea',
/** 图片集 */
imgWindow = 'imgWindow',
/** 文本内容 */
content = 'content',
/** 团购 */
groupPurchase = 'groupPurchase',
/** 秒杀 */
seckill = 'seckill',
/** 弹窗广告 */
adpop = 'adpop',
/** 图片 */
imgSingle = 'imgSingle',
/** 服务商品 */
service = 'service',
/** 图片轮播 */
imgSlide = 'imgSlide',
/** 公告 */
notice = 'notice',
/** 优惠券 */
coupon = 'coupon',
/** 拼团 */
pinTuan = 'pinTuan',
/** 搜索 */
search = 'search',
/** 宫格自定义导航 */
navBar = 'navBar',
/** 商品选项卡 */
goodTabBar = 'goodTabBar',
/** 文章 */
article = 'article',
/** 文章分类 */
articleClassify = 'articleClassify',
/** 视频 */
video = 'video',
/** 商品 */
goods = 'goods',
/** 浏览记录 */
record = 'record',
/** 空格 */
blank = 'blank',
/** 多行文本输入区 */
textarea = 'textarea',
/** 图片集 */
imgWindow = 'imgWindow',
/** 文本内容 */
content = 'content',
/** 团购 */
groupPurchase = 'groupPurchase',
/** 秒杀 */
seckill = 'seckill',
/** 弹窗广告 */
adpop = 'adpop',
}
/** nav页面导航类型 */
export enum NavLinkEnum {
/** URL链接 */
urlLink = 1,
/** 商品 */
shop = 2,
/** 文章 */
article = 3,
/** 文章分类 */
articleCategory = 4,
/** 智能表单 */
intelligentForms = 5,
/** 商品分类 */
shopCategory = 6,
/** 跳转小程序 */
wxMiNiProgram = 7,
/** URL链接 */
urlLink = 1,
/** 商品 */
shop = 2,
/** 文章 */
article = 3,
/** 文章分类 */
articleCategory = 4,
/** 智能表单 */
intelligentForms = 5,
/** 商品分类 */
shopCategory = 6,
/** 跳转小程序 */
wxMiNiProgram = 7,
};
/** 底部导航栏 */
export enum RouteSwitchTabEnum {
/** 首页 */
home = 'home',
/** 商品分类 */
classify = 'classify',
/** 购物车 */
cart = 'cart',
/** 个人中心 */
member = 'member',
/** 首页 */
home = 'home',
/** 商品分类 */
classify = 'classify',
/** 购物车 */
cart = 'cart',
/** 个人中心 */
member = 'member',
}
/** 底部导航栏页面路由 */
export enum RouteSwitchNameEnum {
/** 首页 */
home = '/pages/home/home',
/** 商品分类 */
classify = '/pages/classify/classify',
/** 购物车 */
cart = '/pages/cart/cart',
/** 个人中心 */
member = '/pages/member/member',
}

View File

@@ -1,39 +1,55 @@
<template>
<view class="adpop-box" v-if="state.show">
<view class="img-box">
<image class="img" :src="shopConfigStore.config.indexPopupWindowImageUrl" mode="widthFix"></image>
<view class="btn" @click="hanldeCloseAdpop">
<image class="icon" :src="handleStaticResources('/static/images/icon/icon-close.png')"></image>
</view>
</view>
</view>
<view class="adpop-box" v-if="state.show">
<view class="img-box">
<image class="img" @click="handleJumpPopupUrl" :src="shopConfigStore.config.indexPopupWindowImageUrl"
mode="widthFix"></image>
<view class="btn" @click="hanldeCloseAdpop">
<image class="icon" :src="handleStaticResources('/static/images/icon/icon-close.png')"></image>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { reactive, onMounted } from 'vue';
import type { ShopConfigStoreType } from '@/core/models';
import { useShopConfigStore } from '@/core/store';
import { ShowPopupWindowEnum } from '@/core/enum';
import { handleStaticResources } from '@/core/utils';
import { reactive, onMounted } from 'vue';
import type { ShopConfigStoreType } from '@/core/models';
import { useShopConfigStore } from '@/core/store';
import { ShowPopupWindowEnum, RouteSwitchNameEnum } from '@/core/enum';
import { handleStaticResources, handleRouteNavigateTo } from '@/core/utils';
// 获取项目配置
const shopConfigStore : ShopConfigStoreType = useShopConfigStore();
// 获取项目配置
const shopConfigStore : ShopConfigStoreType = useShopConfigStore();
const state = reactive<{
show : boolean,
}>({
show: false,
})
const state = reactive<{
show : boolean,
}>({
show: false,
})
const hanldeCloseAdpop = () => {
state.show = !state.show;
}
const hanldeCloseAdpop = () => {
state.show = !state.show;
}
onMounted(() => {
if (shopConfigStore.config.showIndexPopupWindow === ShowPopupWindowEnum.yes) {
state.show = true;
}
})
onMounted(() => {
if (shopConfigStore.config.showIndexPopupWindow === ShowPopupWindowEnum.yes) {
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>
<style lang="scss" scoped>
@import './home-adpop.scss';
@import './home-adpop.scss';
</style>