fix:调整广告跳转方式判断

feature/ad-0531-ch
ch 2 years ago
parent d6516bbfcf
commit 02552acb69

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-05-31 11:05:08
* @LastEditors: ch
* @LastEditTime: 2022-05-31 11:15:27
* @LastEditTime: 2022-05-31 17:23:02
* @Description: file content
*/
@ -19,10 +19,24 @@ const AD_LOCATION = {
// 分类banner
CATEGORY_BANNER : 3
}
const AD_JUMP_TYPE = {
// 商品详情
GOODS: 1,
// 分类
CATEGORY: 2,
// 链接
LINK: 3,
// 不跳转
NO_JUMP : 4
}
export {
// 广告所属平台
AD_PLATFORM,
// 广告位置
AD_LOCATION
AD_LOCATION,
// 广告跳转类型
AD_JUMP_TYPE
}

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-17 19:15:10
* @LastEditors: ch
* @LastEditTime: 2022-05-31 15:17:45
* @LastEditTime: 2022-05-31 17:36:08
* @Description: 一些无法归类的公共方法容器
*/
@ -15,6 +15,7 @@ import {
} from "js-util-all";
import ENV from '@/common/config/env';
import {AD_JUMP_TYPE} from '@/common/dicts/ad';
/**
* 首次运行时把定时器赋值给一个变量 第二次执行时
@ -40,26 +41,34 @@ const Debounce = (fn, delay) => {
* 兼容APP根据域名判断站内跳转还是站外跳转
* @param {*} link
*/
const AdJump = (link) => {
if (!/^(http|https):\/\/./.test(link)) {
uni.$u.toast('非法链接,暂不跳转!');
return false;
const AdJump = (item) => {
// if (!/^(http|https):\/\/./.test(link)) {
// uni.$u.toast('非法链接,暂不跳转!');
// return false;
// }
console.log(item);
switch (item.jumpType) {
case AD_JUMP_TYPE.GOODS:
uni.navigateTo({
url: `/goodsDetail?id=${item.jumpUrl}`
});
break;
case AD_JUMP_TYPE.CATEGORY:
uni.navigateTo({
url: `/goodsList?categoryId=${item.jumpUrl}`
});
break;
case AD_JUMP_TYPE.LINK:
// #ifdef H5
window.location.href = item.jumpUrl;
// #endif
// #ifdef APP-PLUS
plus.runtime.openURL(item.jumpUrl);
// #endif
break;
default:
break
}
console.log(link);
const isInner = link.includes(ENV.staticUrl);
if (isInner) {
uni.navigateTo({
url : link.replace(ENV.staticUrl,'')
})
} else {
// #ifdef H5
window.location.href = link;
// #endif
// #ifdef APP-PLUS
plus.runtime.openURL(link);
// #endif
}
}
// 工具类的文件需要把文件提供的工具类统一放最下方做一个统一输出
export {

@ -18,7 +18,7 @@
<!-- 右侧 二级分类 -->
<scroll-view class="cate-right" @scrolltolower="reachBottom" :scroll-top="scrollTop" :scroll-y="true">
<image class="cate-tow-img" v-if="curTwoCategory.adPictureUrl" :src="curTwoCategory.adPictureUrl"
@click="handleAdJump(curTwoCategory.adJumpUrl)"></image>
@click="handleAdJump(curTwoCategory)"></image>
<!-- <view @click="onTargetGoodsList(item.id)"> -->
<view class="cate-tow-group" :class="idx === curTwoCategory.children.length - 1 ? 'cate-tow-group__last' :''"
v-for="(item, idx) in curTwoCategory.children" :key="idx">
@ -126,12 +126,14 @@ export default {
if(result.length){
this.$set(item, 'adPictureUrl', result[0].pictureUrl);
this.$set(item, 'adJumpUrl', result[0].jumpUrl);
this.$set(item, 'adJumpType', result[0].jumpType);
}
},
handleAdJump(link){
if(link){
AdJump(link);
}
handleAdJump(item){
AdJump({
jumpUrl: item.jumpUrl,
jumpType:item.jumpType
});
}
},
};

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2019-08-22 19:41:20
* @LastEditors: ch
* @LastEditTime: 2022-05-31 14:56:04
* @LastEditTime: 2022-05-31 17:35:15
* @Description: file content
-->
<template>
@ -24,7 +24,7 @@
<view class="category">
<view class="category--item" v-for="item in categoryList" :key="item.id"
@click="handleCategory(item)">
@click="AdJump(item)">
<view class="category--image-box">
<image class="category--image" :src="item.pictureUrl"></image>
</view>
@ -117,11 +117,7 @@ export default {
this.seckillData = result
}
},
handleCategory(item){
if(item.jumpUrl){
AdJump(item.jumpUrl);
}
}
AdJump
}
}
</script>

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-23 10:31:12
* @LastEditors: ch
* @LastEditTime: 2022-05-31 14:54:22
* @LastEditTime: 2022-05-31 17:19:26
* @Description: file content
-->
<template>
@ -46,9 +46,7 @@ export default {
methods:{
goDetail(idx){
let item = this.data[idx];
if(item.jumpUrl){
AdJump(item.jumpUrl);
}
AdJump(item);
}
}
}

Loading…
Cancel
Save