Browse Source

修改公众号无法关联用户的问题

zyh
Gaoxs 4 years ago
parent
commit
549ae41097
  1. 2
      libs/wechat.js
  2. 11
      main.js
  3. 14
      pages/Loading/index.vue
  4. 12
      pages/shop/GoodsCon/index.vue

2
libs/wechat.js

@ -152,7 +152,7 @@ export async function auth(code) {
console.log('获取微信授权') console.log('获取微信授权')
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let loginType = cookie.get(LOGINTYPE); let loginType = cookie.get(LOGINTYPE);
let spread = cookie.get(spread); let spread = cookie.get('spread');
wechatAuth(code, spread, loginType) wechatAuth(code, spread, loginType)
.then(({ data }) => { .then(({ data }) => {
console.log(data) console.log(data)

11
main.js

@ -125,16 +125,7 @@ if (!cookie.has(CACHE_KEY)) {
} }
var urlSpread = parseQuery()["spread"]; var urlSpread = parseQuery()["spread"];
cookie.set("spread", urlSpread || 0);
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);
}
}
// #endif // #endif

14
pages/Loading/index.vue

@ -25,7 +25,8 @@
login, login,
handleQrCode, handleQrCode,
getCurrentPageUrl, getCurrentPageUrl,
handleUrlParam handleUrlParam,
getCurrentPageUrlWithArgs
} from "@/utils"; } from "@/utils";
export default { export default {
@ -37,17 +38,12 @@
var url = handleQrCode(); var url = handleQrCode();
if (!url) { if (!url) {
url = handleUrlParam(getCurrentPageUrl()) url = handleUrlParam(getCurrentPageUrlWithArgs())
} }
// //
if (url) { if (url) {
var spread = cookie.get("spread");
let urlSpread = parseInt(url.spread); let urlSpread = parseInt(url.spread);
if (!Number.isNaN(urlSpread) && spread !== urlSpread) {
cookie.set("spread", urlSpread || 0); cookie.set("spread", urlSpread || 0);
} else if (spread === 0 || typeof spread !== "number") {
cookie.set("spread", urlSpread || 0);
}
} }
// if (this.$deviceType == "app" || this.$deviceType == "weixinh5") { // if (this.$deviceType == "app" || this.$deviceType == "weixinh5") {
// this.$yrouter.switchTab({ // this.$yrouter.switchTab({
@ -81,8 +77,8 @@
}); });
cookie.remove('redirect'); cookie.remove('redirect');
} else { } else {
this.$yrouter.replace({ this.$yrouter.switchTab({
path: '/pages/home/index', path: "/pages/home/index"
}); });
} }
} }

12
pages/shop/GoodsCon/index.vue

@ -220,7 +220,9 @@
import { import {
isWeixin, isWeixin,
PosterCanvas, PosterCanvas,
handleQrCode handleQrCode,
handleUrlParam,
getCurrentPageUrlWithArgs
} from "@/utils"; } from "@/utils";
import { import {
wechatEvevt wechatEvevt
@ -303,15 +305,13 @@
computed: mapGetters(["isLogin", "location"]), computed: mapGetters(["isLogin", "location"]),
mounted: function () { mounted: function () {
let url = handleQrCode(); let url = handleQrCode();
if (!url) {
url = handleUrlParam(getCurrentPageUrlWithArgs())
}
if (url && url.id) { if (url && url.id) {
this.id = url.id; this.id = url.id;
var spread = cookie.get("spread");
let urlSpread = parseInt(url.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 { } else {
this.id = this._route.query.id; this.id = this._route.query.id;
} }

Loading…
Cancel
Save