mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-15 14:06:45 +08:00
【随机密钥加密解密】app内用navigator.userAgent app外用url加参数apiVersion,兼容v2和v3
This commit is contained in:
@@ -14,10 +14,29 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
let apiDomain, imgDomain, assetsUrl, mainUrl, payUrl, zssqUrl, REQ_PWD, CACHE_ENCRYP, API_VERSION, assetsUpUrl // 保融支付的收银台服务地址
|
let apiDomain, imgDomain, assetsUrl, mainUrl, payUrl, zssqUrl, REQ_PWD, CACHE_ENCRYP, API_VERSION, assetsUpUrl // 保融支付的收银台服务地址
|
||||||
|
function getSearchString(key) {
|
||||||
|
var str = window.location.href.split('?')[1]
|
||||||
|
str = str.substring(1, str.length) // 获取URL中?之后的字符(去掉第一位的问号)
|
||||||
|
// 以&分隔字符串,获得类似name=xiaoli这样的元素数组
|
||||||
|
var arr = str.split("&")
|
||||||
|
var obj = new Object()
|
||||||
|
// 将每一个数组元素以=分隔并赋给obj对象
|
||||||
|
for (var i = 0; i < arr.length; i++) {
|
||||||
|
var tmp_arr = arr[i].split("=")
|
||||||
|
obj[decodeURIComponent(tmp_arr[0])] = decodeURIComponent(tmp_arr[1])
|
||||||
|
}
|
||||||
|
return obj[key]
|
||||||
|
}
|
||||||
let apiVersion = 'v2'
|
let apiVersion = 'v2'
|
||||||
if(navigator.userAgent.indexOf('JZG_') > 0){
|
var ua = window.navigator.userAgent.toLowerCase()
|
||||||
// console.log(navigator.userAgent,'navigator.userAgent')
|
//通过正则表达式匹配ua中是否含有MicroMessenger字符串, 在微信
|
||||||
|
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
|
||||||
|
apiVersion = getSearchString('apiVersion')== 'V3'?'v3':'v2';//url中apiVersion没有时,为v2
|
||||||
|
}else{
|
||||||
|
// 在app
|
||||||
|
if(navigator.userAgent.indexOf('JZG_') > 0){
|
||||||
apiVersion = navigator.userAgent.split('JZG_')[1].split('/')[0].split('_')[1] == 'V3'?'v3':'v2'
|
apiVersion = navigator.userAgent.split('JZG_')[1].split('/')[0].split('_')[1] == 'V3'?'v3':'v2'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 可以多个接口域名,按需添加
|
// 可以多个接口域名,按需添加
|
||||||
|
|||||||
Reference in New Issue
Block a user