Blame view

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