提交 703957ab 作者: 毛细亚

调试完成

上级 a127a227
<template> <template>
<div id="app" class="mobile-app-wrapper"> <div id="app" class="mobile-app-wrapper">
<div class="mobile-menu-bar" v-if="token"> <div class="mobile-menu-bar" v-if="token && external_userid">
<el-menu <el-menu
:default-active="selectedPath" :default-active="selectedPath"
mode="horizontal" mode="horizontal"
...@@ -80,10 +80,7 @@ export default { ...@@ -80,10 +80,7 @@ export default {
const currentPath = this.$route.path const currentPath = this.$route.path
if (currentPath === '/' || currentPath === '' || currentPath === '/index.html') { if (currentPath === '/' || currentPath === '' || currentPath === '/index.html') {
this.selectedPath = '/userInfo' this.selectedPath = '/userInfo'
// 如果当前路径是根路径或 index.html,重定向到 userInfo // 移除重定向逻辑,让路由配置处理重定向
if (currentPath === '/' || currentPath === '/index.html') {
this.$router.replace('/userInfo')
}
} else { } else {
this.selectedPath = currentPath this.selectedPath = currentPath
} }
......
...@@ -7,6 +7,7 @@ import applyRecord from '../views/applyRecord.vue' ...@@ -7,6 +7,7 @@ import applyRecord from '../views/applyRecord.vue'
import quickSend from '../views/quickSend.vue' import quickSend from '../views/quickSend.vue'
import addressBook from '../views/addressBook.vue' import addressBook from '../views/addressBook.vue'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import store from '@/store'
Vue.use(VueRouter) Vue.use(VueRouter)
import { getParams } from '@/utils/index' import { getParams } from '@/utils/index'
const routes = [ const routes = [
...@@ -84,7 +85,7 @@ router.beforeEach((to, from, next) => { ...@@ -84,7 +85,7 @@ router.beforeEach((to, from, next) => {
const token = Cookies.get('token') const token = Cookies.get('token')
const urlParams = getParams(); const urlParams = getParams();
if (needAuth) { if (needAuth) {
if (wecomUserId && token) { if (wecomUserId && token && store.state.user.external_userid) {
// 登录信息齐全,允许进入 // 登录信息齐全,允许进入
next() next()
} else { } else {
......
...@@ -27,7 +27,7 @@ const state = { ...@@ -27,7 +27,7 @@ const state = {
time:'' time:''
}, },
weixin_blongs_id_list:[], weixin_blongs_id_list:[],
external_userid:Cookies.get('external_userid') external_userid:''
// 六子的 用户id wm5rUgMgAAjqjOcqp8i3lEhFZDQieWug // 六子的 用户id wm5rUgMgAAjqjOcqp8i3lEhFZDQieWug
// 我的 userid JinDuoXia cser_id 4090 corp_id wweaefe716636df3d1 cser_id 4090 token token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9. eyJpc3MiOjQwOTAsImlhdCI6MTc0NzgxMjMxMiwiZXhwIjoxNzQ4NDE3MTEyLCJuYmYiOjE3NDc4MTIzMTIsInN1YiI6InRva2Vu6K6k6K-BIiwianRpIjoiMjBkOTY3MDZiYzI1MDdmY2MxOWI2MjU1YTM0YWQ3M2YifQ.yX7E7QHV7x2ubpa8iK3Avy794EiHNCaW2CtB4A4UQWo // 我的 userid JinDuoXia cser_id 4090 corp_id wweaefe716636df3d1 cser_id 4090 token token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9. eyJpc3MiOjQwOTAsImlhdCI6MTc0NzgxMjMxMiwiZXhwIjoxNzQ4NDE3MTEyLCJuYmYiOjE3NDc4MTIzMTIsInN1YiI6InRva2Vu6K6k6K-BIiwianRpIjoiMjBkOTY3MDZiYzI1MDdmY2MxOWI2MjU1YTM0YWQ3M2YifQ.yX7E7QHV7x2ubpa8iK3Avy794EiHNCaW2CtB4A4UQWo
} }
......
// UnifiedLogin.vue // UnifiedLogin.vue
<template> <template>
<div class="loginContent"> <div class="loginContent">
<div> <div v-if="!token">
<div> <div>
当前组织:<span class="current-org">{{ currentOrg.name }}</span> 当前组织:<span class="current-org">{{ currentOrg.name }}</span>
<el-button type="text" @click="showOrgDialog = true">切换组织</el-button> <el-button type="text" @click="showOrgDialog = true">切换组织</el-button>
...@@ -70,17 +70,19 @@ export default { ...@@ -70,17 +70,19 @@ export default {
qrLoading: false, // 控制二维码 loading qrLoading: false, // 控制二维码 loading
redirectUri: process.env.NODE_ENV === 'production' ? 'https://companywx.zwnet.cn/api/api/sidebar_login/ding' : 'https://companywx.zwwlkj03.top/api/api/sidebar_login/ding', redirectUri: process.env.NODE_ENV === 'production' ? 'https://companywx.zwnet.cn/api/api/sidebar_login/ding' : 'https://companywx.zwwlkj03.top/api/api/sidebar_login/ding',
DDTestUrl:'', DDTestUrl:'',
token:getToken()
} }
}, },
async mounted() { async mounted() {
await this.initOrganization(); await this.initOrganization();
const urlParams = getParams(); const urlParams = getParams();
const userid = Cookies.get('userid')
console.log(urlParams,'mounted')
// 如果是钉钉扫码回调页面 // 如果是钉钉扫码回调页面
if ( urlParams.type && urlParams.type === 'ding') {// 钉钉回调 if ( urlParams.type && urlParams.type === 'ding') {// 钉钉回调
this.handleDingCallback(); this.handleDingCallback();
}else{ }else if(this.token){ // 已经钉钉扫码过 重新获取授权 获取签名 注册企微js-sdk
await this.getSignature();
}else {
if(!userid){ //没有企微授权过 并且 钉钉扫码成功 开始微信授权 if(!userid){ //没有企微授权过 并且 钉钉扫码成功 开始微信授权
await this.startWeComSilentAuth(); await this.startWeComSilentAuth();
}else{ }else{
...@@ -97,7 +99,7 @@ export default { ...@@ -97,7 +99,7 @@ export default {
...mapState('user',['corp_id']) ...mapState('user',['corp_id'])
}, },
methods: { methods: {
...mapMutations('user',['set_corp_id','set_userid','set_userInfo','set_token','set_cser_info','set_signData','set_cser_id','set_cser_name']), ...mapMutations('user',['set_corp_id','set_userid','set_userInfo','set_token','set_cser_info','set_signData','set_cser_id','set_cser_name','set_external_userid']),
// 设置缓存 // 设置缓存
cacheCorp_id(corp_id){ cacheCorp_id(corp_id){
Cookies.set('corp_id',corp_id, { expires: 7 }) Cookies.set('corp_id',corp_id, { expires: 7 })
...@@ -167,6 +169,21 @@ export default { ...@@ -167,6 +169,21 @@ export default {
window.location.href = window.location.origin +'/company_app/index.html?corp_id='+corp_id+'&msg=signerror' window.location.href = window.location.origin +'/company_app/index.html?corp_id='+corp_id+'&msg=signerror'
} }
}, },
getCurExternalContact() {
ww.getCurExternalContact({
success: (res) => {
if (res.err_msg === "getCurExternalContact:ok") {
console.log(res,'重新进入获取企微外部联系人')
this.set_external_userid(res.userId)
this.$router.push('/userInfo')
}
},
fail: (err) => {
console.log(err,'获取企微外部联系人失败')
// 错误处理
}
});
},
// 2. 注册企微JS-SDK // 2. 注册企微JS-SDK
registerWeComSDK() { registerWeComSDK() {
console.log('删除企业签名',1231) console.log('删除企业签名',1231)
...@@ -188,7 +205,7 @@ export default { ...@@ -188,7 +205,7 @@ export default {
onAgentConfigSuccess: (res) => { onAgentConfigSuccess: (res) => {
console.log('注册成功可以调用企微 js-sdk',res) console.log('注册成功可以调用企微 js-sdk',res)
// 注册成功后不立即获取外部联系人,等钉钉扫码后再获取 // 注册成功后不立即获取外部联系人,等钉钉扫码后再获取
this.$router.push('/') this.getCurExternalContact()
}, },
onAgentConfigFail: (err) => { onAgentConfigFail: (err) => {
console.log('注册失败不能使用企微js-sdk',err) console.log('注册失败不能使用企微js-sdk',err)
......
...@@ -53,11 +53,10 @@ export default { ...@@ -53,11 +53,10 @@ export default {
}, },
methods:{ methods:{
...mapMutations('game',['set_chatUserInfo']), ...mapMutations('game',['set_chatUserInfo']),
...mapMutations('user',['set_userid','set_corp_id','set_external_userid','set_token','set_cser_info','set_cser_id','set_cser_name']), ...mapMutations('user',['set_userid','set_corp_id','set_token','set_cser_info','set_cser_id','set_cser_name']),
initVuexValue(){ initVuexValue(){
this.set_userid(Cookies.get('userid')) this.set_userid(Cookies.get('userid'))
this.set_corp_id(Cookies.get('corp_id')) this.set_corp_id(Cookies.get('corp_id'))
this.set_external_userid(Cookies.get('external_userid'))
this.set_token(Cookies.get('token')) this.set_token(Cookies.get('token'))
this.set_cser_id(Cookies.get('cser_id')) this.set_cser_id(Cookies.get('cser_id'))
this.set_cser_name(Cookies.get('cser_name')) this.set_cser_name(Cookies.get('cser_name'))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论