提交 ea07ef17 编写于 作者: guofeng.chen's avatar guofeng.chen

授权登录

上级 e5058ee5
......@@ -13,6 +13,7 @@ import BuriedPoint, { sendBuriedData } from 'web-buried-point';
import Vant from 'vant';
import 'vant/lib/index.css';
import clipboard from 'clipboard';
import { querystring } from '@/utils';
//注册到vue原型上
Vue.prototype.clipboard = clipboard;
......@@ -69,10 +70,16 @@ function fliterRoute(query, path) {
has = true;
}
// 商品详情页去掉code
if (path === '/goods-detail' && query.code) {
store.dispatch('getWxUserInfo', query.code);
// delete query.code;
// has = true;
if (path === '/goods-detail') {
let search = querystring(location.search);
if (search.code) {
store.dispatch('getWxUserInfo', search.code);
// delete query.code;
let goodsDetailParams = sessionStorage.getItem('goodsDetailParams');
goodsDetailParams = goodsDetailParams ? JSON.parse(goodsDetailParams) : {};
Object.assign(query, goodsDetailParams);
has = true;
}
}
return [query, has];
}
......
......@@ -259,3 +259,19 @@ export function debounce(fn, wait = 50) {
}, wait)
}
}
function decode(input) {
return decodeURIComponent(input.replace(/\+/g, ' '));
}
export function querystring(query) {
var parser = /([^=?&]+)=?([^&]*)/g
, result = {}
, part;
for (;
part = parser.exec(query);
result[decode(part[1])] = decode(part[2])
);
return result;
}
......@@ -120,6 +120,8 @@ export default {
// 数量加减
this.curtGoodsNum = this.goodsNum;
this.countTotalPrice = debounce(this.getTotalPrice, 500);
// 记录参数,授权登录返回时重新赋值,在main.js
sessionStorage.setItem('goodsDetailParams', JSON.stringify(this.$route.query))
},
beforeDestroy() {
this.countTotalPrice = null;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册