Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Guten-PigxUI
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄卓然
Guten-PigxUI
Commits
28ee8c5b
Commit
28ee8c5b
authored
Nov 18, 2018
by
冷冷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
👽
Updating code due to external API changes.
parent
27de1d55
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
33 deletions
+83
-33
login.js
src/api/login.js
+14
-1
codelogin.vue
src/page/login/codelogin.vue
+34
-21
thirdlogin.vue
src/page/login/thirdlogin.vue
+1
-1
userlogin.vue
src/page/login/userlogin.vue
+22
-0
axios.js
src/router/axios.js
+1
-1
user.js
src/store/modules/user.js
+11
-9
No files found.
src/api/login.js
View file @
28ee8c5b
...
...
@@ -29,10 +29,23 @@ export const loginByUsername = (username, password, code, randomStr) => {
})
}
export
const
loginByMobile
=
(
mobile
,
code
)
=>
{
var
grant_type
=
'mobile'
return
request
({
url
:
'/auth/mobile/token/sms'
,
headers
:
{
'TENANT_ID'
:
'1'
,
'Authorization'
:
'Basic cGlnOnBpZw=='
},
method
:
'post'
,
params
:
{
mobile
:
'SMS@'
+
mobile
,
code
:
code
,
grant_type
}
})
}
export
const
loginBySocial
=
(
state
,
code
)
=>
{
var
grant_type
=
'mobile'
return
request
({
url
:
'/auth/mobile/token'
,
url
:
'/auth/mobile/token
/social
'
,
headers
:
{
'TENANT_ID'
:
'1'
,
'Authorization'
:
'Basic cGlnOnBpZw=='
...
...
src/page/login/codelogin.vue
View file @
28ee8c5b
...
...
@@ -8,7 +8,7 @@
<el-form-item
prop=
"phone"
>
<el-input
size=
"small"
@
keyup
.
enter
.
native=
"handleLogin"
v-model=
"loginForm.
phon
e"
v-model=
"loginForm.
mobil
e"
auto-complete=
"off"
placeholder=
"请输入手机号码"
>
<i
slot=
"prefix"
...
...
@@ -42,11 +42,11 @@
<
script
>
const
MSGINIT
=
"发送验证码"
,
// MSGERROR = "验证码发送失败",
MSGSCUCCESS
=
"${time}秒后重发"
,
MSGTIME
=
60
;
import
{
isvalidatemobile
}
from
"@/util/validate"
;
import
{
mapGetters
}
from
"vuex"
;
import
request
from
'@/router/axios'
export
default
{
name
:
"codelogin"
,
data
()
{
...
...
@@ -69,12 +69,12 @@ export default {
msgTime
:
MSGTIME
,
msgKey
:
false
,
loginForm
:
{
phone
:
"17547400800"
,
code
:
""
mobile
:
''
,
code
:
''
},
loginRules
:
{
phone
:
[{
required
:
true
,
trigger
:
"blur"
,
validator
:
validatePhone
}],
code
:
[{
required
:
true
,
trigger
:
"blur"
,
validator
:
validateCode
}]
mobile
:
[{
required
:
true
,
trigger
:
'blur'
,
validator
:
validatePhone
}],
code
:
[{
required
:
true
,
trigger
:
'blur'
,
validator
:
validateCode
}]
}
};
},
...
...
@@ -85,21 +85,34 @@ export default {
},
props
:
[],
methods
:
{
handleSend
()
{
if
(
this
.
msgKey
)
return
;
this
.
msgText
=
MSGSCUCCESS
.
replace
(
"${time}"
,
this
.
msgTime
);
this
.
msgKey
=
true
;
const
time
=
setInterval
(()
=>
{
this
.
msgTime
--
;
this
.
msgText
=
MSGSCUCCESS
.
replace
(
"${time}"
,
this
.
msgTime
);
if
(
this
.
msgTime
==
0
)
{
this
.
msgTime
=
MSGTIME
;
this
.
msgText
=
MSGINIT
;
this
.
msgKey
=
false
;
clearInterval
(
time
);
}
},
1000
);
},
handleSend
()
{
if
(
this
.
msgKey
)
return
request
({
url
:
'/admin/mobile/'
+
this
.
loginForm
.
mobile
,
method
:
'get'
}).
then
(
response
=>
{
console
.
log
(
response
.
data
.
data
)
if
(
response
.
data
.
data
)
{
this
.
$message
.
success
(
'验证码发送成功'
)
}
else
{
this
.
$message
.
error
(
response
.
data
.
msg
)
}
})
this
.
msgText
=
MSGSCUCCESS
.
replace
(
'${time}'
,
this
.
msgTime
)
this
.
msgKey
=
true
const
time
=
setInterval
(()
=>
{
this
.
msgTime
--
this
.
msgText
=
MSGSCUCCESS
.
replace
(
'${time}'
,
this
.
msgTime
)
if
(
this
.
msgTime
==
0
)
{
this
.
msgTime
=
MSGTIME
this
.
msgText
=
MSGINIT
this
.
msgKey
=
false
clearInterval
(
time
)
}
},
1000
)
},
handleLogin
()
{
this
.
$refs
.
loginForm
.
validate
(
valid
=>
{
if
(
valid
)
{
...
...
src/page/login/thirdlogin.vue
View file @
28ee8c5b
...
...
@@ -32,7 +32,7 @@ export default {
redirect_uri
=
encodeURIComponent
(
window
.
location
.
origin
+
'/#/authredirect'
)
if
(
thirdpart
===
'wechat'
)
{
appid
=
'wxd1678d3f83b1d83a'
url
=
'https://open.weixin.qq.com/connect/qrconnect?appid='
+
appid
+
'&redirect_uri='
+
redirect_uri
+
'&state=
'
+
appid
+
'
&response_type=code&scope=snsapi_login#wechat_redirect'
url
=
'https://open.weixin.qq.com/connect/qrconnect?appid='
+
appid
+
'&redirect_uri='
+
redirect_uri
+
'&state=
WX
&response_type=code&scope=snsapi_login#wechat_redirect'
}
else
if
(
thirdpart
===
'tencent'
)
{
client_id
=
'101322838'
url
=
'https://graph.qq.com/oauth2.0/authorize?response_type=code&state='
+
appid
+
'&client_id='
+
client_id
+
'&redirect_uri='
+
redirect_uri
...
...
src/page/login/userlogin.vue
View file @
28ee8c5b
...
...
@@ -75,6 +75,10 @@ export default {
data
()
{
return
{
socialForm
:
{
code
:
''
,
state
:
''
},
loginForm
:
{
username
:
"admin"
,
password
:
"123456"
,
...
...
@@ -104,6 +108,24 @@ export default {
passwordType
:
"password"
};
},
watch
:
{
$route
()
{
const
params
=
this
.
$route
.
query
this
.
socialForm
.
state
=
params
.
state
this
.
socialForm
.
code
=
params
.
code
if
(
!
validatenull
(
this
.
socialForm
.
state
))
{
const
loading
=
this
.
$loading
({
lock
:
true
,
text
:
`登录中,请稍后。。。`
,
spinner
:
'el-icon-loading'
})
setTimeout
(()
=>
{
loading
.
close
()
},
2000
)
this
.
handleSocialLogin
()
}
}
},
created
()
{
this
.
refreshCode
();
},
...
...
src/router/axios.js
View file @
28ee8c5b
...
...
@@ -47,7 +47,7 @@ axios.interceptors.request.use(config => {
axios
.
interceptors
.
response
.
use
(
res
=>
{
NProgress
.
done
();
const
status
=
Number
(
res
.
status
);
const
message
=
res
.
data
.
message
||
errorCode
[
status
]
||
errorCode
[
'default'
];
const
message
=
res
.
data
.
data
||
errorCode
[
status
]
||
errorCode
[
'default'
];
if
(
status
===
401
){
store
.
dispatch
(
'FedLogOut'
).
then
(()
=>
{
...
...
src/store/modules/user.js
View file @
28ee8c5b
import
{
setToken
,
removeToken
}
from
'@/util/auth'
import
{
setStore
,
getStore
}
from
'@/util/store'
import
{
logout
,
loginByUsername
,
loginBySocial
,
getUserInfo
}
from
'@/api/login'
import
{
logout
,
loginByUsername
,
loginByMobile
,
loginBySocial
,
getUserInfo
}
from
'@/api/login'
import
{
encryption
}
from
'@/util/util'
import
webiste
from
'@/const/website'
;
import
{
GetMenu
}
from
'@/api/menu'
...
...
@@ -61,14 +61,16 @@ const user = {
},
//根据手机号登录
LoginByPhone
({
commit
},
userInfo
)
{
return
new
Promise
((
resolve
)
=>
{
loginByUsername
(
userInfo
.
phone
,
userInfo
.
code
).
then
(
res
=>
{
const
data
=
res
.
data
;
commit
(
'SET_TOKEN'
,
data
);
commit
(
'DEL_ALL_TAG'
);
commit
(
'CLEAR_LOCK'
);
setToken
(
data
);
resolve
();
return
new
Promise
((
resolve
,
reject
)
=>
{
loginByMobile
(
userInfo
.
mobile
,
userInfo
.
code
).
then
(
response
=>
{
const
data
=
response
.
data
setToken
(
data
.
access_token
)
commit
(
'SET_ACCESS_TOKEN'
,
data
.
access_token
)
commit
(
'SET_REFRESH_TOKEN'
,
data
.
refresh_token
)
commit
(
'CLEAR_LOCK'
)
resolve
()
}).
catch
(
error
=>
{
reject
(
error
)
})
})
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment