From 072f8a76eca2bb83e1051ded31a2f39fc19c7c0d Mon Sep 17 00:00:00 2001 From: "li.yuetong" Date: Wed, 19 Oct 2022 14:01:16 +0800 Subject: [PATCH] =?UTF-8?q?=20=E3=80=90=E9=9A=8F=E6=9C=BA=E5=AF=86?= =?UTF-8?q?=E9=92=A5=E5=8A=A0=E5=AF=86=E8=A7=A3=E5=AF=86=E3=80=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=8E=B7=E5=8F=96apiVersion=E8=8E=B7=E5=8F=96v3/v2?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9ClocalStorage=E6=9C=89=E5=80=BC?= =?UTF-8?q?=E5=88=99=E4=B8=8D=E9=87=8D=E6=96=B0=E8=8E=B7=E5=8F=96=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/config/index.js b/src/config/index.js index 941ef1cc2..2e91e25db 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -30,18 +30,18 @@ function getSearchString(key) { let apiVersion = 'v2' var ua = window.navigator.userAgent.toLowerCase() //通过正则表达式匹配ua中是否含有MicroMessenger字符串, 在微信 -if(ua.match(/MicroMessenger/i) == 'micromessenger'){ - if(localStorage.getItem('apiVersion')){ - apiVersion = localStorage.getItem('apiVersion') - }else{ - apiVersion = getSearchString('apiVersion')== 'V3'?'v3':'v2';//url中apiVersion没有时,为v2 - window.localStorage.setItem('apiVersion', apiVersion) - } +if(localStorage.getItem('apiVersion')){ + apiVersion = localStorage.getItem('apiVersion') }else{ - // 在app - if(navigator.userAgent.indexOf('JZG_') > 0){ - apiVersion = navigator.userAgent.split('JZG_')[1].split('/')[0].split('_')[1] == 'V3'?'v3':'v2' + 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' + } } + window.localStorage.setItem('apiVersion', apiVersion) } // 可以多个接口域名,按需添加