Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
company_app
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
毛细亚
company_app
Commits
876aa800
提交
876aa800
authored
6月 04, 2025
作者:
毛细亚
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加开发模式
上级
4a0b775b
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
489 行增加
和
162 行删除
+489
-162
main.js
src/main.js
+3
-11
devMode.js
src/utils/devMode.js
+175
-0
vconsoleCleanup.js
src/utils/vconsoleCleanup.js
+130
-0
login.vue
src/views/login.vue
+181
-151
没有找到文件。
src/main.js
浏览文件 @
876aa800
...
...
@@ -11,7 +11,7 @@ import 'lib-flexible/flexible.js'
// import '@/styles/element-theme-colors.css';
import
'@/styles/index.scss'
;
import
moment
from
'moment'
import
VConsole
from
'vconsole'
;
// import VConsole from 'vconsole'; // 注释掉,使用 devMode.js 统一管理
// import 'bi-element-ui/lib/bi-element-ui.css'
import
Element
from
'bi-eleme'
// import 'bi-eleme/lib/theme-chalk/index.css'
...
...
@@ -19,16 +19,8 @@ import BiElementUi from 'bi-element-ui'
// import 'bi-element-ui/lib/bi-element-ui.css'
import
uploading
from
'@/utils/cos-upload'
import
'element-ui/lib/theme-chalk/index.css'
;
import
{
getParams
}
from
'@/utils/index'
if
(
process
.
env
.
NODE_ENV
!==
'production'
){
new
VConsole
();
}
const
urlParams
=
getParams
();
if
(
urlParams
.
corp_id
===
'wwfd5c6c0e0db795b4'
||
Cookies
.
get
(
'corp_id'
)
===
'wwfd5c6c0e0db795b4'
){
console
.
log
(
urlParams
,
'urlParams'
)
new
VConsole
();
}
// 导入 VConsole 清理工具
import
'@/utils/vconsoleCleanup'
// 测试一下
Vue
.
use
(
uploading
)
...
...
src/utils/devMode.js
0 → 100644
浏览文件 @
876aa800
import
VConsole
from
'vconsole'
class
DevModeManager
{
constructor
()
{
this
.
vConsole
=
null
this
.
clickCount
=
0
this
.
clickTimer
=
null
this
.
maxClicks
=
7
// 连续点击7次开启
this
.
resetTime
=
3000
// 3秒内无点击则重置
this
.
isDevMode
=
this
.
getDevModeFromStorage
()
// 自动初始化逻辑
this
.
autoInit
()
}
// 自动初始化逻辑
autoInit
()
{
const
isDevEnv
=
process
.
env
.
NODE_ENV
!==
'production'
// 如果是开发环境或特定公司ID,或者之前开启过开发模式,则自动启用
if
(
isDevEnv
||
this
.
isDevMode
)
{
this
.
enableDevMode
()
}
}
// 从 localStorage 获取开发模式状态
getDevModeFromStorage
()
{
try
{
return
localStorage
.
getItem
(
'dev_mode_enabled'
)
===
'true'
}
catch
(
error
)
{
console
.
warn
(
'无法读取开发模式状态:'
,
error
)
return
false
}
}
// 保存开发模式状态到 localStorage
saveDevModeToStorage
(
enabled
)
{
try
{
localStorage
.
setItem
(
'dev_mode_enabled'
,
enabled
.
toString
())
}
catch
(
error
)
{
console
.
warn
(
'无法保存开发模式状态:'
,
error
)
}
}
// 处理点击事件
handleClick
()
{
this
.
clickCount
++
console
.
log
(
`开发模式激活进度:
${
this
.
clickCount
}
/
${
this
.
maxClicks
}
`
)
// 清除之前的定时器
if
(
this
.
clickTimer
)
{
clearTimeout
(
this
.
clickTimer
)
}
// 如果达到指定次数,切换开发模式
if
(
this
.
clickCount
>=
this
.
maxClicks
)
{
this
.
toggleDevMode
()
this
.
resetClickCount
()
return
}
// 设置重置定时器
this
.
clickTimer
=
setTimeout
(()
=>
{
if
(
this
.
clickCount
>
0
)
{
console
.
log
(
'开发模式激活超时,重置计数'
)
this
.
resetClickCount
()
}
},
this
.
resetTime
)
}
// 重置点击计数
resetClickCount
()
{
this
.
clickCount
=
0
if
(
this
.
clickTimer
)
{
clearTimeout
(
this
.
clickTimer
)
this
.
clickTimer
=
null
}
}
// 切换开发模式
toggleDevMode
()
{
if
(
this
.
isDevMode
)
{
this
.
disableDevMode
()
}
else
{
this
.
enableDevMode
()
}
}
// 开启开发模式
enableDevMode
()
{
try
{
// 防止重复初始化
if
(
!
this
.
vConsole
)
{
this
.
vConsole
=
new
VConsole
()
console
.
log
(
'🎉 开发模式已开启!'
)
console
.
log
(
'💡 提示:再次连续点击7次可关闭开发模式'
)
}
else
{
console
.
log
(
'📱 开发模式已经处于开启状态'
)
}
this
.
isDevMode
=
true
this
.
saveDevModeToStorage
(
true
)
}
catch
(
error
)
{
console
.
error
(
'开启开发模式失败:'
,
error
)
this
.
vConsole
=
null
this
.
isDevMode
=
false
}
}
// 关闭开发模式
disableDevMode
()
{
try
{
if
(
this
.
vConsole
)
{
this
.
vConsole
.
destroy
()
this
.
vConsole
=
null
console
.
log
(
'👋 开发模式已关闭!'
)
}
this
.
isDevMode
=
false
this
.
saveDevModeToStorage
(
false
)
}
catch
(
error
)
{
console
.
error
(
'关闭开发模式失败:'
,
error
)
// 强制重置状态
this
.
vConsole
=
null
this
.
isDevMode
=
false
}
}
// 检查是否为开发环境
isDevEnvironment
()
{
return
process
.
env
.
NODE_ENV
===
'development'
}
// 获取当前开发模式状态
getDevModeStatus
()
{
return
{
enabled
:
this
.
isDevMode
,
environment
:
process
.
env
.
NODE_ENV
,
clickCount
:
this
.
clickCount
,
maxClicks
:
this
.
maxClicks
,
hasVConsole
:
!!
this
.
vConsole
}
}
// 安全销毁方法
destroy
()
{
this
.
resetClickCount
()
this
.
disableDevMode
()
}
}
// 创建全局实例
const
devModeManager
=
new
DevModeManager
()
// 添加到 window 对象,方便控制台操作
if
(
typeof
window
!==
'undefined'
)
{
window
.
devMode
=
{
toggle
:
()
=>
devModeManager
.
toggleDevMode
(),
enable
:
()
=>
devModeManager
.
enableDevMode
(),
disable
:
()
=>
devModeManager
.
disableDevMode
(),
status
:
()
=>
devModeManager
.
getDevModeStatus
(),
reset
:
()
=>
devModeManager
.
resetClickCount
(),
destroy
:
()
=>
devModeManager
.
destroy
()
}
// 监听页面卸载,清理资源
window
.
addEventListener
(
'beforeunload'
,
()
=>
{
try
{
devModeManager
.
destroy
()
}
catch
(
error
)
{
console
.
warn
(
'清理开发模式资源时出错:'
,
error
)
}
})
}
export
default
devModeManager
\ No newline at end of file
src/utils/vconsoleCleanup.js
0 → 100644
浏览文件 @
876aa800
// VConsole 清理工具
// 用于清理可能存在的重复实例和状态问题
const
VConsoleCleanup
=
{
// 清理所有可能的 VConsole 实例
cleanup
()
{
try
{
// 清理全局 VConsole 引用
if
(
window
.
VConsole
)
{
delete
window
.
VConsole
}
// 清理可能存在的 vConsole 实例
if
(
window
.
vConsole
&&
typeof
window
.
vConsole
.
destroy
===
'function'
)
{
window
.
vConsole
.
destroy
()
delete
window
.
vConsole
}
// 清理 DOM 中的 VConsole 元素
const
vcElements
=
document
.
querySelectorAll
(
'[class*="vc-"], [id*="__vconsole"]'
)
vcElements
.
forEach
(
el
=>
{
try
{
el
.
remove
()
}
catch
(
e
)
{
console
.
warn
(
'移除 VConsole 元素失败:'
,
e
)
}
})
// 清理可能的事件监听器
this
.
removeEventListeners
()
// 清理 localStorage 中的 VConsole 相关数据
this
.
cleanupStorage
()
console
.
log
(
'✅ VConsole 清理完成'
)
}
catch
(
error
)
{
console
.
error
(
'❌ VConsole 清理过程中出错:'
,
error
)
}
},
// 移除可能的事件监听器
removeEventListeners
()
{
try
{
// VConsole 常用的事件类型
const
eventTypes
=
[
'resize'
,
'orientationchange'
,
'scroll'
,
'touchstart'
,
'touchmove'
,
'touchend'
]
// 移除可能由 VConsole 添加的事件监听器(这里只能尝试移除一些通用的)
eventTypes
.
forEach
(
type
=>
{
// 注意:这里无法准确移除所有 VConsole 的监听器,只是一个清理尝试
document
.
removeEventListener
(
type
,
this
.
dummyHandler
,
true
)
window
.
removeEventListener
(
type
,
this
.
dummyHandler
,
true
)
})
}
catch
(
error
)
{
console
.
warn
(
'清理事件监听器时出错:'
,
error
)
}
},
// 空的事件处理器
dummyHandler
()
{},
// 清理存储
cleanupStorage
()
{
try
{
const
keysToRemove
=
[]
// 检查 localStorage 中是否有 VConsole 相关的键
for
(
let
i
=
0
;
i
<
localStorage
.
length
;
i
++
)
{
const
key
=
localStorage
.
key
(
i
)
if
(
key
&&
(
key
.
includes
(
'vconsole'
)
||
key
.
includes
(
'vConsole'
)))
{
keysToRemove
.
push
(
key
)
}
}
// 移除找到的键(保留我们自定义的 dev_mode_enabled)
keysToRemove
.
forEach
(
key
=>
{
if
(
key
!==
'dev_mode_enabled'
)
{
localStorage
.
removeItem
(
key
)
}
})
}
catch
(
error
)
{
console
.
warn
(
'清理存储时出错:'
,
error
)
}
},
// 检查当前状态
checkStatus
()
{
const
status
=
{
hasWindowVConsole
:
!!
window
.
VConsole
,
hasWindowVconsole
:
!!
window
.
vConsole
,
vcElements
:
document
.
querySelectorAll
(
'[class*="vc-"], [id*="__vconsole"]'
).
length
,
devModeStatus
:
window
.
devMode
?
window
.
devMode
.
status
()
:
null
}
console
.
table
(
status
)
return
status
},
// 强制重启开发模式
forceRestart
()
{
try
{
this
.
cleanup
()
// 等待清理完成后重新启动
setTimeout
(()
=>
{
if
(
window
.
devMode
)
{
window
.
devMode
.
enable
()
console
.
log
(
'🔄 开发模式已重新启动'
)
}
},
500
)
}
catch
(
error
)
{
console
.
error
(
'强制重启失败:'
,
error
)
}
}
}
// 添加到全局,方便控制台调用
if
(
typeof
window
!==
'undefined'
)
{
window
.
VConsoleCleanup
=
VConsoleCleanup
// 在控制台提供快捷命令
window
.
cleanVConsole
=
()
=>
VConsoleCleanup
.
cleanup
()
window
.
checkVConsole
=
()
=>
VConsoleCleanup
.
checkStatus
()
window
.
restartVConsole
=
()
=>
VConsoleCleanup
.
forceRestart
()
}
export
default
VConsoleCleanup
\ No newline at end of file
src/views/login.vue
浏览文件 @
876aa800
...
...
@@ -6,38 +6,32 @@
当前组织:
<span
class=
"current-org"
>
{{
currentOrg
.
name
}}
</span>
<el-button
type=
"text"
@
click=
"showOrgDialog = true"
>
切换组织
</el-button>
</div>
<div
class=
"qr-contain"
>
<div
id=
"dingTalkLoginContainer"
>
<div
class=
"qr-contain"
>
<div
id=
"dingTalkLoginContainer"
>
</div>
<div
class=
"refresh"
>
<i
class=
"el-icon-refresh-right "
@
click=
"refreshDingTalkQRCode"
></i>
<i
class=
"el-icon-refresh-right "
@
click=
"refreshDingTalkQRCode"
></i>
</div>
<!-- 生二维码的时候加一个 loading -->
<div
class=
"loading"
v-if=
"qrLoading"
>
<span
class=
"loading-spinner"
></span>
</div>
</div>
<!-- 开发模式触发区域 - 隐藏的点击区域 -->
<div
class=
"dev-mode-trigger"
@
click=
"handleDevModeClick"
title=
"开发模式触发区域"
></div>
<!-- 组织切换弹窗 -->
<el-dialog
:visible
.
sync=
"showOrgDialog"
width=
"300px"
title=
"选择组织"
>
<el-dialog
:visible
.
sync=
"showOrgDialog"
width=
"300px"
title=
"选择组织"
>
<ul
style=
"list-style:none;padding:0;margin-top: -20px;"
>
<li
v-for=
"org in orgList"
:key=
"org.app_key"
@
click=
"switchOrg(org)"
:style=
"
{
padding: '8px 16px',
cursor: 'pointer',
background: org.app_key === currentOrg.app_key ? '#e6f7ff' : '',
color: org.app_key === currentOrg.app_key ? '#1890ff' : '',
fontWeight: org.app_key === currentOrg.app_key ? 'bold' : 'normal',
borderRadius: '4px',
marginBottom: '4px',
transition: 'background 0.2s'
}"
@mouseover="hoveredOrg = org.app_key"
@mouseleave="hoveredOrg = null"
>
<li
v-for=
"org in orgList"
:key=
"org.app_key"
@
click=
"switchOrg(org)"
:style=
"
{
padding: '8px 16px',
cursor: 'pointer',
background: org.app_key === currentOrg.app_key ? '#e6f7ff' : '',
color: org.app_key === currentOrg.app_key ? '#1890ff' : '',
fontWeight: org.app_key === currentOrg.app_key ? 'bold' : 'normal',
borderRadius: '4px',
marginBottom: '4px',
transition: 'background 0.2s'
}" @mouseover="hoveredOrg = org.app_key" @mouseleave="hoveredOrg = null">
{{
org
.
name
}}
<span
v-if=
"org.app_key === currentOrg.app_key"
style=
"margin-left:8px;"
>
(当前)
</span>
</li>
...
...
@@ -49,12 +43,13 @@
<
script
>
import
*
as
ww
from
'@wecom/jssdk'
import
{
getOrganization
,
getAuthUser
,
getSignature
}
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'
import
{
getToken
,
setToken
}
from
'@/utils/auth'
import
{
mapMutations
,
mapState
}
from
'vuex'
import
{
getToken
,
setToken
}
from
'@/utils/auth'
import
jsApiList
from
'@/utils/jsApiList'
import
devModeManager
from
'@/utils/devMode'
export
default
{
data
()
{
return
{
...
...
@@ -63,75 +58,81 @@ export default {
signData
:
null
,
// 企微签名数据
orgList
:
[],
organizationNum
:
5
,
urlParams
:{},
urlParams
:
{},
currentOrg
:
{},
showOrgDialog
:
false
,
hoveredOrg
:
null
,
showRefresh
:
false
,
// 控制刷新按钮显示
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'
,
DDTestUrl
:
''
,
token
:
getToken
()
DDTestUrl
:
''
,
token
:
getToken
()
}
},
},
async
mounted
()
{
console
.
log
(
1231321321
,
'1231321321'
)
console
.
log
(
1231321321
,
'1231321321'
)
this
.
$nextTick
(()
=>
{
this
.
initLogin
()
})
},
computed
:{
...
mapState
(
'user'
,[
'corp_id'
])
computed
:
{
...
mapState
(
'user'
,
[
'corp_id'
])
},
methods
:
{
...
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'
]),
async
initLogin
(){
...
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'
]),
async
initLogin
()
{
await
this
.
initOrganization
();
const
urlParams
=
getParams
();
const
userid
=
Cookies
.
get
(
'userid'
);
// 每次进入页面都缓存corp_id
if
(
urlParams
.
corp_id
)
{
this
.
cacheCorp_id
(
urlParams
.
corp_id
)
// 缓存 corp_id
}
// 如果是钉钉扫码回调页面
if
(
urlParams
.
type
&&
urlParams
.
type
===
'ding'
)
{
// 钉钉回调
if
(
urlParams
.
type
&&
urlParams
.
type
===
'ding'
)
{
// 钉钉回调
console
.
log
(
1
)
this
.
handleDingCallback
();
}
else
if
(
this
.
token
)
{
// 已经钉钉扫码过 重新获取授权 获取签名 注册企微js-sdk
}
else
if
(
this
.
token
)
{
// 已经钉钉扫码过 重新获取授权 获取签名 注册企微js-sdk
console
.
log
(
2
)
await
this
.
getSignature
();
}
else
{
await
this
.
getSignature
();
}
else
{
console
.
log
(
3
)
if
(
!
userid
)
{
//没有企微授权过 并且 钉钉扫码成功 开始微信授权
if
(
!
userid
)
{
//没有企微授权过 并且 钉钉扫码成功 开始微信授权
console
.
log
(
4
)
await
this
.
startWeComSilentAuth
();
}
else
{
}
else
{
console
.
log
(
5
)
this
.
initDingTalkLogin
();
// 始化钉钉扫码
}
}
// 每次进入页面都缓存corp_id
if
(
urlParams
.
corp_id
){
this
.
cacheCorp_id
(
urlParams
.
corp_id
)
// 缓存 corp_id
}
},
// 处理开发模式点击
handleDevModeClick
()
{
devModeManager
.
handleClick
()
},
// 设置缓存
cacheCorp_id
(
corp_id
){
Cookies
.
set
(
'corp_id'
,
corp_id
,
{
expires
:
7
})
cacheCorp_id
(
corp_id
)
{
Cookies
.
set
(
'corp_id'
,
corp_id
,
{
expires
:
7
})
this
.
set_corp_id
(
corp_id
)
},
cacheuserid
(
userid
){
Cookies
.
set
(
'userid'
,
userid
,
{
expires
:
7
})
cacheuserid
(
userid
)
{
Cookies
.
set
(
'userid'
,
userid
,
{
expires
:
7
})
this
.
set_userid
(
userid
)
},
cacheCser
(
cser_id
,
cser_name
)
{
Cookies
.
set
(
'cser_id'
,
cser_id
,
{
expires
:
7
})
Cookies
.
set
(
'cser_name'
,
cser_name
,
{
expires
:
7
})
cacheCser
(
cser_id
,
cser_name
)
{
Cookies
.
set
(
'cser_id'
,
cser_id
,
{
expires
:
7
})
Cookies
.
set
(
'cser_name'
,
cser_name
,
{
expires
:
7
})
this
.
set_cser_info
({
cser_id
:
cser_id
,
cser_name
:
cser_name
cser_id
:
cser_id
,
cser_name
:
cser_name
})
this
.
set_cser_id
(
cser_id
)
this
.
set_cser_name
(
cser_name
)
},
cacheSignData
(
signData
){
Cookies
.
set
(
'signData'
,
JSON
.
stringify
(
signData
),
{
expires
:
7
})
cacheSignData
(
signData
)
{
Cookies
.
set
(
'signData'
,
JSON
.
stringify
(
signData
),
{
expires
:
7
})
this
.
set_signData
(
signData
)
},
// 进入的页面地址是 https://companywx.jianshuwenhua.com/company_app/index.html?corp_id=wweaefe716636df3d1
...
...
@@ -139,7 +140,7 @@ export default {
async
startWeComSilentAuth
()
{
this
.
urlParams
=
getParams
();
const
corp_id
=
this
.
urlParams
.
corp_id
if
(
!
corp_id
)
{
if
(
!
corp_id
)
{
this
.
$message
.
error
(
'当前客服号信息异常,请切换会话后重试'
)
return
}
...
...
@@ -152,82 +153,82 @@ export default {
return
;
}
// 用code
const
res
=
await
getAuthUser
({
code
:
this
.
urlParams
.
code
,
url
:
window
.
location
.
href
,
corp_id
:
corp_id
});
const
res
=
await
getAuthUser
({
code
:
this
.
urlParams
.
code
,
url
:
window
.
location
.
href
,
corp_id
:
corp_id
});
if
(
res
.
status_code
===
1
)
{
this
.
cacheuserid
(
res
.
data
.
userid
)
this
.
initDingTalkLogin
();
// 初始化钉钉扫码
}
else
{
console
.
log
(
'获取useid失败'
,
res
)
console
.
log
(
'获取useid失败'
,
res
)
// 错误处理
}
},
async
getSignature
(){
console
.
log
(
'获取签名'
,
window
.
location
.
href
)
async
getSignature
()
{
console
.
log
(
'获取签名'
,
window
.
location
.
href
)
const
corp_id
=
Cookies
.
get
(
'corp_id'
)
try
{
try
{
const
res
=
await
getSignature
({
corp_id
:
corp_id
,
path
:
window
.
location
.
href
});
if
(
res
.
status_code
===
1
)
{
if
(
res
.
status_code
===
1
)
{
this
.
signData
=
res
.
data
this
.
cacheSignData
(
res
.
data
)
try
{
try
{
this
.
registerWeComSDK
();
}
catch
(
err
)
{
console
.
log
(
err
,
'初始化sdk 失败'
)
}
catch
(
err
)
{
console
.
log
(
err
,
'初始化sdk 失败'
)
}
}
}
catch
(
err
)
{
console
.
log
(
err
,
'获取签名失败'
)
window
.
location
.
href
=
window
.
location
.
origin
+
'/company_app/index.html?corp_id='
+
corp_id
+
'&msg=signerror'
}
catch
(
err
)
{
console
.
log
(
err
,
'获取签名失败'
)
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
,
'重新进入获取企微外部联系人'
)
console
.
log
(
res
,
'重新进入获取企微外部联系人'
)
this
.
set_external_userid
(
res
.
userId
)
// 确保 Vuex 状态更新后再跳转
this
.
$nextTick
(()
=>
{
this
.
$router
.
replace
(
'/'
)
console
.
log
(
window
.
location
.
href
,
'window.location.hrefuserInfo'
)
this
.
$router
.
replace
(
'/'
)
console
.
log
(
window
.
location
.
href
,
'window.location.hrefuserInfo'
)
})
}
},
fail
:
(
err
)
=>
{
console
.
log
(
err
,
'获取企微外部联系人失败'
)
console
.
log
(
err
,
'获取企微外部联系人失败'
)
// 错误处理
}
});
},
// 2. 注册企微JS-SDK
registerWeComSDK
()
{
console
.
log
(
'删除企业签名'
,
1231
)
ww
.
register
({
corpId
:
Cookies
.
get
(
'corp_id'
),
agentId
:
this
.
signData
.
agent_id
,
jsApiList
:
jsApiList
,
// getConfigSignature: () => Promise.resolve({
// nonceStr: this.signData.nonce_str,
// timestamp: this.signData.signature_time,
// signature: this.signData.corp_signature,
// }),
// 只用到应用的 api 可以只进行应用的签名
getAgentConfigSignature
:
()
=>
Promise
.
resolve
({
nonceStr
:
this
.
signData
.
nonce_str
,
timestamp
:
this
.
signData
.
signature_time
,
signature
:
this
.
signData
.
agent_signature
,
}),
onAgentConfigSuccess
:
(
res
)
=>
{
console
.
log
(
'注册成功可以调用企微 js-sdk'
,
res
)
// 注册成功后不立即获取外部联系人,等钉钉扫码后再获取
this
.
getCurExternalContact
()
},
onAgentConfigFail
:
(
err
)
=>
{
console
.
log
(
'注册失败不能使用企微js-sdk'
,
err
)
// 错误处理123
}
});
console
.
log
(
'删除企业签名'
,
1231
)
ww
.
register
({
corpId
:
Cookies
.
get
(
'corp_id'
),
agentId
:
this
.
signData
.
agent_id
,
jsApiList
:
jsApiList
,
// getConfigSignature: () => Promise.resolve({
// nonceStr: this.signData.nonce_str,
// timestamp: this.signData.signature_time,
// signature: this.signData.corp_signature,
// }),
// 只用到应用的 api 可以只进行应用的签名
getAgentConfigSignature
:
()
=>
Promise
.
resolve
({
nonceStr
:
this
.
signData
.
nonce_str
,
timestamp
:
this
.
signData
.
signature_time
,
signature
:
this
.
signData
.
agent_signature
,
}),
onAgentConfigSuccess
:
(
res
)
=>
{
console
.
log
(
'注册成功可以调用企微 js-sdk'
,
res
)
// 注册成功后不立即获取外部联系人,等钉钉扫码后再获取
this
.
getCurExternalContact
()
},
onAgentConfigFail
:
(
err
)
=>
{
console
.
log
(
'注册失败不能使用企微js-sdk'
,
err
)
// 错误处理123
}
});
},
// 3. 获取组织列表并选取默认组织
...
...
@@ -249,7 +250,7 @@ export default {
// 4. 初始化钉钉扫码
initDingTalkLogin
()
{
this
.
qrLoading
=
true
;
console
.
log
(
'进入初始化钉钉'
,
this
.
currentOrg
)
console
.
log
(
'进入初始化钉钉'
,
this
.
currentOrg
)
if
(
!
this
.
currentOrg
.
app_key
)
return
;
const
appid
=
this
.
currentOrg
.
app_key
;
// 清空二维码容器,防止切换组织后二维码不刷新
...
...
@@ -296,7 +297,7 @@ export default {
const
appid
=
this
.
currentOrg
.
app_key
;
const
state
=
encodeURIComponent
(
`
${
this
.
currentOrg
.
app_key
}
$
${
this
.
currentOrg
.
template_code
}
$
${
corp_id
}
$
${
userid
}
`
)
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'
)
console
.
log
(
url
,
'回调 url'
)
this
.
DDTestUrl
=
url
window
.
location
.
href
=
url
;
},
...
...
@@ -306,32 +307,32 @@ export default {
console
.
log
(
'扫码成功'
)
const
ddParams
=
getParams
();
const
corp_id
=
Cookies
.
get
(
'corp_id'
)
if
(
ddParams
.
code
==
'error'
&&
ddParams
.
msg
)
{
if
(
ddParams
.
code
==
'error'
&&
ddParams
.
msg
)
{
this
.
$message
.
error
(
ddParams
.
msg
)
setTimeout
(()
=>
{
window
.
location
.
href
=
window
.
location
.
origin
+
'/company_app/index.html?corp_id='
+
corp_id
+
'&msg=error'
window
.
location
.
href
=
window
.
location
.
origin
+
'/company_app/index.html?corp_id='
+
corp_id
+
'&msg=error'
},
5000
)
return
}
if
(
ddParams
.
token
&&
ddParams
.
token
!=
'undefined'
)
{
if
(
ddParams
.
token
&&
ddParams
.
token
!=
'undefined'
)
{
setToken
(
ddParams
.
token
)
this
.
set_token
(
ddParams
.
token
)
// 获取签名
await
this
.
getSignature
();
}
else
{
}
else
{
console
.
log
(
'没有token'
)
window
.
location
.
href
=
window
.
location
.
origin
+
'/company_app/index.html?corp_id='
+
corp_id
+
'&msg=notoken'
window
.
location
.
href
=
window
.
location
.
origin
+
'/company_app/index.html?corp_id='
+
corp_id
+
'&msg=notoken'
}
if
(
ddParams
.
cser_id
)
{
this
.
cacheCser
(
ddParams
.
cser_id
,
ddParams
.
cser_name
)
if
(
ddParams
.
cser_id
)
{
this
.
cacheCser
(
ddParams
.
cser_id
,
ddParams
.
cser_name
)
}
},
refreshDingTalkQRCode
()
{
this
.
initDingTalkLogin
();
},
},
}
</
script
>
...
...
@@ -342,51 +343,72 @@ export default {
margin-right
:
5px
;
}
.loginContent
{
.loginContent
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
justify-content
:
center
;
}
/* 开发模式触发区域 */
.dev-mode-trigger
{
position
:
absolute
;
top
:
5px
;
right
:
5px
;
width
:
50px
;
height
:
50px
;
background
:
transparent
;
cursor
:
pointer
;
z-index
:
999
;
user-select
:
none
;
}
/* 开发环境下显示边框提示 */
.dev-mode-trigger
:hover
{
background
:
rgba
(
0
,
191
,
138
,
0.1
);
border-radius
:
4px
;
}
.qr-contain
{
margin
:
0
auto
;
/* margin-top: 20px; */
width
:
260px
;
height
:
260px
;
position
:
relative
;
overflow
:
hidden
;
#dingTalkLoginContainer
{
padding
:
15px
;
position
:
absolute
;
left
:
10px
;
bottom
:
0
;
}
.refresh
{
display
:
none
;
text-align
:
center
;
position
:
absolute
;
width
:
40px
;
background
:
#fff
;
height
:
40px
;
transform
:
translate
(
-50%
,
-50%
);
left
:
50%
;
top
:
50%
;
i
{
line-height
:
40px
;
font-size
:
26px
;
color
:
#3491FA
;
cursor
:
pointer
;
}
}
margin
:
0
auto
;
/* margin-top: 20px; */
width
:
260px
;
height
:
260px
;
position
:
relative
;
overflow
:
hidden
;
&
:hover
{
.refresh
{
display
:
block
;
}
}
}
#dingTalkLoginContainer
{
padding
:
15px
;
position
:
absolute
;
left
:
10px
;
bottom
:
0
;
}
.refresh
{
display
:
none
;
text-align
:
center
;
position
:
absolute
;
width
:
40px
;
background
:
#fff
;
height
:
40px
;
transform
:
translate
(
-50%
,
-50%
);
left
:
50%
;
top
:
50%
;
i
{
line-height
:
40px
;
font-size
:
26px
;
color
:
#3491FA
;
cursor
:
pointer
;
}
}
&
:hover
{
.refresh
{
display
:
block
;
}
}
}
.loading
{
position
:
absolute
;
...
...
@@ -394,23 +416,30 @@ export default {
top
:
0
;
width
:
100%
;
height
:
100%
;
background
:
rgba
(
255
,
255
,
255
,
0.7
);
background
:
rgba
(
255
,
255
,
255
,
0.7
);
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
z-index
:
20
;
transition
:
opacity
0.3s
;
}
.loading-spinner
{
width
:
40px
;
height
:
40px
;
border
:
4px
solid
#e0e0e0
;
border-top
:
4px
solid
#3491FA
;
border-top
:
4px
solid
#3491FA
;
border-radius
:
50%
;
animation
:
spin
1s
linear
infinite
;
}
@keyframes
spin
{
0
%
{
transform
:
rotate
(
0deg
);
}
100
%
{
transform
:
rotate
(
360deg
);
}
0
%
{
transform
:
rotate
(
0deg
);
}
100
%
{
transform
:
rotate
(
360deg
);
}
}
</
style
>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论