From 02552acb6962a634408547cf6e0634dc2f90f479 Mon Sep 17 00:00:00 2001 From: ch Date: Tue, 31 May 2022 17:38:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E5=B9=BF=E5=91=8A?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E6=96=B9=E5=BC=8F=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/dicts/ad.js | 18 +++++++++-- src/common/utils/utils.js | 49 ++++++++++++++++++------------ src/pages/goods/category.vue | 12 +++++--- src/pages/index/index.vue | 10 ++---- src/pages/index/modules/Banner.vue | 6 ++-- 5 files changed, 57 insertions(+), 38 deletions(-) diff --git a/src/common/dicts/ad.js b/src/common/dicts/ad.js index 59ad599..afc3762 100644 --- a/src/common/dicts/ad.js +++ b/src/common/dicts/ad.js @@ -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 } \ No newline at end of file diff --git a/src/common/utils/utils.js b/src/common/utils/utils.js index 29a39e9..10a3bd4 100644 --- a/src/common/utils/utils.js +++ b/src/common/utils/utils.js @@ -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 { diff --git a/src/pages/goods/category.vue b/src/pages/goods/category.vue index bbaa5e5..e83af54 100644 --- a/src/pages/goods/category.vue +++ b/src/pages/goods/category.vue @@ -18,7 +18,7 @@ + @click="handleAdJump(curTwoCategory)"> @@ -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 + }); } }, }; diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 0d57ee0..1052a06 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -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 -->