|
@@ -5,19 +5,25 @@ import { getIsIdentity, supremeAuthority, getIsWx, getTypes, getTypesName, getUs
|
|
|
//判断环境/登录状态
|
|
|
export function isWxEnv(type,data) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- if (getIsWx()) {
|
|
|
- if (getWxToken()&&localStorage.getItem('wx_user_info')) {
|
|
|
- // Toast("微信环境已授权");
|
|
|
- resolve()
|
|
|
+ if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
|
|
|
+ if (getIsWx()) {
|
|
|
+ if (getWxToken()&&localStorage.getItem('wx_user_info')) {
|
|
|
+ // Toast("微信环境已授权");
|
|
|
+ resolve()
|
|
|
+ } else {
|
|
|
+ // Toast.fail("微信环境未授权");
|
|
|
+ reject(1)
|
|
|
+ doWeixinLogin(type,data);
|
|
|
+ }
|
|
|
} else {
|
|
|
- // Toast.fail("微信环境未授权");
|
|
|
- reject(1)
|
|
|
- //测试用,正式隐藏
|
|
|
- doWeixinLogin(type,data);
|
|
|
+ if (getWxToken()&&localStorage.getItem('wx_user_info')) {
|
|
|
+ resolve()
|
|
|
+ } else {
|
|
|
+ Toast.fail("当前不在微信环境中,请在微信中打开浏览");
|
|
|
+ reject(2)
|
|
|
+ }
|
|
|
}
|
|
|
- } else {
|
|
|
- // Toast.fail("当前不在微信环境中,请在微信中打开浏览");
|
|
|
- // reject(2)
|
|
|
+ }else{
|
|
|
if (getWxToken()&&localStorage.getItem('wx_user_info')) {
|
|
|
resolve()
|
|
|
} else {
|
|
@@ -27,6 +33,34 @@ export function isWxEnv(type,data) {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+function isWeChat() {
|
|
|
+ var ua = navigator.userAgent.toLowerCase();
|
|
|
+ return /micromessenger/.test(ua);
|
|
|
+}
|
|
|
+
|
|
|
+function isWeChatPC() {
|
|
|
+ var ua = navigator.userAgent.toLowerCase();
|
|
|
+ // 你可以根据PC版微信浏览器的特性来添加更多的判断条件
|
|
|
+ // 例如,某些PC版微信浏览器可能包含特定的关键字或版本信息
|
|
|
+ return /micromessenger/.test(ua) && /windows/.test(ua) && !/mobile/.test(ua);
|
|
|
+}
|
|
|
+
|
|
|
+function isWeChatMobile() {
|
|
|
+ var ua = navigator.userAgent.toLowerCase();
|
|
|
+ return /micromessenger/.test(ua) && /mobile/.test(ua);
|
|
|
+}
|
|
|
+
|
|
|
+// if (isWeChat()) {
|
|
|
+// if (isWeChatPC()) {
|
|
|
+// console.log('这是PC版微信');
|
|
|
+// } else if (isWeChatMobile()) {
|
|
|
+// console.log('这是手机版微信');
|
|
|
+// } else {
|
|
|
+// console.log('无法确定是PC版还是手机版微信');
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// console.log('这不是微信浏览器');
|
|
|
+// }
|
|
|
//请求微信授权
|
|
|
export function doWeixinLogin(type,data) {
|
|
|
// let defaultUrl = 'https://3g954g5149.picp.vip/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=1'
|