Authored by yyq
Committed by lea guo

fix URLSearchParams

1 import {get} from 'lodash'; 1 import {get} from 'lodash';
2 import Vue from 'vue'; 2 import Vue from 'vue';
  3 +import queryString from 'querystring';
  4 +
  5 +function getJumpUrl(qs = {}) {
  6 + return `//m.yohobuy.com/?${queryString.stringify(qs)}`;
  7 +}
3 8
4 export default function() { 9 export default function() {
5 return { 10 return {
@@ -39,17 +44,13 @@ export default function() { @@ -39,17 +44,13 @@ export default function() {
39 if(item.linkType === 'h5'){ 44 if(item.linkType === 'h5'){
40 item.isShow = true; 45 item.isShow = true;
41 item.url = item.link; 46 item.url = item.link;
42 - }else {  
43 - let hostUrl ='http://m.yohobuy.com/';  
44 - let params = new URLSearchParams();  
45 -  
46 - params.append('pagename', 'productList');  
47 - params.append('title', item.name);  
48 - params.append(`${item.linkType}`, item.link);  
49 - 47 + } else {
50 item.isShow = false; 48 item.isShow = false;
51 - let url = `${hostUrl}?${params}`  
52 - item.url = url 49 + item.url = getJumpUrl({
  50 + pagename: 'productList',
  51 + title: item.name,
  52 + [item.linkType]: item.link
  53 + });
53 } 54 }
54 55
55 }) 56 })
@@ -58,16 +59,6 @@ export default function() { @@ -58,16 +59,6 @@ export default function() {
58 state.categorySubList = data.category; 59 state.categorySubList = data.category;
59 } 60 }
60 }, 61 },
61 - getUrl(item){  
62 - let hostUrl ='http://m.yohobuy.com/';  
63 - let params = new URLSearchParams();  
64 -  
65 - params.append('pagename', 'productList');  
66 - params.append('title', item.name);  
67 - params.append(`${item.linkType}`, item.link);  
68 -  
69 - return `${hostUrl}?${params}`  
70 - },  
71 addBrandList(state, {data}){ 62 addBrandList(state, {data}){
72 if(data && data.brand_list){ 63 if(data && data.brand_list){
73 let sub = []; 64 let sub = [];
@@ -75,15 +66,8 @@ export default function() { @@ -75,15 +66,8 @@ export default function() {
75 66
76 data.brand_list.forEach((val, index) => { 67 data.brand_list.forEach((val, index) => {
77 val.isSelect = false; 68 val.isSelect = false;
78 - let hostUrl ='http://m.yohobuy.com/';  
79 - let params = new URLSearchParams();  
80 -  
81 - params.append('pagename', 'productList');  
82 - params.append('title', val.brand_name);  
83 - params.append('brand', val.id);  
84 69
85 let isShowBottomBordor = (size - index) > 3; 70 let isShowBottomBordor = (size - index) > 3;
86 - let url = `${hostUrl}?${params}`  
87 let right = index % 3 !== 2 ? '-right' : ''; 71 let right = index % 3 !== 2 ? '-right' : '';
88 let bottom = isShowBottomBordor ? '-bottom' : ''; 72 let bottom = isShowBottomBordor ? '-bottom' : '';
89 let subItem = { 73 let subItem = {
@@ -92,7 +76,11 @@ export default function() { @@ -92,7 +76,11 @@ export default function() {
92 image: val.brand_logo, 76 image: val.brand_logo,
93 linkType: 'brand', 77 linkType: 'brand',
94 link: val.id, 78 link: val.id,
95 - url: url, 79 + url: getJumpUrl({
  80 + pagename: 'productList',
  81 + title: val.brand_name,
  82 + brand: val.id,
  83 + }),
96 isShow: false, 84 isShow: false,
97 } 85 }
98 86