diff --git a/libs/wechat.js b/libs/wechat.js index 5cad6b7..b47cbb9 100644 --- a/libs/wechat.js +++ b/libs/wechat.js @@ -152,7 +152,7 @@ export async function auth(code) { console.log('获取微信授权') return new Promise((resolve, reject) => { let loginType = cookie.get(LOGINTYPE); - let spread = cookie.get(spread); + let spread = cookie.get('spread'); wechatAuth(code, spread, loginType) .then(({ data }) => { console.log(data) diff --git a/main.js b/main.js index 66258c1..286e36f 100644 --- a/main.js +++ b/main.js @@ -125,16 +125,7 @@ if (!cookie.has(CACHE_KEY)) { } var urlSpread = parseQuery()["spread"]; - -if (urlSpread !== undefined) { - var spread = cookie.get("spread"); - urlSpread = parseInt(urlSpread); - if (!Number.isNaN(urlSpread) && spread !== urlSpread) { - cookie.set("spread", urlSpread || 0); - } else if (spread === 0 || typeof spread !== "number") { - cookie.set("spread", urlSpread || 0); - } -} +cookie.set("spread", urlSpread || 0); // #endif diff --git a/pages/Loading/index.vue b/pages/Loading/index.vue index 578a2eb..ac26c7a 100644 --- a/pages/Loading/index.vue +++ b/pages/Loading/index.vue @@ -25,7 +25,8 @@ login, handleQrCode, getCurrentPageUrl, - handleUrlParam + handleUrlParam, + getCurrentPageUrlWithArgs } from "@/utils"; export default { @@ -37,17 +38,12 @@ var url = handleQrCode(); if (!url) { - url = handleUrlParam(getCurrentPageUrl()) + url = handleUrlParam(getCurrentPageUrlWithArgs()) } // 判断是否是分销 if (url) { - var spread = cookie.get("spread"); let urlSpread = parseInt(url.spread); - if (!Number.isNaN(urlSpread) && spread !== urlSpread) { - cookie.set("spread", urlSpread || 0); - } else if (spread === 0 || typeof spread !== "number") { - cookie.set("spread", urlSpread || 0); - } + cookie.set("spread", urlSpread || 0); } // if (this.$deviceType == "app" || this.$deviceType == "weixinh5") { // this.$yrouter.switchTab({ @@ -81,8 +77,8 @@ }); cookie.remove('redirect'); } else { - this.$yrouter.replace({ - path: '/pages/home/index', + this.$yrouter.switchTab({ + path: "/pages/home/index" }); } } diff --git a/pages/shop/GoodsCon/index.vue b/pages/shop/GoodsCon/index.vue index a323675..b7c3a4b 100644 --- a/pages/shop/GoodsCon/index.vue +++ b/pages/shop/GoodsCon/index.vue @@ -220,7 +220,9 @@ import { isWeixin, PosterCanvas, - handleQrCode + handleQrCode, + handleUrlParam, + getCurrentPageUrlWithArgs } from "@/utils"; import { wechatEvevt @@ -303,15 +305,13 @@ computed: mapGetters(["isLogin", "location"]), mounted: function () { let url = handleQrCode(); + if (!url) { + url = handleUrlParam(getCurrentPageUrlWithArgs()) + } if (url && url.id) { this.id = url.id; - var spread = cookie.get("spread"); let urlSpread = parseInt(url.spread); - if (!Number.isNaN(urlSpread) && spread !== urlSpread) { - cookie.set("spread", urlSpread || 0); - } else if (spread === 0 || typeof spread !== "number") { - cookie.set("spread", urlSpread || 0); - } + cookie.set("spread", urlSpread || 0); } else { this.id = this._route.query.id; }