Blame view

common/common.js 6.36 KB
4b045f7c   刘淇   江阴初始化项目
1
  import md5 from './md5.min.js';
4b045f7c   刘淇   江阴初始化项目
2
3
  // 江阴正式环境
  var serverUrl = "https://bus.jycrtc.com";
2f02d40c   chenbiao   add 登录页面数据接口联调
4
  //江阴微信小程序appid
1cea5358   刘淇   停车记录详情
5
  const hs_wxPay_appId = 'wxfdc1af620d3ab750';
2f02d40c   chenbiao   add 登录页面数据接口联调
6
7
  //  江阴慧停车orgId
  const public_orgId = '10107';
b42d4437   chenbiao   add 公共js信息更新
8
9
  const appName = '江阴慧停车';
  const ACompany = '©江阴慧停车管理有限公司';
4b045f7c   刘淇   江阴初始化项目
10
  const BCompany = '由中兴智能交通股份有限公司提供技术支持';
4b045f7c   刘淇   江阴初始化项目
11
  const appVerson = '1.0.0';
4b045f7c   刘淇   江阴初始化项目
12
  const SetToken = uni.getStorageSync("globalUser").token;
4b045f7c   刘淇   江阴初始化项目
13
14
  // ----江阴项目 接口----
  //  商户登录
2f02d40c   chenbiao   add 登录页面数据接口联调
15
  const userLogin = serverUrl + "/business/h5/index/login";
f7e9351e   chenbiao   add 接口文档更新
16
17
  //  获取已登录商户用户信息
  const indexInfo = serverUrl + "/business/h5/index/info";
4b045f7c   刘淇   江阴初始化项目
18
  //  商户退出登录
2f02d40c   chenbiao   add 登录页面数据接口联调
19
  const userLoginout = serverUrl + "/business/h5/index/logout";
4b045f7c   刘淇   江阴初始化项目
20
  //  商户关于我们
2f02d40c   chenbiao   add 登录页面数据接口联调
21
  const useraboutUs = serverUrl + "/business/h5/index/aboutUs";
93c5ecb3   chenbiao   add 添加filter.js 设...
22
23
  //  商户账户余额信息
  const walletAccount = serverUrl + "/business/h5/wallet/account";
b398dc4a   chenbiao   add 我的钱包 接口联调
24
25
  //  商户充值金额列表
  const rechargeList = serverUrl + "/business/h5/wallet/rechargeList";
d9f79954   刘淇   停车记录
26
27
  //  通过商户ID查询停车记录信息
  const getBusinessParkOrderByBusIdForPage = serverUrl + "/business/h5/order/getBusinessParkOrderByBusIdForPage";
d9f79954   刘淇   停车记录
28
29
  //  通过商户ID查询停车记录信息
  const getPayOrderByOrderId = serverUrl + "/business/h5/order/getPayOrderByOrderId";
1cea5358   刘淇   停车记录详情
30
31
  //刘淇接口
  
0b9d5f71   刘淇   停车记录详情
32
  //   商户卡券-可以购买卡券列表-分页
510601e4   刘淇   商户卡券
33
  const couponRuleParkPage = serverUrl + "/business/h5/coupon/couponRuleParkPage";
78e17486   刘淇   商户券明细
34
35
  //   商户卡券-卡券申领明细
  const couponIssuedParkPage = serverUrl + "/business/h5/couponIssued/couponIssuedParkPage";
75b91c08   刘淇   卡券发放
36
37
  //   商户卡券-卡券发放-生成领券的动态码
  const getCouponDynamicQR = serverUrl + "/business/h5/couponsend/getCouponDynamicQR";
78e17486   刘淇   商户券明细
38
  
1cea5358   刘淇   停车记录详情
39
  //陈彪接口
4b045f7c   刘淇   江阴初始化项目
40
  
00a21ab7   chenbiao   add 余额明细 接口联调
41
42
43
44
45
46
47
48
49
50
51
52
  //  余额明细下拉框选择列表
  const walletKindType = serverUrl + "/business/h5/wallet/kindType";
  
  //  余额明细总览
  const detailSummary = serverUrl + "/business/h5/wallet/detailSummary";
  
  //  余额明细-分页
  const walletDetailsPage = serverUrl + "/business/h5/wallet/detailsPage";
  
  // 钱包充值-微信
  const publicUnifiedOrder = serverUrl + "/business/h5/pay/weixinpay/publicUnifiedOrder";
  
