-
Notifications
You must be signed in to change notification settings - Fork 8
/
common.js
68 lines (56 loc) · 1.33 KB
/
common.js
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
var _ = require("underscore");
var common = {
err : ""
};
common.getErr = function(){
return this.err;
}
common.setErr = function(err){
this.err = err;
}
common.vefiyConf = function(config){
if(config.weixin){
for(var key in config.weixin){
var weixin = config.weixin[key];
if(!weixin.appid){
this.setErr("微信: appid 配置错误");
return false;
}
if(!weixin.mch_id){
this.setErr("微信: 商户号 配置错误");
return false;
}
if(!weixin.key){
this.setErr("微信: 加密串 配置错误");
return false;
}
}
}
if(config.alipay){
for(var key in config.alipay){
var alipay = config.alipay[key];
if(!alipay.seller_id){
this.setErr("支付宝: seller_id 配置错误");
return false;
}
if(!alipay.partner){
this.setErr("支付宝: partner 配置错误");
return false;
}
if(!alipay.app_id){
this.setErr("支付宝: app_id 配置错误");
return false;
}
}
}
return true;
}
common.queryize = function(params, quoted) {
if (!params) {
return null;
}
return Object.keys(params).sort().map(function(k) {
return k + '=' + (quoted ? ('"' + params[k] + '"') : params[k]);
}).join('&');
}
module.exports = common;