|
@@ -1,55 +1,48 @@
|
|
|
import { Toast, Notify } from 'vant'
|
|
|
import Clipboard from "clipboard";
|
|
|
import { getWxToken, setWxToken, openError } from "@/utils/auth";
|
|
|
-import { getIsIdentity, supremeAuthority, getIsWx, getTypes, getTypesName, getUserData, getEmployeeMap, getCache, setCache, removeCache, returnDeptName, getEmployeeMapItem, returnFh } from '@/utils/auth'
|
|
|
+import {getCache} from '@/utils/auth'
|
|
|
//判断环境/登录状态
|
|
|
-export function isWxEnv(type,data) {
|
|
|
+export function isWxEnv(type, data) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- 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 {
|
|
|
- if (getWxToken()&&localStorage.getItem('wx_user_info')) {
|
|
|
- resolve()
|
|
|
- } else {
|
|
|
- Toast.fail("当前不在微信环境中,请在微信中打开浏览");
|
|
|
- reject(2)
|
|
|
- }
|
|
|
- }
|
|
|
- }else{
|
|
|
- if (getWxToken()&&localStorage.getItem('wx_user_info')) {
|
|
|
+ if (isWeChatMobile()) {
|
|
|
+ if (getWxToken() && localStorage.getItem('wx_user_info')) {
|
|
|
+ Toast("微信环境已授权");
|
|
|
resolve()
|
|
|
} else {
|
|
|
- Toast.fail("当前不在微信环境中,请在微信中打开浏览");
|
|
|
- reject(2)
|
|
|
+ Toast.fail("微信环境未授权");
|
|
|
+ reject(1)
|
|
|
+ doWeixinLogin(type, data);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ Toast.fail("请在手机微信中打开浏览");
|
|
|
+ reject(2)
|
|
|
+ // if (getWxToken() && localStorage.getItem('wx_user_info')) {
|
|
|
+ // resolve()
|
|
|
+ // } else {
|
|
|
+ // Toast.fail("请在手机微信中打开浏览");
|
|
|
+ // reject(2)
|
|
|
+ // }
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-function isWeChat() {
|
|
|
- var ua = navigator.userAgent.toLowerCase();
|
|
|
- return /micromessenger/.test(ua);
|
|
|
-}
|
|
|
-
|
|
|
-function isWeChatPC() {
|
|
|
- var ua = navigator.userAgent.toLowerCase();
|
|
|
+export function isWeChat() {
|
|
|
+ var ua = navigator.userAgent.toLowerCase();
|
|
|
+ return /micromessenger/.test(ua);
|
|
|
+}
|
|
|
+
|
|
|
+export 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);
|
|
|
-}
|
|
|
-
|
|
|
+ return /micromessenger/.test(ua) && /windows/.test(ua) && !/mobile/.test(ua);
|
|
|
+}
|
|
|
+
|
|
|
+export function isWeChatMobile() {
|
|
|
+ var ua = navigator.userAgent.toLowerCase();
|
|
|
+ return /micromessenger/.test(ua) && /mobile/.test(ua);
|
|
|
+}
|
|
|
+
|
|
|
// if (isWeChat()) {
|
|
|
// if (isWeChatPC()) {
|
|
|
// console.log('这是PC版微信');
|
|
@@ -62,7 +55,7 @@ function isWeChatMobile() {
|
|
|
// console.log('这不是微信浏览器');
|
|
|
// }
|
|
|
//请求微信授权
|
|
|
-export function doWeixinLogin(type,data) {
|
|
|
+export function doWeixinLogin(type, data) {
|
|
|
// let defaultUrl = 'https://3g954g5149.picp.vip/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=1'
|
|
|
// let dealerUrl = 'https://3g954g5149.picp.vip/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=2&pid='
|
|
|
// let timinalUrl = 'https://3g954g5149.picp.vip/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=3&expendCode='
|
|
@@ -70,19 +63,19 @@ export function doWeixinLogin(type,data) {
|
|
|
let dealerUrl = `${process.env.BASE_API}/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=2&pid=`
|
|
|
let timinalUrl = `${process.env.BASE_API}/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=3&expendCode=`
|
|
|
if (getCache("isAndroid")) {
|
|
|
- if (type == 'pid'&&data) {
|
|
|
+ if (type == 'pid' && data) {
|
|
|
window.open(`${dealerUrl}${data}`)
|
|
|
- } else if(type == 'code'&&data){
|
|
|
+ } else if (type == 'code' && data) {
|
|
|
window.open(`${timinalUrl}${data}`)
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
window.open(`${defaultUrl}`)
|
|
|
}
|
|
|
} else {
|
|
|
- if (type == 'pid'&&data) {
|
|
|
+ if (type == 'pid' && data) {
|
|
|
window.location.href = `${dealerUrl}${data}`;
|
|
|
- } else if(type == 'code'&&data){
|
|
|
+ } else if (type == 'code' && data) {
|
|
|
window.location.href = `${timinalUrl}${data}`;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
window.location.href = `${defaultUrl}`;
|
|
|
}
|
|
|
}
|