common.js
9.75 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
import md5 from './md5.min.js';
// 江阴正式环境
var serverUrl = "http://test.jycrtc.com:8096";
// 测试 http://test.jycrtc.com:8096 正式 https://bus.jycrtc.com
var serverPayUrl = ''
// 测试环境
// var serverUrl = "http://test.jycrtc.com:8096";
//江阴微信小程序appid
const hs_wxPay_appId = 'wxfdc1af620d3ab750';
// 江阴慧停车orgId
const public_orgId = '10107';
const appName = '江阴慧停车';
const ACompany = '©江阴慧停车管理有限公司';
const BCompany = '由中兴智能交通股份有限公司提供技术支持';
const appVerson = '1.0.0';
const SetToken = uni.getStorageSync("globalUser").token;
// const SetToken = 'e2c1e43722dd43a5b7e268001b39e6f0';
// ----江阴项目 接口----
// 商户登录
const userLogin = serverUrl + "/business/h5/index/login";
// 获取已登录商户用户信息
const indexInfo = serverUrl + "/business/h5/index/info";
// 商户退出登录
const userLoginout = serverUrl + "/business/h5/index/logout";
// 商户关于我们
const useraboutUs = serverUrl + "/business/h5/index/aboutUs";
// 商户账户余额信息
const walletAccount = serverUrl + "/business/h5/wallet/account";
// 商户充值金额列表
const rechargeList = serverUrl + "/business/h5/wallet/rechargeList";
// 通过商户ID查询停车记录信息
const getBusinessParkOrderByBusIdForPage = serverUrl + "/business/h5/order/getBusinessParkOrderByBusIdForPage";
// 通过商户ID查询停车记录信息
const getPayOrderByOrderId = serverUrl + "/business/h5/order/getPayOrderByOrderId";
//刘淇接口
// 商户卡券-可以购买卡券列表-分页
const couponRuleParkPage = serverUrl + "/business/h5/coupon/couponRuleParkPage";
// 商户卡券-卡券申领明细
const couponIssuedParkPage = serverUrl + "/business/h5/couponIssued/couponIssuedParkPage";
// 商户卡券-卡券发放-生成领券的动态码
const getCouponDynamicQR = serverUrl + "/business/h5/couponsend/getCouponDynamicQR";
// 商户卡券-卡券发放-生成领券的静态码下载地址
const getCouponStaticQR = serverUrl + "/business/h5/couponsend/getCouponStaticQR";
// 卡券申领明细总览
const couponDetailSummary = serverUrl + "/business/h5/couponIssued/couponDetailSummary";
// 商户卡券-卡券下单
const createCouponOrder = serverUrl + "/business/h5/coupon/createCouponOrder";
// 商户卡券-使用余额购买
const accountPay = serverUrl + "/business/h5/pay/busAccount/accountPay";
// 获取发票抬头列表
const queryCustInvoiceInfoList = serverUrl + "/business/h5/pay/invoice/queryCustInvoiceInfoList";
// 新增一条客户发票抬头信息
const insertCustInvoiceInfo = serverUrl + "/business/h5/pay/invoice/insertCustInvoiceInfo";
// 通过主键更新一条客户发票抬头信息
const updateCustInvoiceInfo = serverUrl + "/business/h5/pay/invoice/updateCustInvoiceInfo";
// 删除一条客户发票抬头信息
const deleteCustInvoiceInfoByID = serverUrl + "/business/h5/pay/invoice/deleteCustInvoiceInfoByID";
// 获取开票订单列表
const queryRntPayOrderForInvoice = serverUrl + "/business/h5/pay/invoice/queryRntPayOrderForInvoice";
// 记录客户开发票历史信息及开票历史详情信息
const openTicketForCustInvoiceHisInfo = serverUrl + "/business/h5/pay/invoice/openTicketForCustInvoiceHisInfo";
// 查询客户所有发票历史
const queryCustInvoiceHistoryList = serverUrl + "/business/h5/pay/invoice/queryCustInvoiceHistoryList";
// 重发邮件
const resendInvoiceMail = serverUrl + "/business/h5/pay/invoice/resendInvoiceMail";
//陈彪接口
// 余额明细下拉框选择列表
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";
// 根据商户支出停车费订单ID获取订单信息
const getParkingInfoByOrderId = serverUrl + "/business/h5/wallet/detail/getParkingInfoByOrderId";
// 钱包-根据订单ID获取购买优惠券信息
const couponInfo = serverUrl + "/business/h5/wallet/detail/couponInfo";
// 根据车牌号查询车牌号订单支付详情
const queryParkingRecordByCarNumbers ="https://pay.jycrtc.com/queryParkOrder/queryParkingRecordPageByCarNumbersForBusiness";
// 根据商户支出 购买卡券订单ID获取订单信息
const getOpenIdByCode = "https://pay.jycrtc.com/weixinPublicPay/getSmallRoutineOpenIdByCode"
// 停车记录明细总览
const parkingCouponSummary = serverUrl +"/business/h5/order/parkingCouponSummary"
const requestSign = function (inputData) {
var jsonList = inputData || {};
jsonList.orgId = public_orgId;
jsonList.sign_type = "md5";
jsonList.app_id = "0eca8f5373ca4866aec2f8e9d9367104";
jsonList.deviceInfo = "BC0703A4-AFB0-4B51-9089-9B7487C0CC6E";
jsonList.salt = getSalt();
jsonList.terminalSource = "16";
// jsonList.token = getGlobalUser("globalUser").token;
jsonList.token = getGlobalUser("globalUser").token;
// jsonList.token = 'e2c1e43722dd43a5b7e268001b39e6f0';
var arrData = [];
for (var key in jsonList) {
var obj = {};
// console.log("key = "+key);
// // obj[key] =jsonList[key];
obj.keyname = key;
obj.value = jsonList[key];
// console.log(obj);
arrData.push(obj);
}
var sign = getSign(arrData);
jsonList.sign = sign;
return jsonList;
}
//获取sign
var getSign = function (objb) {
var compare = function (obj1, obj2) {
var val1 = obj1.keyname;
var val2 = obj2.keyname;
if (val1 < val2) {
return -1;
} else if (val1 > val2) {
return 1;
} else {
return 0;
}
}
objb.sort(compare);
var strmd5 = '14318527b13840c2a4af63fef52c2d6e';
for (var i = 0; i < objb.length; i++) {
if (objb[i].value != null && objb[i].value != '') {
strmd5 += objb[i].keyname + objb[i].value;
}
}
strmd5 += '14318527b13840c2a4af63fef52c2d6e';
// console.log('strmd5-------->'+strmd5);
strmd5 = md5(strmd5);
strmd5 = strmd5.toUpperCase();
return strmd5;
}
//获取盐值
var getSalt = function () {
var len = parseInt(32);
var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
var maxPos = $chars.length;
var pwd = '';
for (var i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
// console.log(pwd);
return pwd;
}
var getGlobalUser = function (key) {
var userInfo = uni.getStorageSync("globalUser");
if (userInfo != null && userInfo != "" && userInfo != undefined) {
return userInfo;
} else {
return '';
}
}
// 除了金额
var moneyFormat = function (val) {
if(val){
return (val / 100).toFixed(2)
}else{
return '-'
}
}
var dateFormat = function (msd) { // 时间转换
var time =msd
if (null != time && "" != time) {
if (time > 60 && time < 60 * 60) {
time = parseInt(time / 60.0) + "分钟" + parseInt((parseFloat(time / 60.0) -
parseInt(time / 60.0)) * 60) + "秒";
}
else if (time >= 60 * 60 && time < 60 * 60 * 24) {
time = parseInt(time / 3600.0) + "小时" + parseInt((parseFloat(time / 3600.0) -
parseInt(time / 3600.0)) * 60) + "分钟" +
parseInt((parseFloat((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60) -
parseInt((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60)) * 60) + "秒";
} else if (time >= 60 * 60 * 24) {
time = parseInt(time / 3600.0/24) + "天" +parseInt((parseFloat(time / 3600.0/24)-
parseInt(time / 3600.0/24))*24) + "小时" + parseInt((parseFloat(time / 3600.0) -
parseInt(time / 3600.0)) * 60) + "分钟" +
parseInt((parseFloat((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60) -
parseInt((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60)) * 60) + "秒";
}
else {
time = parseInt(time) + "秒";
}
}
return time;
}
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 '折扣券'
}
}
var formatDate = function(dataStr) {
var time = new Date(dataStr);
function timeAdd0(str) {
if (str < 10) {
str = '0' + str;
}
return str
}
var y = time.getFullYear();
var m = time.getMonth() + 1;
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
var s = time.getSeconds();
return y + '-' + timeAdd0(m) + '-' + timeAdd0(d) + ' '
+ timeAdd0(h) + ':' + timeAdd0(mm) + ':' + timeAdd0(s);
};
export default {
// deviceInfo,
formatDate,
hs_wxPay_appId,
public_orgId,
appName,
ACompany,
BCompany,
appVerson,
SetToken,
requestSign,
moneyFormat,
dateFormat,
cardTypeFormat,
// 接口
userLogin,
indexInfo,
userLoginout,
useraboutUs,
walletAccount,
//刘淇接口
getBusinessParkOrderByBusIdForPage,
getPayOrderByOrderId,
couponRuleParkPage,
couponIssuedParkPage,
getCouponDynamicQR,
getCouponStaticQR,
couponDetailSummary,
createCouponOrder,
accountPay,
// 获取发票抬头列表
queryCustInvoiceInfoList,
// 新增一条客户发票抬头信息
insertCustInvoiceInfo,
// 通过主键更新一条客户发票抬头信息
updateCustInvoiceInfo,
// 删除一条客户发票抬头信息
deleteCustInvoiceInfoByID,
// 获取开票订单列表
queryRntPayOrderForInvoice,
// 记录客户开发票历史信息及开票历史详情信息
openTicketForCustInvoiceHisInfo,
// 查询客户所有发票历史
queryCustInvoiceHistoryList,
// 重发邮件
resendInvoiceMail,
//陈彪接口
rechargeList,
walletKindType,
detailSummary,
walletDetailsPage,
publicUnifiedOrder,
couponInfo,
queryParkingRecordByCarNumbers,
getOpenIdByCode,
getParkingInfoByOrderId,
parkingCouponSummary,
}