Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzuaa
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzuaa
提交
34658fa5
提交
34658fa5
编写于
9月 09, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
651e5b5a
a3ea0706
变更
7
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
196 行增加
和
209 行删除
+196
-209
dingdingRedirect.html
app_web/public/assets/dingdingRedirect.html
+24
-17
qqRedirect.html
app_web/public/assets/qqRedirect.html
+27
-20
weixinRedirect.html
app_web/public/assets/weixinRedirect.html
+30
-18
dingdingLoginRedirect.vue
app_web/src/components/login/dingdingLoginRedirect.vue
+31
-42
login.vue
app_web/src/components/login/login.vue
+11
-14
qqLoginRedirect.vue
app_web/src/components/login/qqLoginRedirect.vue
+36
-53
weixinLoginRedirect.vue
app_web/src/components/login/weixinLoginRedirect.vue
+37
-45
未找到文件。
app_web/public/assets/dingdingRedirect.html
浏览文件 @
34658fa5
...
...
@@ -10,22 +10,20 @@
<script
src=
"https://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js"
></script>
<script>
/**
* 初始化
*/
$
(
function
()
{
var
code
=
getUrlParam
(
'code'
);
var
state
=
getUrlParam
(
'state'
);
// alert("code:" + code + "\n state:" + state);
if
(
code
&&
state
)
{
// 通过授权code请求后台
var
opt
=
{
"code"
:
code
,
"state"
:
state
};
$
.
ajax
({
type
:
"
pos
t"
,
url
:
"../uaa/
queryDingtalkUserByCode"
,
type
:
"
ge
t"
,
url
:
"../uaa/
open/dingtalk/sns/"
+
code
+
"?state="
+
state
,
dataType
:
"json"
,
data
:
JSON
.
stringify
(
opt
),
contentType
:
'application/json'
,
success
:
function
(
data
)
{
// console.log(JSON.stringify(data));
if
(
data
)
{
if
(
data
.
openid
)
{
localStorage
.
setItem
(
'openid'
,
data
.
openid
);
...
...
@@ -33,17 +31,17 @@
if
(
data
.
nickname
)
{
localStorage
.
setItem
(
'nickname'
,
data
.
nickname
);
}
if
(
data
.
unionid
)
{
localStorage
.
setItem
(
'unionid'
,
data
.
unionid
);
}
if
(
data
.
token
)
{
localStorage
.
setItem
(
'token'
,
data
.
token
);
}
if
(
data
.
user
)
{
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
data
.
user
));
}
if
(
data
.
ibzuser
)
{
var
ibzuser
=
data
.
ibzuser
;
localStorage
.
setItem
(
'ibzuser'
,
JSON
.
stringify
(
ibzuser
));
// 设置cookie,保存账号密码7天
setCookie
(
ibzuser
.
loginname
,
ibzuser
.
password
,
7
);
var
user
=
data
.
user
;
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
user
));
// 设置cookie,保存账号7天
setCookie
(
"loginname"
,
ibzuser
.
loginname
,
7
);
// 跳转首页
window
.
location
.
href
=
"../index"
;
}
else
{
...
...
@@ -65,7 +63,11 @@
});
// 获取url中的参数
/**
* 获取url中的参数
* @param name
* @returns {*}
*/
function
getUrlParam
(
name
)
{
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
//构造一个含有目标参数的正则表达式对象
var
r
=
window
.
location
.
search
.
substr
(
1
).
match
(
reg
);
//匹配目标参数
...
...
@@ -73,7 +75,12 @@
return
null
;
//返回参数值
}
// 设置Cookie
/**
* 设置Cookie
* @param name
* @param value
* @param day
*/
function
setCookie
(
name
,
value
,
day
)
{
if
(
day
!==
0
)
{
//当设置的时间等于0时,不设置expires属性,cookie在浏览器关闭后删除
var
curDate
=
new
Date
();
...
...
@@ -83,7 +90,7 @@
var
leftTamp
=
24
*
60
*
60
*
1000
-
passedTamp
;
var
leftTime
=
new
Date
();
leftTime
.
setTime
(
leftTamp
+
curTamp
);
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
();
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
()
+
";path=/"
;
}
else
{
document
.
cookie
=
name
+
"="
+
escape
(
value
);
}
...
...
app_web/public/assets/qqRedirect.html
浏览文件 @
34658fa5
...
...
@@ -10,44 +10,42 @@
<script
src=
"https://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js"
></script>
<script>
/**
* 初始化
*/
$
(
function
()
{
var
code
=
getUrlParam
(
'code'
);
var
state
=
getUrlParam
(
'state'
);
// alert("code:" + code + "\n state:" + state);
if
(
code
&&
state
)
{
// 通过授权code请求后台
var
opt
=
{
"code"
:
code
,
"state"
:
state
};
$
.
ajax
({
type
:
"
pos
t"
,
url
:
"../uaa/
queryQQUserByCode"
,
type
:
"
ge
t"
,
url
:
"../uaa/
open/qq/sns/"
+
code
+
"?state"
+
state
,
dataType
:
"json"
,
data
:
JSON
.
stringify
(
opt
),
contentType
:
'application/json'
,
success
:
function
(
data
)
{
// console.log(JSON.stringify(data));
if
(
data
)
{
if
(
data
.
openid
)
{
localStorage
.
setItem
(
'openid'
,
data
.
openid
);
}
if
(
data
.
nickname
)
{
localStorage
.
setItem
(
'nickname'
,
data
.
nickname
);
if
(
data
.
access_token
)
{
localStorage
.
setItem
(
'access_token'
,
data
.
access_token
);
}
if
(
data
.
refresh_token
)
{
localStorage
.
setItem
(
'refresh_token'
,
data
.
refresh_token
);
}
if
(
data
.
token
)
{
localStorage
.
setItem
(
'token'
,
data
.
token
);
}
if
(
data
.
user
)
{
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
data
.
user
));
}
if
(
data
.
ibzuser
)
{
var
ibzuser
=
data
.
ibzuser
;
localStorage
.
setItem
(
'ibzuser'
,
JSON
.
stringify
(
ibzuser
));
// 设置cookie,保存账号密码7天
setCookie
(
ibzuser
.
loginname
,
ibzuser
.
password
,
7
);
var
user
=
data
.
user
;
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
user
));
// 设置cookie,保存账号7天
setCookie
(
"loginname"
,
user
.
loginname
,
7
);
// 跳转首页
window
.
location
.
href
=
"../index"
;
}
else
{
// 跳转
微信
绑定
// 跳转
qq
绑定
window
.
location
.
href
=
"../#/qqLoginRedirect?code="
+
code
+
"&state="
+
state
;
}
}
...
...
@@ -65,7 +63,11 @@
});
// 获取url中的参数
/**
* 获取url中的参数
* @param name
* @returns {*}
*/
function
getUrlParam
(
name
)
{
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
//构造一个含有目标参数的正则表达式对象
var
r
=
window
.
location
.
search
.
substr
(
1
).
match
(
reg
);
//匹配目标参数
...
...
@@ -73,7 +75,12 @@
return
null
;
//返回参数值
}
// 设置Cookie
/**
* 设置Cookie
* @param name
* @param value
* @param day
*/
function
setCookie
(
name
,
value
,
day
)
{
if
(
day
!==
0
)
{
//当设置的时间等于0时,不设置expires属性,cookie在浏览器关闭后删除
var
curDate
=
new
Date
();
...
...
@@ -83,7 +90,7 @@
var
leftTamp
=
24
*
60
*
60
*
1000
-
passedTamp
;
var
leftTime
=
new
Date
();
leftTime
.
setTime
(
leftTamp
+
curTamp
);
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
();
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
()
+
";path=/"
;
}
else
{
document
.
cookie
=
name
+
"="
+
escape
(
value
);
}
...
...
app_web/public/assets/weixinRedirect.html
浏览文件 @
34658fa5
...
...
@@ -10,39 +10,41 @@
<script
src=
"https://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js"
></script>
<script>
/**
* 初始化
*/
$
(
function
()
{
var
code
=
getUrlParam
(
'code'
);
var
state
=
getUrlParam
(
'state'
);
// alert("code:" + code + "\n state:" + state);
if
(
code
&&
state
)
{
// 通过授权code请求后台
var
opt
=
{
"code"
:
code
,
"state"
:
state
};
$
.
ajax
({
type
:
"
pos
t"
,
url
:
"../uaa/
queryWechatUserByCode"
,
type
:
"
ge
t"
,
url
:
"../uaa/
open/wechat/sns/"
+
code
+
"?state="
+
state
,
dataType
:
"json"
,
data
:
JSON
.
stringify
(
opt
),
contentType
:
'application/json'
,
success
:
function
(
data
)
{
if
(
data
)
{
if
(
data
.
openid
)
{
localStorage
.
setItem
(
'openid'
,
data
.
openid
);
}
if
(
data
.
nickname
)
{
localStorage
.
setItem
(
'nickname'
,
data
.
nickname
);
if
(
data
.
access_token
)
{
localStorage
.
setItem
(
'access_token'
,
data
.
access_token
);
}
if
(
data
.
refresh_token
)
{
localStorage
.
setItem
(
'refresh_token'
,
data
.
refresh_token
);
}
if
(
data
.
unionid
)
{
localStorage
.
setItem
(
'unionid'
,
data
.
unionid
);
}
if
(
data
.
token
)
{
localStorage
.
setItem
(
'token'
,
data
.
token
);
}
if
(
data
.
user
)
{
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
data
.
user
));
}
if
(
data
.
ibzuser
)
{
var
ibzuser
=
data
.
ibzuser
;
localStorage
.
setItem
(
'ibzuser'
,
JSON
.
stringify
(
ibzuser
));
// 设置cookie,保存账号密码7天
setCookie
(
ibzuser
.
loginname
,
ibzuser
.
password
,
7
);
var
user
=
data
.
user
;
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
user
));
// 设置cookie,保存账号7天
setCookie
(
"loginname"
,
user
.
loginname
,
7
);
// 跳转首页
window
.
location
.
href
=
"../index"
;
}
else
{
...
...
@@ -64,7 +66,11 @@
});
// 获取url中的参数
/**
* 回去url中的参数
* @param name
* @returns {*}
*/
function
getUrlParam
(
name
)
{
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
//构造一个含有目标参数的正则表达式对象
var
r
=
window
.
location
.
search
.
substr
(
1
).
match
(
reg
);
//匹配目标参数
...
...
@@ -72,7 +78,12 @@
return
null
;
//返回参数值
}
// 设置Cookie
/**
* 设置Cookie
* @param name
* @param value
* @param day
*/
function
setCookie
(
name
,
value
,
day
)
{
if
(
day
!==
0
)
{
//当设置的时间等于0时,不设置expires属性,cookie在浏览器关闭后删除
var
curDate
=
new
Date
();
...
...
@@ -82,11 +93,12 @@
var
leftTamp
=
24
*
60
*
60
*
1000
-
passedTamp
;
var
leftTime
=
new
Date
();
leftTime
.
setTime
(
leftTamp
+
curTamp
);
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
();
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
()
+
";path=/"
;
}
else
{
document
.
cookie
=
name
+
"="
+
escape
(
value
);
}
}
</script>
</head>
...
...
app_web/src/components/login/dingdingLoginRedirect.vue
浏览文件 @
34658fa5
...
...
@@ -62,37 +62,25 @@
})
export
default
class
dingdingLoginRedirect
extends
Vue
{
/**
* 表单对象
*
* @type {*}
* @memberof Register
*/
// 表单
public
form
:
any
=
{
loginname
:
''
,
password
:
''
};
/**
* 按钮可点击
*/
// 按钮可点击
public
canClick
:
any
=
true
;
/**
* 按钮内容
*/
// 按钮内容
public
BtnContent
:
any
=
"注册并绑定钉钉"
;
/**
* 钉钉授权成功返回的code和state
*/
// 钉钉授权成功返回的code和state
public
code
:
any
;
public
state
:
any
;
/**
* 钉钉用户身份的唯一标识
*/
public
openid
:
any
;
/**
* 钉钉用户名称
*/
public
nickname
:
any
;
public
dingtalkUserInfo
:
any
=
{
openid
:
''
,
// 钉钉用户身份的唯一标识
nickname
:
''
,
// 钉钉用户名称
unionid
:
''
,
// 钉钉用户唯一标识
}
/**
* 应用名称
...
...
@@ -139,7 +127,6 @@
* 挂载
*/
public
mounted
()
{
// 从url获取授权code和state
this
.
code
=
this
.
$route
.
query
.
code
;
if
(
!
this
.
code
)
{
...
...
@@ -155,12 +142,15 @@
this
.
goLogin
();
}
else
{
// 从local中获取
该用户的openid和nickname
// 从local中获取
钉钉用户的openid,可用于后续请求及绑定操作
if
(
localStorage
.
getItem
(
"openid"
))
{
this
.
openid
=
localStorage
.
getItem
(
"openid"
);
this
.
dingtalkUserInfo
.
openid
=
localStorage
.
getItem
(
"openid"
);
}
if
(
localStorage
.
getItem
(
"nickname"
))
{
this
.
nickname
=
localStorage
.
getItem
(
"nickname"
);
this
.
dingtalkUserInfo
.
nickname
=
localStorage
.
getItem
(
"nickname"
);
}
if
(
localStorage
.
getItem
(
"unionid"
))
{
this
.
dingtalkUserInfo
.
unionid
=
localStorage
.
getItem
(
"unionid"
);
}
}
...
...
@@ -190,6 +180,7 @@
/**
* 获取url参数
* @param name
*/
public
getUrlParam
(
name
:
any
)
{
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
//构造一个含有目标参数的正则表达式对象
...
...
@@ -216,18 +207,17 @@
if
(
!
validatestate
)
{
return
;
}
// 请求传参
var
param
:
any
=
this
.
form
;
if
(
this
.
code
&&
this
.
state
)
{
param
.
openid
=
this
.
openid
;
param
.
nickname
=
this
.
nickname
;
param
.
openid
=
this
.
dingtalkUserInfo
.
openid
;
param
.
nickname
=
this
.
dingtalkUserInfo
.
nickname
;
}
else
{
this
.
$message
.
error
(
"钉钉授权,获取code失败"
);
return
;
}
const
post
:
Promise
<
any
>
=
this
.
$http
.
post
(
'/uaa/
bindDingtalkToRegister
'
,
param
,
true
);
// post请求绑定钉钉
const
post
:
Promise
<
any
>
=
this
.
$http
.
post
(
'/uaa/
open/dingtalk/bind
'
,
param
,
true
);
post
.
then
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
const
data
=
response
.
data
;
...
...
@@ -239,13 +229,10 @@
localStorage
.
setItem
(
'token'
,
data
.
token
);
}
if
(
data
.
user
)
{
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
data
.
user
));
}
if
(
data
.
ibzuser
)
{
let
ibzuser
:
any
=
data
.
ibzuser
;
localStorage
.
setItem
(
'ibzuser'
,
JSON
.
stringify
(
ibzuser
));
// 设置cookie,保存账号密码7天
this
.
setCookie
(
ibzuser
.
loginname
,
ibzuser
.
password
,
7
);
let
user
:
any
=
data
.
user
;
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
user
));
// 设置cookie,保存账号7天
this
.
setCookie
(
"loginname"
,
user
.
loginname
,
7
);
// 跳转首页
const
url
:
any
=
'*'
;
this
.
$router
.
push
({
path
:
url
});
...
...
@@ -273,9 +260,11 @@
}
/**
* 设置cookie
* 设置Cookie
* @param name
* @param value
* @param day
*/
public
setCookie
(
name
:
any
,
value
:
any
,
day
:
any
)
{
if
(
day
!==
0
)
{
//当设置的时间等于0时,不设置expires属性,cookie在浏览器关闭后删除
...
...
@@ -286,7 +275,7 @@
var
leftTamp
=
24
*
60
*
60
*
1000
-
passedTamp
;
var
leftTime
=
new
Date
();
leftTime
.
setTime
(
leftTamp
+
curTamp
);
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
();
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
()
+
";path=/"
;
}
else
{
document
.
cookie
=
name
+
"="
+
escape
(
value
);
}
...
...
app_web/src/components/login/login.vue
浏览文件 @
34658fa5
...
...
@@ -89,7 +89,7 @@
* @type {*}
* @memberof Login
*/
public
form
:
any
=
{
loginname
:
'
guest
'
,
password
:
'123456'
};
public
form
:
any
=
{
loginname
:
'
ibzadmin
'
,
password
:
'123456'
};
/**
...
...
@@ -134,17 +134,14 @@
}
public
mounted
()
{
if
(
this
.
getCookie
(
"loginname"
)
&&
this
.
getCookie
(
"loginname"
)
!==
'undefined'
&&
this
.
getCookie
(
"password"
)
&&
this
.
getCookie
(
"password"
)
!==
'undefined'
)
{
if
(
this
.
getCookie
(
"loginname"
)
&&
this
.
getCookie
(
"loginname"
)
!==
'undefined'
)
{
this
.
form
.
loginname
=
this
.
getCookie
(
"loginname"
);
this
.
form
.
password
=
this
.
getCookie
(
"password"
);
}
else
{
if
(
localStorage
.
getItem
(
"ibzuser"
))
{
const
ibzuser
:
any
=
localStorage
.
getItem
(
"ibzuser"
);
if
(
ibzuser
)
{
const
ibzuserObj
:
any
=
JSON
.
parse
(
ibzuser
);
this
.
form
.
loginname
=
ibzuserObj
.
loginname
;
this
.
form
.
password
=
ibzuserObj
.
password
;
if
(
localStorage
.
getItem
(
"user"
))
{
const
user
:
any
=
localStorage
.
getItem
(
"user"
);
if
(
user
)
{
const
userObj
:
any
=
JSON
.
parse
(
user
);
this
.
form
.
loginname
=
userObj
.
loginname
;
}
}
}
...
...
@@ -245,7 +242,7 @@
var
leftTamp
=
24
*
60
*
60
*
1000
-
passedTamp
;
var
leftTime
=
new
Date
();
leftTime
.
setTime
(
leftTamp
+
curTamp
);
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
();
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
()
+
";path=/"
;
}
else
{
document
.
cookie
=
name
+
"="
+
escape
(
value
);
}
...
...
@@ -272,7 +269,7 @@
const
baseUrl
=
this
.
getNeedLocation
();
// 从后台获取qq互联创建的网站应用appid
const
get
:
Promise
<
any
>
=
this
.
$http
.
get
(
'/uaa/
getQQAppI
d'
);
const
get
:
Promise
<
any
>
=
this
.
$http
.
get
(
'/uaa/
open/qq/appi
d'
);
get
.
then
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
const
data
=
response
.
data
;
...
...
@@ -326,7 +323,7 @@
*/
public
wechatHandleClick
(
thirdpart
:
any
)
{
// 从后台获取微信开放平台提供的appid
const
get
:
Promise
<
any
>
=
this
.
$http
.
get
(
'/uaa/
getWechatAppI
d'
);
const
get
:
Promise
<
any
>
=
this
.
$http
.
get
(
'/uaa/
open/wechat/appi
d'
);
get
.
then
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
const
data
=
response
.
data
;
...
...
@@ -381,7 +378,7 @@
*/
public
dingtalkHandleClick
(
thirdpart
:
any
)
{
// 从后台获取钉钉开放平台提供的appid
const
get
:
Promise
<
any
>
=
this
.
$http
.
get
(
'/uaa/
getDingtalkAppI
d'
);
const
get
:
Promise
<
any
>
=
this
.
$http
.
get
(
'/uaa/
open/dingtalk/appi
d'
);
get
.
then
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
const
data
=
response
.
data
;
...
...
app_web/src/components/login/qqLoginRedirect.vue
浏览文件 @
34658fa5
...
...
@@ -62,41 +62,22 @@
})
export
default
class
qqLoginRedirect
extends
Vue
{
/**
* 表单对象
*
* @type {*}
* @memberof Register
*/
// 表单
public
form
:
any
=
{
loginname
:
''
,
password
:
''
};
/**
* 按钮可点击
*/
// 按钮可点击
public
canClick
:
any
=
true
;
/**
* 按钮内容
*/
// 按钮内容
public
BtnContent
:
any
=
"注册并绑定QQ"
;
/**
* QQ授权成功返回的code和state
*/
// qq授权成功后返回的code和state
public
code
:
any
;
public
state
:
any
;
/**
* QQ用户身份的唯一标识
*/
public
openid
:
any
;
/**
* QQ用户名称
*/
public
nickname
:
any
;
// qq用户信息
public
qqUserInfo
:
any
=
{
openid
:
''
,
//QQ用户身份的唯一标识
nickname
:
''
,
// QQ用户名称
access_token
:
''
,
// 临时授权token
refresh_token
:
''
,
// 刷新授权token
}
/**
* 应用名称
...
...
@@ -144,7 +125,6 @@
* 挂载
*/
public
mounted
()
{
// 从url获取授权code和state
this
.
code
=
this
.
$route
.
query
.
code
;
if
(
!
this
.
code
)
{
...
...
@@ -154,18 +134,20 @@
if
(
!
this
.
state
)
{
this
.
state
=
this
.
getUrlParam
(
'state'
);
}
// 获取
失败,回到登录页
// 获取
授权code和state失败,回到登录页重新授权
if
(
!
this
.
code
||
!
this
.
state
)
{
this
.
$message
.
error
(
"QQ授权,获取code失败"
);
this
.
goLogin
();
}
else
{
// 从local中获取该用户的openid和nickname
}
else
{
// 从local中获取qq用户的授权openid,可用于后续请求及绑定操作
if
(
localStorage
.
getItem
(
"openid"
))
{
this
.
openid
=
localStorage
.
getItem
(
"openid"
);
this
.
qqUserInfo
.
openid
=
localStorage
.
getItem
(
"openid"
);
}
if
(
localStorage
.
getItem
(
"nickname"
))
{
this
.
nickname
=
localStorage
.
getItem
(
"nickname"
);
if
(
localStorage
.
getItem
(
"access_token"
))
{
this
.
qqUserInfo
.
access_token
=
localStorage
.
getItem
(
"access_token"
);
}
if
(
localStorage
.
getItem
(
"refresh_token"
))
{
this
.
qqUserInfo
.
refresh_token
=
localStorage
.
getItem
(
"refresh_token"
);
}
}
...
...
@@ -195,6 +177,7 @@
/**
* 获取url参数
* @param name
*/
public
getUrlParam
(
name
:
any
)
{
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
//构造一个含有目标参数的正则表达式对象
...
...
@@ -220,20 +203,19 @@
if
(
!
validatestate
)
{
return
;
}
// 请求参数
var
param
:
any
=
this
.
form
;
if
(
this
.
code
&&
this
.
state
)
{
param
.
code
=
this
.
code
;
param
.
state
=
this
.
state
;
param
.
openid
=
this
.
openid
;
param
.
nickname
=
this
.
nickname
;
}
else
{
param
.
openid
=
this
.
qqUserInfo
.
openid
;
param
.
nickname
=
this
.
qqUserInfo
.
nickname
;
}
else
{
this
.
$message
.
error
(
"QQ授权,获取code失败"
);
return
;
}
const
post
:
Promise
<
any
>
=
this
.
$http
.
post
(
'/uaa/
bindQQtoRegister
'
,
param
,
true
);
// post请求绑定qq
const
post
:
Promise
<
any
>
=
this
.
$http
.
post
(
'/uaa/
open/qq/bind
'
,
param
,
true
);
post
.
then
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
const
data
=
response
.
data
;
...
...
@@ -245,13 +227,10 @@
localStorage
.
setItem
(
'token'
,
data
.
token
);
}
if
(
data
.
user
)
{
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
data
.
user
));
}
if
(
data
.
ibzuser
)
{
let
ibzuser
:
any
=
data
.
ibzuser
;
localStorage
.
setItem
(
'ibzuser'
,
JSON
.
stringify
(
ibzuser
));
const
user
:
any
=
data
.
user
;
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
user
));
// 设置cookie,保存账号密码7天
this
.
setCookie
(
ibzuser
.
loginname
,
ibzuser
.
password
,
7
);
this
.
setCookie
(
"loginname"
,
user
.
loginname
,
7
);
// 跳转首页
const
url
:
any
=
'*'
;
this
.
$router
.
push
({
path
:
url
});
...
...
@@ -278,8 +257,12 @@
});
}
/**
* 设置cookie
* 设置Cookie
* @param name
* @param value
* @param day
*/
public
setCookie
(
name
:
any
,
value
:
any
,
day
:
any
)
{
if
(
day
!==
0
)
{
//当设置的时间等于0时,不设置expires属性,cookie在浏览器关闭后删除
...
...
@@ -290,7 +273,7 @@
var
leftTamp
=
24
*
60
*
60
*
1000
-
passedTamp
;
var
leftTime
=
new
Date
();
leftTime
.
setTime
(
leftTamp
+
curTamp
);
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
();
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
()
+
";path=/"
;
}
else
{
document
.
cookie
=
name
+
"="
+
escape
(
value
);
}
...
...
app_web/src/components/login/weixinLoginRedirect.vue
浏览文件 @
34658fa5
...
...
@@ -62,39 +62,25 @@
})
export
default
class
weixinLoginRedirect
extends
Vue
{
/**
* 表单对象
*
* @type {*}
* @memberof Register
*/
// 表单
public
form
:
any
=
{
loginname
:
''
,
password
:
''
};
/**
* 按钮可点击
*/
// 表单可点击
public
canClick
:
any
=
true
;
/**
* 按钮内容
*/
// 按钮内容
public
BtnContent
:
any
=
"注册并绑定微信"
;
/**
* 微信授权成功返回的code和state
*/
// 微信授权成功返回的code和state
public
code
:
any
;
public
state
:
any
;
/**
* 微信用户身份的唯一标识
*/
public
openid
:
any
;
/**
* 微信用户名称
*/
public
nickname
:
any
;
// 微信用户信息
public
wechatUserInfo
:
any
=
{
openid
:
''
,
//微信用户身份的唯一标识
nickname
:
''
,
//微信用户名称
access_token
:
''
,
// 临时授权token
refresh_token
:
''
,
// 刷新授权token
unionid
:
''
,
//微信用户唯一标识
}
/**
* 应用名称
...
...
@@ -141,7 +127,6 @@
* 挂载
*/
public
mounted
()
{
// 从url获取授权code和state
this
.
code
=
this
.
$route
.
query
.
code
;
if
(
!
this
.
code
)
{
...
...
@@ -157,12 +142,18 @@
this
.
goLogin
();
}
else
{
// 从local中获取
该用户的openid和nickname
// 从local中获取
微信用户的openid,可用于后续请求及绑定操作
if
(
localStorage
.
getItem
(
"openid"
))
{
this
.
openid
=
localStorage
.
getItem
(
"openid"
);
this
.
wechatUserInfo
.
openid
=
localStorage
.
getItem
(
"openid"
);
}
if
(
localStorage
.
getItem
(
"nickname"
))
{
this
.
nickname
=
localStorage
.
getItem
(
"nickname"
);
if
(
localStorage
.
getItem
(
"access_token"
))
{
this
.
wechatUserInfo
.
access_token
=
localStorage
.
getItem
(
"access_token"
);
}
if
(
localStorage
.
getItem
(
"refresh_token"
))
{
this
.
wechatUserInfo
.
refresh_token
=
localStorage
.
getItem
(
"refresh_token"
);
}
if
(
localStorage
.
getItem
(
"unionid"
))
{
this
.
wechatUserInfo
.
unionid
=
localStorage
.
getItem
(
"unionid"
);
}
}
...
...
@@ -191,6 +182,7 @@
/**
* 获取url参数
* @param name
*/
public
getUrlParam
(
name
:
any
)
{
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
//构造一个含有目标参数的正则表达式对象
...
...
@@ -216,20 +208,19 @@
if
(
!
validatestate
)
{
return
;
}
// 请求传参
var
param
:
any
=
this
.
form
;
if
(
this
.
code
&&
this
.
state
)
{
param
.
code
=
this
.
code
;
param
.
state
=
this
.
state
;
param
.
openid
=
this
.
openid
;
param
.
nickname
=
this
.
nickname
;
param
.
openid
=
this
.
wechatUserInfo
.
openid
;
param
.
nickname
=
this
.
wechatUserInfo
.
nickname
;
}
else
{
this
.
$message
.
error
(
"微信授权,获取code失败"
);
return
;
}
const
post
:
Promise
<
any
>
=
this
.
$http
.
post
(
'/uaa/
bindWechatToRegister
'
,
param
,
true
);
// post请求绑定微信
const
post
:
Promise
<
any
>
=
this
.
$http
.
post
(
'/uaa/
open/wechat/bind
'
,
param
,
true
);
post
.
then
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
const
data
=
response
.
data
;
...
...
@@ -241,13 +232,10 @@
localStorage
.
setItem
(
'token'
,
data
.
token
);
}
if
(
data
.
user
)
{
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
data
.
user
));
}
if
(
data
.
ibzuser
)
{
let
ibzuser
:
any
=
data
.
ibzuser
;
localStorage
.
setItem
(
'ibzuser'
,
JSON
.
stringify
(
ibzuser
));
// 设置cookie,保存账号密码7天
this
.
setCookie
(
ibzuser
.
loginname
,
ibzuser
.
password
,
7
);
let
user
:
any
=
data
.
user
;
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
user
));
// 设置cookie,保存账号7天
this
.
setCookie
(
"loginname"
,
user
.
loginname
,
7
);
// 跳转首页
const
url
:
any
=
'*'
;
this
.
$router
.
push
({
path
:
url
});
...
...
@@ -274,8 +262,12 @@
});
}
/**
* 设置cookie
* 设置Cookie
* @param name
* @param value
* @param day
*/
public
setCookie
(
name
:
any
,
value
:
any
,
day
:
any
)
{
if
(
day
!==
0
)
{
//当设置的时间等于0时,不设置expires属性,cookie在浏览器关闭后删除
...
...
@@ -286,7 +278,7 @@
var
leftTamp
=
24
*
60
*
60
*
1000
-
passedTamp
;
var
leftTime
=
new
Date
();
leftTime
.
setTime
(
leftTamp
+
curTamp
);
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
();
document
.
cookie
=
name
+
"="
+
escape
(
value
)
+
";expires="
+
leftTime
.
toUTCString
()
+
";path=/"
;
}
else
{
document
.
cookie
=
name
+
"="
+
escape
(
value
);
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录