|
@@ -5,39 +5,25 @@ import {
|
|
|
} from '@/api/configget';
|
|
|
import Router from '@/router'
|
|
|
// import {withoutCodeLoad} from '@/utils/wxconfiguration.js'
|
|
|
-import moment from 'moment' // 时间库
|
|
|
import {
|
|
|
getToken
|
|
|
} from '@/utils/auth'
|
|
|
|
|
|
export const wxAuth = async (ifHome, next, to) => {
|
|
|
const wechatConfigUrl = location.href.split('#')[0]
|
|
|
- console.log('获取url')
|
|
|
+ console.log('--获取url--')
|
|
|
console.log(wechatConfigUrl)
|
|
|
console.log(window.wechatConfigUrl)
|
|
|
- if (window.wechatConfigUrl === wechatConfigUrl) {
|
|
|
+ if (window.wechatConfigUrl === wechatConfigUrl && window.WWOpenData) {
|
|
|
if (getToken()) {
|
|
|
- console.log('进入getToken')
|
|
|
- // console.log(to)
|
|
|
- // console.log(!to)
|
|
|
- // console.log('R你XR')
|
|
|
- // console.log(Router.history.current.name)
|
|
|
- // console.log(to.name)
|
|
|
- // if (Router.history.current.name == 'login' && !to) {
|
|
|
- // console.log('执行跳转?')
|
|
|
- // Router.push({
|
|
|
- // name: 'home'
|
|
|
- // })
|
|
|
- // }
|
|
|
+ console.log('--满足跳转条件--')
|
|
|
if (ifHome) {
|
|
|
- console.log('login跳转?')
|
|
|
+ console.log('--跳转首页--')
|
|
|
Router.push({
|
|
|
name: 'home'
|
|
|
})
|
|
|
} else {
|
|
|
- console.log(next)
|
|
|
if (next) {
|
|
|
- console.log('1111111111111')
|
|
|
next()
|
|
|
}
|
|
|
}
|
|
@@ -58,7 +44,7 @@ async function wxConfigByCorp(ifHome, body, next) {
|
|
|
var data;
|
|
|
await allocations(body).then((res) => {
|
|
|
if (res.data.code == 1) {
|
|
|
- console.log("请求配置成功")
|
|
|
+ console.log("--请求配置成功--")
|
|
|
data = res.data.data
|
|
|
} else {}
|
|
|
}).catch(() => {
|
|
@@ -68,7 +54,7 @@ async function wxConfigByCorp(ifHome, body, next) {
|
|
|
const appSignature = data.agentConfig
|
|
|
console.log(wxConfigParams)
|
|
|
console.log(appSignature)
|
|
|
- console.log('wxConfig开始')
|
|
|
+ console.log('--wxConfig开始--')
|
|
|
await Vue.prototype.$wx.config({ // 鉴权(企业的身份与权限)
|
|
|
beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
|
|
|
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
|
@@ -87,53 +73,14 @@ async function wxConfigByCorp(ifHome, body, next) {
|
|
|
] // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
|
|
|
});
|
|
|
await Vue.prototype.$wx.ready(function () {
|
|
|
- console.log('wxConfig成功')
|
|
|
- console.log('wx.agentConfig开始')
|
|
|
- console.log('wx.agentConfig:BEGIN');
|
|
|
+ console.log('--wxConfig成功--')
|
|
|
+ console.log('--wx.agentConfig开始--')
|
|
|
+ console.log('--wx.agentConfig:BEGIN--');
|
|
|
const u = navigator.userAgent;
|
|
|
const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; // 安卓
|
|
|
const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
|
|
|
if (isAndroid) {
|
|
|
- console.log('安卓手机');
|
|
|
- // Vue.prototype.$wx.invoke('agentConfig', {
|
|
|
- // Vue.prototype.$wx.agentConfig({
|
|
|
- // corpid: appSignature.appId, // 必填,企业微信的corpid,必须与当前登录的企业一致
|
|
|
- // agentid: appSignature.agentid, // 必填,企业微信的应用id (e.g. 1000247)生产环境 写自己环境的agentid
|
|
|
- // timestamp: appSignature.timestamp, // 必填,生成签名的时间戳
|
|
|
- // nonceStr: appSignature.nonceStr, // 必填,生成签名的随机串
|
|
|
- // signature: appSignature.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
|
|
|
- // jsApiList: [
|
|
|
- // 'openUserProfile',
|
|
|
- // 'previewFile'
|
|
|
- // ], // 必填
|
|
|
- // success(res) {
|
|
|
- // console.log('agentConfig', res);
|
|
|
- // console.log('agentConfig成功')
|
|
|
- // console.log('回调')
|
|
|
- // console.log(res)
|
|
|
- // console.log('window.WWOpenData')
|
|
|
- // console.log(window.WWOpenData)
|
|
|
- // if (next) {
|
|
|
- // next()
|
|
|
- // }
|
|
|
- // if (pushindex) {
|
|
|
- // console.log('跳转首页')
|
|
|
- // Router.push({
|
|
|
- // path: '/'
|
|
|
- // }) //跳转首页
|
|
|
- // }
|
|
|
- // },
|
|
|
- // fail(res) {
|
|
|
- // console.log('err', res);
|
|
|
- // if (res.errMsg.indexOf('function not exist') > -1) {
|
|
|
- // alert('版本过低请升级');
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }, function (res) {
|
|
|
- // console.log('result', res);
|
|
|
- // });
|
|
|
-
|
|
|
-
|
|
|
+ console.log('--安卓手机--');
|
|
|
Vue.prototype.$wx.agentConfig({ //鉴权(应用的身份与权限)
|
|
|
corpid: appSignature.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
|
|
|
agentid: appSignature.agentid, // 必填,企业微信的应用id (e.g. 1000247)
|
|
@@ -142,10 +89,10 @@ async function wxConfigByCorp(ifHome, body, next) {
|
|
|
signature: appSignature.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
|
|
|
jsApiList: ['selectExternalContact'], //必填
|
|
|
success: function (res) { // 回调 // wx.agentConfig成功回调后,WWOpenData 才会注入到 window 对象上面
|
|
|
- console.log('agentConfig成功')
|
|
|
- console.log('回调')
|
|
|
+ console.log('--agentConfig成功--')
|
|
|
+ console.log('--回调--')
|
|
|
console.log(res)
|
|
|
- console.log('window.WWOpenData')
|
|
|
+ console.log('--window.WWOpenData--')
|
|
|
console.log(window.WWOpenData)
|
|
|
console.log(next)
|
|
|
if (next) {
|
|
@@ -154,7 +101,7 @@ async function wxConfigByCorp(ifHome, body, next) {
|
|
|
console.log(getToken())
|
|
|
console.log(ifHome)
|
|
|
if (ifHome) {
|
|
|
- console.log('跳转首页')
|
|
|
+ console.log('--跳转首页--')
|
|
|
Router.push({
|
|
|
name: 'home'
|
|
|
})
|
|
@@ -205,44 +152,5 @@ async function wxConfigByCorp(ifHome, body, next) {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
|
|
|
-
|
|
|
- } else {
|
|
|
- console.log('pc端')
|
|
|
- Vue.prototype.$wx.agentConfig({ //鉴权(应用的身份与权限)
|
|
|
- corpid: appSignature.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
|
|
|
- agentid: appSignature.agentid, // 必填,企业微信的应用id (e.g. 1000247)
|
|
|
- timestamp: appSignature.timestamp, // 必填,生成签名的时间戳
|
|
|
- nonceStr: appSignature.nonceStr, // 必填,生成签名的随机串
|
|
|
- signature: appSignature.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
|
|
|
- jsApiList: ['selectExternalContact'], //必填
|
|
|
- success: function (res) { // 回调 // wx.agentConfig成功回调后,WWOpenData 才会注入到 window 对象上面
|
|
|
- console.log('agentConfig成功')
|
|
|
- console.log('回调')
|
|
|
- console.log(res)
|
|
|
- console.log('window.WWOpenData')
|
|
|
- console.log(window.WWOpenData)
|
|
|
- if (next) {
|
|
|
- next()
|
|
|
- }
|
|
|
- if (ifHome) {
|
|
|
- console.log('跳转首页')
|
|
|
- Router.push({
|
|
|
- name: 'home'
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- fail: function (res) {
|
|
|
- console.log(res)
|
|
|
- if (res.errMsg.indexOf('function not exist') > -1) {
|
|
|
- alert('版本过低请升级')
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
});
|
|
|
-}
|
|
|
+}
|