Helper.js
963 Bytes
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
'use strict';
function excludeParams(groupParams, needGender=true){
let newParams = {};
try{
let params = groupParams.toJS();
for(let key in params){
if(params[key]){
newParams[key] = params[key]
}
}
//gender 需要进行空处理,防止原生会添加默认值
if(needGender && !newParams["gender"]){
newParams["gender"] = "";
}
//size因为字段是关键字,使用了g_size替换
if(newParams["g_size"]){
newParams["size"] = newParams["g_size"];
delete newParams["g_size"]
}
}catch(e){
}
return newParams;
}
function joinWxProgramPath(wxPath, groupParams){
let params = excludeParams(groupParams, false);
for(let key in params){
wxPath = wxPath + "&" + key + "=" + params[key];
}
return wxPath;
}
module.exports = {
excludeParams,
joinWxProgramPath
};