From 50af9c1f53d0b1a951dc7aa38f1f4c1703a956e4 Mon Sep 17 00:00:00 2001 From: wwxin <2463926940@qq.com> Date: Tue, 30 Jul 2024 17:16:19 +0800 Subject: [PATCH] =?UTF-8?q?update:=E4=BC=98=E5=8C=96=E6=8E=A8=E5=B9=BF?= =?UTF-8?q?=E4=BD=8D=E9=83=A8=E5=88=86=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/promotion/promotion.vue | 2 ++ src/views/promotion/promotionat.vue | 46 ++++++++--------------------- src/views/promotion/wxpromotion.vue | 15 +--------- 3 files changed, 16 insertions(+), 47 deletions(-) diff --git a/src/views/promotion/promotion.vue b/src/views/promotion/promotion.vue index fe29f01..45a42f5 100644 --- a/src/views/promotion/promotion.vue +++ b/src/views/promotion/promotion.vue @@ -274,6 +274,8 @@ const shouye = () => { } } } + const mobile=getQueryParam("mobile"); + if(mobile.value&&mobile.value.length > 0) { if (isRend) { const keyImages = [ { id: "coverImg", url: coverImgUrl.value }, diff --git a/src/views/promotion/promotionat.vue b/src/views/promotion/promotionat.vue index f3e4a6b..485ec4e 100644 --- a/src/views/promotion/promotionat.vue +++ b/src/views/promotion/promotionat.vue @@ -144,7 +144,7 @@ import { import { isMobile, isIOS, showTel } from "@/utils/tools"; import md5 from "js-md5"; import { showDialog } from "vant"; -import { useRouter } from "vue-router"; +import { useRouter,useRoute } from "vue-router"; const longSpace = "\xa0".repeat(10); let $router = useRouter(); let htmlLoadFinish = ref(false); @@ -177,6 +177,7 @@ let coverImgUrl = ref(""); let coverBtnImgUrl = ref(""); let isTelOrder = ref(false); let showNoticeBar = ref(true); +const route=useRoute() //同意弹窗 const handleAgree = (type) => { @@ -193,26 +194,13 @@ const handleAgree = (type) => { tipsShow.value = false; } }; -const getUrlParam = () => { - let url = document.location.toString(); - let arrObj = url.split("?"); - let params = Object.create(null); - if (arrObj.length > 1) { - arrObj = arrObj[1].split("&"); - arrObj.forEach((item) => { - item = item.split("="); - params[item[0]] = item[1]; - }); - } - return params; -}; //跳转看agree等 const toAgreePages = (types) => { let typesparmes = types === "hdRule" ? 1 : types === "ysRule" ? 2 : 3; $router.push(`/agree?promotionId=${promotionId.value}&type=${typesparmes}`); }; const shouye = () => { - let param = getUrlParam(); + let param=route.query resourceInfo({promotionCode:promotionCode.value,...param}).then((resp) => { if (resp.data.code == "S00000") { const result = resp.data.result; @@ -336,28 +324,19 @@ const submitOrder = () => { // showToast("请先阅读并同意服务条款"); } }; -/* - * changeURLStatic 修改地址栏URL参数 不跳转 - * @param name 参数名 - * @param value 参数值 - * - * */ +//替换地址栏参数 const changeURLStatic = (name, value) => { - let url = location.href; - let url2 = ""; - let reg = eval("/([?|&]" + name + "=)[^&]*/gi"); - value = value.toString().replace(/(^\s*)|(\s*$)/g, ""); //移除首尾空格 - if (!value) { - url2 = url.replace(reg, ""); //正则替换 + let url = new URL(location.href); + let params = url.searchParams; + value = value.toString().trim(); + if (value) { + params.set(name, value); } else { - if (url.match(reg)) { - url2 = url.replace(reg, "$1" + value); //正则替换 - } else { - url2 = url + (url.indexOf("?") > -1 ? "&" : "?") + name + "=" + value; //没有参数添加参数 - } + params.delete(name); } - history.replaceState(null, null, url2); //替换地址栏 + history.replaceState(null, null, url.toString()); }; + const submitData = async () => { let mobiles = mobile.value; @@ -605,6 +584,7 @@ onMounted(() => { margin-bottom: 0.32407rem; width: 6rem; border: none; + margin-top:20px; } .agreement-view { align-items: center; diff --git a/src/views/promotion/wxpromotion.vue b/src/views/promotion/wxpromotion.vue index c1c37e0..8083ae3 100644 --- a/src/views/promotion/wxpromotion.vue +++ b/src/views/promotion/wxpromotion.vue @@ -206,19 +206,6 @@ const phoneBlur = () => { } } }; -const getUrlParam = () => { - let url = document.location.toString(); - let arrObj = url.split("?"); - let params = Object.create(null); - if (arrObj.length > 1) { - arrObj = arrObj[1].split("&"); - arrObj.forEach((item) => { - item = item.split("="); - params[item[0]] = item[1]; - }); - } - return params; -}; //跳转看agree等 const toAgreePages = (types) => { let typesparmes = types === "hdRule" ? 1 : types === "ysRule" ? 2 : 3; @@ -239,7 +226,7 @@ const toAgreePages = (types) => { $router.push(`/agree?promotionId=${promotionId.value}&type=${typesparmes}`); }; const shouye = () => { - let param = getUrlParam(); + let param=route.query resourceInfo({promotionCode:promotionCode.value,...param}) .then((resp) => { if (resp.data.code == "S00000") {