Blame view

src/utils/utils.js 5.53 KB
65d81c4b   liuqimichale   停车记录接口
1
  import md5 from './md5.min.js';
baa9e35e   刘淇   orgid
2
  
65d81c4b   liuqimichale   停车记录接口
3
4
5
6
7
8
9
10
11
12
13
14
15
  export default {
    myCommonSalt: function (val) { // 获取盐值
      let len = parseInt(val);
      let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
      let 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;
    },
  
44cb771a   liuqimichale   图片修改
16
  
65d81c4b   liuqimichale   停车记录接口
17
  
21bb7bf6   liuqimichale   历史欠费缴纳
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
    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;
    },
  
ae6e7e99   liuqimichale   支付方式
66
67
68
69
70
71
72
73
74
75
76
    signObject: function (jsonObj){ //签名字段
      let sort = []
      for(let k in jsonObj){
        sort.push({
          keyname: k,
          value: jsonObj[k]
        })
      }
      return this.myGetSign(sort)
    },
  
8ecf38fb   刘淇   在停 聚合 支付
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
    signObjectNew: function (inputData){ //签名字段
      // let sort = []
      // for(let k in jsonObj){
      //   sort.push({
      //     keyname: k,
      //     value: jsonObj[k]
      //   })
      // }
      // return this.myGetSign(sort)
  
  
      var jsonList = inputData;
      jsonList.sign_type = "md5";
      jsonList.app_id = "lrpo55tmveqe07w3gpovzgx34pdez7eh";
      jsonList.deviceInfo = "BC0703A4-AFB0-4B51-9089-9B7487C0CC6E";
      jsonList.salt = this.myCommonSalt(32);
      jsonList.terminalSource= '7'
      // jsonList.token= "e3b5417a987641219efb8dc1f8b5fbce"
      // jsonList.token = '84b5a8edb5974f7989e7888b9f48a765';
      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 = this.myGetSign(arrData);
      jsonList.sign = sign;
      return jsonList;
    },
  
ae6e7e99   liuqimichale   支付方式
111
112
113
114
115
116
    clientBrowser: function () { // 判断客户端
      if (/MicroMessenger/.test(window.navigator.userAgent)) {
        console.log("微信客户端");
        return '微信'
      } else if (/AlipayClient/.test(window.navigator.userAgent)) {
        console.log("支付宝客户端");
f304dea7   liuqimichale   农行支付
117
        return '支付宝'
1d350d22   liuqimichale   微信支付 完成
118
119
      } else if (/BankabciPhone/.test(window.navigator.userAgent)) {
        console.log("农行客户端");
db6fba32   liuqimichale   农行支付---立即支付
120
        return '立即'
1d350d22   liuqimichale   微信支付 完成
121
122
      }else if (/BankabcAndroid/.test(window.navigator.userAgent)) {
        console.log("农行客户端");
db6fba32   liuqimichale   农行支付---立即支付
123
        return '立即'
1d350d22   liuqimichale   微信支付 完成
124
      }else {
ae6e7e99   liuqimichale   支付方式
125
        console.log("其他浏览器");
704b8215   liuqimichale   调取微信支付
126
        return '支付宝'
ae6e7e99   liuqimichale   支付方式
127
128
      }
    },
8676f3af   liuqimichale   payType 34
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
  
    // 1:支付宝 2:微信 3:银联 10:H5   4微信公众号   34 农行
    clientBrowsePayType: function () { // 判断客户端
      if (/MicroMessenger/.test(window.navigator.userAgent)) {
        console.log("微信客户端");
        return '4'
      } else if (/AlipayClient/.test(window.navigator.userAgent)) {
        console.log("支付宝客户端");
        return '1'
      } else if (/BankabciPhone/.test(window.navigator.userAgent)) {
        console.log("农行客户端");
        return '34'
      }else if (/BankabcAndroid/.test(window.navigator.userAgent)) {
        console.log("农行客户端");
        return '34'
      }else {
        console.log("其他浏览器");
        return '1'
      }
    },
  
6b286309   liuqimichale   支付方式 -- 微信
150
151
    // 0eca8f5373ca4866aec2f8e9d9367104  老的id
    // 14318527b13840c2a4af63fef52c2d6e 老的签名
e38fe48c   liuqimichale   接口跨域
152
  
e38fe48c   liuqimichale   接口跨域
153
154
155
    // ud8yq5tv0inxupc05xfeau39jywlqoj2  新的id
    // ny1u72b6k374sg379z0kqjgfxe2ycnpw 新的签名
  
8ecf38fb   刘淇   在停 聚合 支付
156
    myVarAppid:'lrpo55tmveqe07w3gpovzgx34pdez7eh',// 公共请求Appid
65d81c4b   liuqimichale   停车记录接口
157
  
21bb7bf6   liuqimichale   历史欠费缴纳
158
159
    myDeviceInfo: 'BC0703A4-AFB0-4B51-9089-9B7487C0CC6E', // 公共请求设备信息
  
a17ce3df   刘淇   宣化 小票码
160
    myVxAppId: 'wx1489e48e6a547023',
44cb771a   liuqimichale   图片修改
161
162
163
    // 测试环境 微信赤峰 appid   wxff4cebaedbf4f886
    // 微信赤峰 appid   wx2af2bab90d433c86
    // 黄石 appid    wxa1a66cc7d263afe6
15eb91bd   刘淇   add
164
    // 天水 appid    wx776e81ec7494232e
44cb771a   liuqimichale   图片修改
165
  
8ecf38fb   刘淇   在停 聚合 支付
166
167
    xuanhuaAppid:'00276515',
  
fd7204cc   刘淇   orgid
168
    myOrgId: sessionStorage.getItem('orgId'), // 归属地 赤峰id  10003    黄石 10079
21bb7bf6   liuqimichale   历史欠费缴纳
169
  
8ecf38fb   刘淇   在停 聚合 支付
170
171
    myOrgId: '10120', // 归属地 赤峰id  10003    黄石 10079
  
44cb771a   liuqimichale   图片修改
172
173
174
175
176
177
178
179
180
181
182
183
184
    myGetSign: 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);
8ecf38fb   刘淇   在停 聚合 支付
185
      var strmd5 = 'gz8wfwd0gn1etamjjhzey1ggcz78pfvd';
44cb771a   liuqimichale   图片修改
186
187
188
189
190
      for(var i=0;i<objb.length;i++){
        if(objb[i].value != null&&objb[i].value != ''){
          strmd5 += objb[i].keyname+objb[i].value;
        }
      }
8ecf38fb   刘淇   在停 聚合 支付
191
      strmd5 += 'gz8wfwd0gn1etamjjhzey1ggcz78pfvd';
44cb771a   liuqimichale   图片修改
192
193
194
195
196
      // console.log('strmd5-------->'+strmd5);
      strmd5 = md5(strmd5);
      strmd5=strmd5.toUpperCase();
      return strmd5;
    },
65d81c4b   liuqimichale   停车记录接口
197
198
  
  }