From 3dafb93cb385dd4e14306a8b764c916031136717 Mon Sep 17 00:00:00 2001 From: "liu.xiaofeng@ebiz-digits.com" Date: Mon, 22 May 2023 21:45:08 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=9B=BD=E5=AF=8C=E4=BA=BA=E5=AF=BF?= =?UTF-8?q?=E3=80=91config=E7=9A=84index.js=20=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/index.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/config/index.js b/src/config/index.js index cb8c296d6..1d80d7f05 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -27,27 +27,27 @@ function getSearchString (key) { } return obj[key] } -let apiVersion = 'v1' -// var ua = window.navigator.userAgent.toLowerCase() -// //通过正则表达式匹配ua中是否含有MicroMessenger字符串, 在微信 -// if (localStorage.getItem('apiVersion')) { -// apiVersion = localStorage.getItem('apiVersion') -// } else { -// if (ua.match(/MicroMessenger/i) == 'micromessenger') { -// //report/reportList数据报表页面在浏览器可以打开了,但在微信或企业微信中打开不了,接口请求不需要token -// if (window.location.href.indexOf('apiVersion') > 0) { -// apiVersion = getSearchString('apiVersion') == 'V3' ? 'v3' : 'v2';//url中apiVersion没有时,为v2 -// } else { -// apiVersion = 'v3' -// } -// } 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) -// } +let apiVersion = 'v2' +var ua = window.navigator.userAgent.toLowerCase() +//通过正则表达式匹配ua中是否含有MicroMessenger字符串, 在微信 +if (localStorage.getItem('apiVersion')) { + apiVersion = localStorage.getItem('apiVersion') +} else { + if (ua.match(/MicroMessenger/i) == 'micromessenger') { + //report/reportList数据报表页面在浏览器可以打开了,但在微信或企业微信中打开不了,接口请求不需要token + if (window.location.href.indexOf('apiVersion') > 0) { + apiVersion = getSearchString('apiVersion') == 'V3' ? 'v3' : 'v2';//url中apiVersion没有时,为v2 + } else { + apiVersion = 'v3' + } + } 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) +} // 可以多个接口域名,按需添加 console.log('环境:', process.env.VUE_APP_FLAG) switch (process.env.VUE_APP_FLAG) {