2e99af66   chenbiao   add 账单详情 接口联调
53
54
55
  // 钱包-根据订单ID获取购买优惠券信息
  const couponInfo = serverUrl + "/business/h5/wallet/detail/couponInfo";
  // const couponInfo = "http://127.0.0.1:8075/business/h5/wallet/detail/couponInfo";
ed34839c   chenbiao   add 停车缴费 支付页面 接口联调
56
  const queryParkingRecordByCarNumbers ="https://pay.jycrtc.com/queryParkOrder/queryParkingRecordPageByCarNumbersForBusiness";
1cea5358   刘淇   停车记录详情
57
58
59
60
  
  
  
  const requestSign = function (inputData) {
0206229e   刘淇   登陆
61
  	var jsonList = inputData || {};
b6d85d2d   chenbiao   Merge remote-trac...
62
  	jsonList.orgId = public_orgId;
2f02d40c   chenbiao   add 登录页面数据接口联调
63
64
65
66
  	jsonList.sign_type = "md5";
  	jsonList.app_id = "0eca8f5373ca4866aec2f8e9d9367104";
  	jsonList.deviceInfo = "BC0703A4-AFB0-4B51-9089-9B7487C0CC6E";
  	jsonList.salt = getSalt();
dd5ecdbd   chenbiao   add 接口文档更新
67
  	jsonList.terminalSource = "11";
752e0b8b   刘淇   登陆
68
  	// jsonList.token = getGlobalUser("globalUser").token;
32694e4b   刘淇   商户券明细
69
70
  	// jsonList.token = getGlobalUser("globalUser").token;
  	jsonList.token = 'e2c1e43722dd43a5b7e268001b39e6f0';
4b045f7c   刘淇   江阴初始化项目
71
  	var arrData = [];
2f02d40c   chenbiao   add 登录页面数据接口联调
72
  	for (var key in jsonList) {
4b045f7c   刘淇   江阴初始化项目
73
  		var obj = {};
2f02d40c   chenbiao   add 登录页面数据接口联调
74
75
76
77
78
79
  		// console.log("key = "+key);
  		// // obj[key] =jsonList[key];
  		obj.keyname = key;
  		obj.value = jsonList[key];
  		// console.log(obj);
  		arrData.push(obj);
4b045f7c   刘淇   江阴初始化项目
80
  	}
2f02d40c   chenbiao   add 登录页面数据接口联调
81
82
83
  	var sign = getSign(arrData);
  	jsonList.sign = sign;
  	return jsonList;
1cea5358   刘淇   停车记录详情
84
  }
4b045f7c   刘淇   江阴初始化项目
85
  //获取sign
1cea5358   刘淇   停车记录详情
86
  var getSign = function (objb) {
b6bde291   chenbiao   Merge remote-trac...
87
  	var compare = function (obj1, obj2) {
2f02d40c   chenbiao   add 登录页面数据接口联调
88
89
90
91
92
93
94
95
96
  		var val1 = obj1.keyname;
  		var val2 = obj2.keyname;
  		if (val1 < val2) {
  			return -1;
  		} else if (val1 > val2) {
  			return 1;
  		} else {
  			return 0;
  		}
4b045f7c   刘淇   江阴初始化项目
97
98
99
  	}
  	objb.sort(compare);
  	var strmd5 = '14318527b13840c2a4af63fef52c2d6e';
2f02d40c   chenbiao   add 登录页面数据接口联调
100
101
102
103
  	for (var i = 0; i < objb.length; i++) {
  		if (objb[i].value != null && objb[i].value != '') {
  			strmd5 += objb[i].keyname + objb[i].value;
  		}
4b045f7c   刘淇   江阴初始化项目
104
105
  	}
  	strmd5 += '14318527b13840c2a4af63fef52c2d6e';
2f02d40c   chenbiao   add 登录页面数据接口联调
106
  	// console.log('strmd5-------->'+strmd5);
4b045f7c   刘淇   江阴初始化项目
107
  	strmd5 = md5(strmd5);
2f02d40c   chenbiao   add 登录页面数据接口联调
108
  	strmd5 = strmd5.toUpperCase();
4b045f7c   刘淇   江阴初始化项目
109
  	return strmd5;
4b045f7c   刘淇   江阴初始化项目
110
  }
