Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-Mob-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-Mob-R7-Res
提交
b34e883f
提交
b34e883f
编写于
8月 23, 2020
作者:
KK
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
钉钉认证
上级
a69be6a9
变更
3
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
69 行增加
和
12 行删除
+69
-12
login.vue
src/components/login/login.vue
+45
-2
DingTalkService.ts
src/ibiz-core/third-party-service/DingTalkService.ts
+23
-9
ThirdPartyService.ts
src/ibiz-core/third-party-service/ThirdPartyService.ts
+1
-1
未找到文件。
src/components/login/login.vue
浏览文件 @
b34e883f
<
template
>
<
template
>
<ion-page
:className=
"
{ 'app-login': true }">
<ion-page
:className=
"
{ 'app-login': true }">
<ion-content
fullscreen
>
<ion-content
fullscreen
v-if=
"!platform"
>
<div
class=
"app-login-contant"
>
<div
class=
"app-login-contant"
>
<img
src=
"assets/images/logo.png"
class=
"ibizLogo"
/>
<img
src=
"assets/images/logo.png"
class=
"ibizLogo"
/>
<form
class=
"app-login-form"
>
<form
class=
"app-login-form"
>
...
@@ -30,7 +30,8 @@
...
@@ -30,7 +30,8 @@
import
{
Vue
,
Component
}
from
"vue-property-decorator"
;
import
{
Vue
,
Component
}
from
"vue-property-decorator"
;
import
{
Loading
}
from
'@/ibiz-core/utils'
;
import
{
Loading
}
from
'@/ibiz-core/utils'
;
import
{
Environment
}
from
'@/environments/environment'
;
import
{
Environment
}
from
'@/environments/environment'
;
import
{
ThirdPartyService
}
from
'@ibiz-core'
import
{
DingTalkService
}
from
'../../ibiz-core/third-party-service/DingTalkService'
;
@
Component
({
@
Component
({
components
:
{},
components
:
{},
i18n
:
{
i18n
:
{
...
@@ -53,6 +54,18 @@ import { Environment } from '@/environments/environment';
...
@@ -53,6 +54,18 @@ import { Environment } from '@/environments/environment';
}
}
})
})
export
default
class
Login
extends
Vue
{
export
default
class
Login
extends
Vue
{
/**
* 第三方服务
*
* @type {string}
* @memberof Login
*/
public
thirdPartyService
:
ThirdPartyService
=
ThirdPartyService
.
getInstance
();
public
platform
:
any
=
""
;
/**
/**
* 用户名
* 用户名
*
*
...
@@ -61,6 +74,36 @@ export default class Login extends Vue {
...
@@ -61,6 +74,36 @@ export default class Login extends Vue {
*/
*/
public
username
:
string
=
""
;
public
username
:
string
=
""
;
/**
* 生命周期
*
* @memberof Login
*/
public
created
(){
this
.
platform
=
this
.
thirdPartyService
.
platform
;
if
(
this
.
platform
){
this
.
thirdLogin
();
}
}
/**
* 第三方登录
*
* @type {string}
* @memberof Login
*/
public
async
thirdLogin
(){
let
loginStatus
:
any
=
await
this
.
thirdPartyService
.
login
();
if
(
!
loginStatus
.
issuccess
){
this
.
$notice
.
error
(
loginStatus
.
message
?
loginStatus
.
message
:
"钉钉认证失败,请联系管理员"
);
}
else
{
const
url
:
any
=
this
.
$route
.
query
.
redirect
?
this
.
$route
.
query
.
redirect
:
"*"
;
this
.
$router
.
replace
({
path
:
url
});
this
.
$router
.
go
(
-
1
)
}
}
/**
/**
* 密码
* 密码
*
*
...
...
src/ibiz-core/third-party-service/DingTalkService.ts
浏览文件 @
b34e883f
...
@@ -31,7 +31,7 @@ export class DingTalkService {
...
@@ -31,7 +31,7 @@ export class DingTalkService {
* @type {string}
* @type {string}
* @memberof WeChatService
* @memberof WeChatService
*/
*/
private
readonly
appId
:
string
=
"ding
f89eefecd565b89cbc961a6cb783455b
"
;
private
readonly
appId
:
string
=
"ding
0466097cd833d9f9a1320dcb25e91351
"
;
/**
/**
* 钉钉sdk
* 钉钉sdk
*
*
...
@@ -84,15 +84,28 @@ export class DingTalkService {
...
@@ -84,15 +84,28 @@ export class DingTalkService {
public
async
login
():
Promise
<
any
>
{
public
async
login
():
Promise
<
any
>
{
const
data
=
await
this
.
getUserInfo
();
const
data
=
await
this
.
getUserInfo
();
if
(
!
data
||
!
data
.
value
||
Object
.
is
(
data
.
value
,
''
))
{
if
(
!
data
||
!
data
.
value
||
Object
.
is
(
data
.
value
,
''
))
{
// 获取临时登录授权码
const
access_token
:
any
=
await
this
.
get
(
`/uaa/open/dingtalk/access_token`
);
const
res
:
{
code
:
string
}
=
await
dd
.
runtime
.
permission
.
requestAuthCode
({
corpId
:
this
.
appId
});
if
(
access_token
.
status
==
200
&&
access_token
.
data
&&
access_token
.
data
.
regionid
){
if
(
res
&&
res
.
code
)
{
const
res
:
any
=
await
dd
.
runtime
.
permission
.
requestAuthCode
({
corpId
:
access_token
.
data
.
regionid
});
const
userInfo
=
await
this
.
get
(
`./dingtalk/login?code=
${
res
.
code
}
`
);
if
(
res
&&
res
.
code
)
{
dd
.
util
.
domainStorage
.
setItem
({
name
:
this
.
infoName
,
value
:
userInfo
});
const
userInfo
:
any
=
await
this
.
get
(
`/uaa/open/dingtalk/auth/
${
res
.
code
}
`
);
data
.
value
=
userInfo
;
if
(
userInfo
.
status
==
200
&&
userInfo
.
data
.
token
&&
userInfo
.
data
.
user
){
localStorage
.
setItem
(
"token"
,
userInfo
.
data
.
token
);
localStorage
.
setItem
(
"user"
,
JSON
.
stringify
(
userInfo
.
data
.
user
));
dd
.
util
.
domainStorage
.
setItem
({
name
:
this
.
infoName
,
value
:
userInfo
.
data
});
return
{
issuccess
:
true
,
message
:
""
};
}
else
if
(
userInfo
.
status
==
400
){
return
{
issuccess
:
false
,
message
:
userInfo
.
data
.
message
};
}
else
{
return
{
issuccess
:
false
,
message
:
userInfo
.
data
.
message
};
}
}
else
{
return
{
issuccess
:
false
,
message
:
"钉钉用户信息获取失败"
};
}
}
else
{
return
{
issuccess
:
false
,
message
:
"获取企业id失败"
};
}
}
}
}
return
data
.
value
;
}
}
/**
/**
...
@@ -125,8 +138,9 @@ export class DingTalkService {
...
@@ -125,8 +138,9 @@ export class DingTalkService {
private
async
get
(
url
:
string
):
Promise
<
any
>
{
private
async
get
(
url
:
string
):
Promise
<
any
>
{
return
new
Promise
((
resolve
)
=>
{
return
new
Promise
((
resolve
)
=>
{
axios
.
get
(
url
).
then
((
response
:
any
)
=>
{
axios
.
get
(
url
).
then
((
response
:
any
)
=>
{
resolve
(
response
.
data
);
resolve
(
response
);
}).
catch
((
error
:
any
)
=>
{
}).
catch
((
error
:
any
)
=>
{
resolve
(
error
);
console
.
log
(
'请求异常'
);
console
.
log
(
'请求异常'
);
});
});
})
})
...
...
src/ibiz-core/third-party-service/ThirdPartyService.ts
浏览文件 @
b34e883f
...
@@ -24,7 +24,7 @@ export class ThirdPartyService {
...
@@ -24,7 +24,7 @@ export class ThirdPartyService {
* @type {('WeChat' | 'DingTalk' | null)}
* @type {('WeChat' | 'DingTalk' | null)}
* @memberof ThirdPartyService
* @memberof ThirdPartyService
*/
*/
p
rotected
platform
:
'WeChat'
|
'DingTalk'
|
null
=
null
;
p
ublic
platform
:
'WeChat'
|
'DingTalk'
|
null
=
null
;
/**
/**
* 钉钉服务
* 钉钉服务
*
*
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录