Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
company_app
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
毛细亚
company_app
Commits
4ec437f6
提交
4ec437f6
authored
5月 24, 2025
作者:
毛细亚
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新代码
上级
0756ad59
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
12 行增加
和
11 行删除
+12
-11
index.js
src/router/index.js
+3
-1
login.vue
src/views/login.vue
+9
-10
没有找到文件。
src/router/index.js
浏览文件 @
4ec437f6
...
...
@@ -78,9 +78,11 @@ router.beforeEach((to, from, next) => {
const
wecomUserId
=
Cookies
.
get
(
'userid'
)
const
cser_id
=
Cookies
.
get
(
'cser_id'
)
const
token
=
Cookies
.
get
(
'token'
)
const
external_userid
=
Cookies
.
get
(
'external_userid'
)
const
urlParams
=
getParams
();
console
.
log
(
urlParams
,
'urlParams'
)
if
(
needAuth
)
{
if
(
wecomUserId
&&
cser_id
&&
token
)
{
if
(
wecomUserId
&&
token
&&
external_userid
)
{
// 登录信息齐全,允许进入
next
()
}
else
{
...
...
src/views/login.vue
浏览文件 @
4ec437f6
...
...
@@ -52,7 +52,7 @@
<
script
>
import
*
as
ww
from
'@wecom/jssdk'
import
{
getOrganization
,
getAuthUser
,
get
DingLogin
,
get
Signature
}
from
'@/api/user'
import
{
getOrganization
,
getAuthUser
,
getSignature
}
from
'@/api/user'
import
Cookies
from
'js-cookie'
import
{
getParams
}
from
'@/utils/index'
import
{
mapMutations
,
mapState
}
from
'vuex'
...
...
@@ -79,20 +79,17 @@ export default {
async
mounted
()
{
await
this
.
initOrganization
();
const
urlParams
=
getParams
();
const
token
=
getToken
()
const
userid
=
Cookies
.
get
(
'userid'
)
console
.
log
(
urlParams
,
'mounted'
)
// 如果是钉钉扫码回调页面
if
(
urlParams
.
type
&&
urlParams
.
type
===
'ding'
)
{
// 钉钉回调
this
.
handleDingCallback
();
if
(
!
userid
&&
token
){
//没有企微授权过 并且 钉钉扫码成功 开始微信授权
}
else
{
if
(
!
userid
){
//没有企微授权过 并且 钉钉扫码成功 开始微信授权
await
this
.
startWeComSilentAuth
();
}
else
{
this
.
initDingTalkLogin
();
// 始化钉钉扫码
}
}
else
{
this
.
initDingTalkLogin
();
// 始化钉钉扫码
}
// 每次进入页面都缓存corp_id
...
...
@@ -151,8 +148,6 @@ export default {
if
(
res
.
status_code
===
1
)
{
this
.
cacheWx_userinfo
(
res
.
data
)
this
.
cacheuserid
(
res
.
data
.
userid
)
// 获取签名
await
this
.
getSignature
();
}
else
{
console
.
log
(
'获取useid失败'
,
res
)
// 错误处理
...
...
@@ -194,6 +189,7 @@ export default {
onAgentConfigSuccess
:
(
res
)
=>
{
console
.
log
(
'注册成功可以调用企微 js-sdk'
,
res
)
// 注册成功后不立即获取外部联系人,等钉钉扫码后再获取
this
.
getCurExternalContact
()
},
onAgentConfigFail
:
(
err
)
=>
{
console
.
log
(
'注册失败不能使用企微js-sdk'
,
err
)
...
...
@@ -207,7 +203,6 @@ export default {
async
initOrganization
()
{
const
res
=
await
getOrganization
();
if
(
res
.
data
.
status_code
===
1
)
{
console
.
log
(
3333
)
this
.
orgList
=
res
.
data
.
data
.
data
;
// 默认组织逻辑:可根据业务自定义
this
.
initCurrentApp
();
...
...
@@ -250,6 +245,7 @@ export default {
window
.
attachEvent
(
'onmessage'
,
this
.
handleDingTalkLogin
)
}
},
// https://companywx.jianshuwenhua.com/company_app/login?code=success&cser_id=4090&cser_name=%E6%AF%9B%E7%BB%86%E4%BA%9A&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOjQwOTAsImRhdGEiOnsiY3Nlcl9pZCI6NDA5MCwiY3Nlcl9uYW1lIjoi5q-b57uG5LqaIn0sImlhdCI6MTc0Nzk5MDM0MiwiZXhwIjoxNzUwNTgyMzQyLCJuYmYiOjE3NDc5OTAzNDIsInN1YiI6InRva2Vu6K6k6K-BIiwianRpIjoiYzYzYTM4NGYzMTFmODVlMGQ2Nzg2ZmJiMTdhNjQzN2EifQ.5ADPtqISjxOqbrDOzlKkCpfTr78Sv0Sdi-_Y1RRiMH0&type=ding
// 5. 切换组织
switchOrg
(
org
)
{
...
...
@@ -271,11 +267,12 @@ export default {
const
url
=
`https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=
${
appid
}
&response_type=code&scope=snsapi_login&state=
${
state
}
&redirect_uri=
${
this
.
redirectUri
}
&loginTmpCode=
${
loginTmpCode
}
`
;
console
.
log
(
url
,
'回调 url'
)
this
.
DDTestUrl
=
url
//
window.location.href = url;
window
.
location
.
href
=
url
;
},
// 7. 钉钉扫码回调页面处理
async
handleDingCallback
()
{
// 在这里处理钉钉扫码成功的回调
console
.
log
(
'扫码成功'
)
const
ddParams
=
getParams
();
const
corp_id
=
Cookies
.
get
(
'corp_id'
)
if
(
ddParams
.
code
==
'error'
&&
ddParams
.
msg
){
...
...
@@ -285,6 +282,8 @@ export default {
if
(
ddParams
.
token
&&
ddParams
.
token
!=
'undefined'
){
setToken
(
ddParams
.
token
)
this
.
set_token
(
ddParams
.
token
)
// 获取签名
await
this
.
getSignature
();
}
else
{
console
.
log
(
'没有token'
)
window
.
location
.
href
=
window
.
location
.
origin
+
'/company_app/index.html?corp_id='
+
corp_id
+
'&msg=notoken'
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论