4b045f7c   刘淇   江阴初始化项目
111
  //获取盐值
1cea5358   刘淇   停车记录详情
112
  var getSalt = function () {
2f02d40c   chenbiao   add 登录页面数据接口联调
113
  	var len = parseInt(32);
4b045f7c   刘淇   江阴初始化项目
114
115
116
  	var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
  	var maxPos = $chars.length;
  	var pwd = '';
2f02d40c   chenbiao   add 登录页面数据接口联调
117
118
119
  	for (var i = 0; i < len; i++) {
  		pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
  	}
4b045f7c   刘淇   江阴初始化项目
120
  	// console.log(pwd);
2f02d40c   chenbiao   add 登录页面数据接口联调
121
  	return pwd;
4b045f7c   刘淇   江阴初始化项目
122
  }
1cea5358   刘淇   停车记录详情
123
  var getGlobalUser = function (key) {
4b045f7c   刘淇   江阴初始化项目
124
125
126
127
128
129
  	var userInfo = uni.getStorageSync("globalUser");
  	if (userInfo != null && userInfo != "" && userInfo != undefined) {
  		return userInfo;
  	} else {
  		return '';
  	}
4b045f7c   刘淇   江阴初始化项目
130
  }
16cff37f   刘淇   停车记录
131
132
  // 除了金额
  var moneyFormat = function (val) {
00a21ab7   chenbiao   add 余额明细 接口联调
133
  	return (val / 100).toFixed(2)
16cff37f   刘淇   停车记录
134
  }
