Jacob
1 天以前 6a0a2c52a4ea8049909b8d7a40d0c2d098b5e74c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import {
   spread
} from "@/api/user";
import Cache from "@/utils/cache";
 
/**
 * 静默授权绑定上下级,使用在已经登录后扫描了别人的推广二维码
 * @param {Object} puid
 */
export function silenceBindingSpread() {
 
 
   //#ifdef H5 || APP 
   let puid = Cache.get('spread');
   //#endif
 
   //#ifdef MP
   let puid = getApp().globalData.spid;
   //#endif
 
   puid = parseInt(puid);
   if (Number.isNaN(puid)) {
       puid = 0;
   }
   if (puid) {
       spread(puid).then(res => {}).catch(res => {});
       //#ifdef H5
       Cache.clear('spread');
       //#endif
 
       //#ifdef MP
       getApp().globalData.spid = 0;
       getApp().globalData.code = 0;
       //#endif
   } else {
       Cache.set('spread', 0);
   }
}
 
export function isWeixin() {
   return navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1;
}
 
export function parseQuery() {
   const res = {};
 
   const query = (location.href.split("?")[1] || "")
       .trim()
       .replace(/^(\?|#|&)/, "");
 
   if (!query) {
       return res;
   }
 
   query.split("&").forEach(param => {
       const parts = param.replace(/\+/g, " ").split("=");
       const key = decodeURIComponent(parts.shift());
       const val = parts.length > 0 ? decodeURIComponent(parts.join("=")) : null;
 
       if (res[key] === undefined) {
           res[key] = val;
       } else if (Array.isArray(res[key])) {
           res[key].push(val);
       } else {
           res[key] = [res[key], val];
       }
   });
 
   return res;
}
 
export function parseQueryString(str) {
   const res = {};
 
   const query = str
       .trim()
       .replace(/^(\?|#|&)/, "");
 
   if (!query) {
       return res;
   }
 
   query.split("&").forEach(param => {
       const parts = param.replace(/\+/g, " ").split("=");
       const key = decodeURIComponent(parts.shift());
       const val = parts.length > 0 ? decodeURIComponent(parts.join("=")) : null;
 
       if (res[key] === undefined) {
           res[key] = val;
       } else if (Array.isArray(res[key])) {
           res[key].push(val);
       } else {
           res[key] = [res[key], val];
       }
   });
 
   return res;
}
// #ifdef H5
const VUE_APP_WS_URL = process.env.VUE_APP_WS_URL || `ws://${location.hostname}:20001`;
export {
   VUE_APP_WS_URL
}
// #endif
 
 
 
export default parseQuery;