51f091d6   刘淇   停车记录详情
135
  var dateFormat = function (msd) {  // 时间转换
b6bde291   chenbiao   Merge remote-trac...
136
  	var time =msd
d6331720   刘淇   停车记录详情
137
  
00a21ab7   chenbiao   add 余额明细 接口联调
138
  	if (null != time && "" != time) {
00a21ab7   chenbiao   add 余额明细 接口联调
139
  		if (time > 60 && time < 60 * 60) {
00a21ab7   chenbiao   add 余额明细 接口联调
140
  			time = parseInt(time / 60.0) + "分钟" + parseInt((parseFloat(time / 60.0) -
d6331720   刘淇   停车记录详情
141
  
00a21ab7   chenbiao   add 余额明细 接口联调
142
  				parseInt(time / 60.0)) * 60) + "秒";
d6331720   刘淇   停车记录详情
143
  
b6bde291   chenbiao   Merge remote-trac...
144
  		}
d6331720   刘淇   停车记录详情
145
  
b6bde291   chenbiao   Merge remote-trac...
146
  		else if (time >= 60 * 60 && time < 60 * 60 * 24) {
00a21ab7   chenbiao   add 余额明细 接口联调
147
  			time = parseInt(time / 3600.0) + "小时" + parseInt((parseFloat(time / 3600.0) -
d6331720   刘淇   停车记录详情
148
  
b6bde291   chenbiao   Merge remote-trac...
149
  				parseInt(time / 3600.0)) * 60) + "分钟" +
d6331720   刘淇   停车记录详情
150
  
00a21ab7   chenbiao   add 余额明细 接口联调
151
  				parseInt((parseFloat((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60) -
d6331720   刘淇   停车记录详情
152
  
00a21ab7   chenbiao   add 余额明细 接口联调
153
  					parseInt((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60)) * 60) + "秒";
d6331720   刘淇   停车记录详情
154
  
00a21ab7   chenbiao   add 余额明细 接口联调
155
  		} else if (time >= 60 * 60 * 24) {
b6bde291   chenbiao   Merge remote-trac...
156
  			time = parseInt(time / 3600.0/24) + "天" +parseInt((parseFloat(time / 3600.0/24)-
d6331720   刘淇   停车记录详情
157
  
b6bde291   chenbiao   Merge remote-trac...
158
  				parseInt(time / 3600.0/24))*24) + "小时" + parseInt((parseFloat(time / 3600.0) -
d6331720   刘淇   停车记录详情
159
  
b6bde291   chenbiao   Merge remote-trac...
160
  				parseInt(time / 3600.0)) * 60) + "分钟" +
d6331720   刘淇   停车记录详情
161
  
00a21ab7   chenbiao   add 余额明细 接口联调
162
  				parseInt((parseFloat((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60) -
d6331720   刘淇   停车记录详情
163
  
00a21ab7   chenbiao   add 余额明细 接口联调
164
  					parseInt((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60)) * 60) + "秒";
d6331720   刘淇   停车记录详情
165
  
b6bde291   chenbiao   Merge remote-trac...
166
  		}
d6331720   刘淇   停车记录详情
167
  
b6bde291   chenbiao   Merge remote-trac...
168
  		else {
00a21ab7   chenbiao   add 余额明细 接口联调
169
  			time = parseInt(time) + "秒";
d6331720   刘淇   停车记录详情
170
  
00a21ab7   chenbiao   add 余额明细 接口联调
171
  		}
d6331720   刘淇   停车记录详情
172
  
00a21ab7   chenbiao   add 余额明细 接口联调
173
  	}
00a21ab7   chenbiao   add 余额明细 接口联调
174
  	return time;
51f091d6   刘淇   停车记录详情
175
  }
4a929260   刘淇   商户券明细
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
  
  var cardTypeFormat =  function(num){
    if(num == '1'){
      return '单次券'
    }
    if(num == 2){
      return '时长券'
    }
    if(num == 3){
      return '满减券'
    }
    if(num == 4){
      return '金额券'
    }
    if(num == 5){
      return '包天券'
    }
    if(num == 6){
      return '折扣券'
    }
  }
2f02d40c   chenbiao   add 登录页面数据接口联调
197
  export default {
4b045f7c   刘淇   江阴初始化项目
198
199
200
201
202
203
  	// deviceInfo,
  	hs_wxPay_appId,
  	public_orgId,
  	appName,
  	ACompany,
  	BCompany,
2f02d40c   chenbiao   add 登录页面数据接口联调
204
  	appVerson,
4b045f7c   刘淇   江阴初始化项目
205
  	SetToken,
4b045f7c   刘淇   江阴初始化项目
206
  	requestSign,
b6d85d2d   chenbiao   Merge remote-trac...
207
  	moneyFormat,
b6bde291   chenbiao   Merge remote-trac...
208
  	dateFormat,
4a929260   刘淇   商户券明细
209
    cardTypeFormat,
2f02d40c   chenbiao   add 登录页面数据接口联调
210
  	// 接口
4b045f7c   刘淇   江阴初始化项目
211
  	userLogin,
f7e9351e   chenbiao   add 接口文档更新
212
  	indexInfo,
4b045f7c   刘淇   江阴初始化项目
213
214
  	userLoginout,
  	useraboutUs,
93c5ecb3   chenbiao   add 添加filter.js 设...
215
  	walletAccount,
b6d85d2d   chenbiao   Merge remote-trac...
216
217
218
  	//刘淇接口
  	getBusinessParkOrderByBusIdForPage,
  	getPayOrderByOrderId,
510601e4   刘淇   商户卡券
219
    couponRuleParkPage,
78e17486   刘淇   商户券明细
220
    couponIssuedParkPage,
75b91c08   刘淇   卡券发放
221
    getCouponDynamicQR,
b6d85d2d   chenbiao   Merge remote-trac...
222
  	//陈彪接口
b398dc4a   chenbiao   add 我的钱包 接口联调
223
  	rechargeList,
00a21ab7   chenbiao   add 余额明细 接口联调
224
225
226
227
  	walletKindType,
  	detailSummary,
  	walletDetailsPage,
  	publicUnifiedOrder,
2e99af66   chenbiao   add 账单详情 接口联调
228
  	couponInfo,
ed34839c   chenbiao   add 停车缴费 支付页面 接口联调
229
  	queryParkingRecordByCarNumbers,
4b045f7c   刘淇   江阴初始化项目
230
  }