Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
W
web-site
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
张冬
web-site
Commits
2fcc836c
Commit
2fcc836c
authored
Sep 21, 2020
by
吴冠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
官网token验证模块
parent
67cce7f2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
34 deletions
+40
-34
header.vue
components/header.vue
+16
-10
index.vue
pages/index/index.vue
+22
-9
user.vue
pages/login/user.vue
+2
-15
No files found.
components/header.vue
View file @
2fcc836c
...
@@ -8,10 +8,10 @@
...
@@ -8,10 +8,10 @@
<nuxt-link
to=
"/"
class=
"head-title t1"
>
首页
</nuxt-link>
<nuxt-link
to=
"/"
class=
"head-title t1"
>
首页
</nuxt-link>
</div>
</div>
<div
class=
"welcome t1"
>
<div
class=
"welcome t1"
>
<span>
欢迎
{{
userName
}}
</span>
<span>
你好,
{{
userName
}}
</span>
<nuxt-link
to=
"/login/user"
class=
"login"
v-show=
"
isshow
"
>
登录
</nuxt-link>
<nuxt-link
to=
"/login/user"
class=
"login"
v-show=
"
showDefault
"
>
登录
</nuxt-link>
<span>
商家免费入住
</span>
<span>
商家免费入住
</span>
<span
@
click=
"jump"
v-show=
"!
isshow
"
>
跳转后台
</span>
<span
@
click=
"jump"
v-show=
"!
showDefault"
class=
"right-pos
"
>
跳转后台
</span>
</div>
</div>
</div>
</div>
<div
class=
"flex-item t1 collection"
>
<div
class=
"flex-item t1 collection"
>
...
@@ -26,18 +26,20 @@
...
@@ -26,18 +26,20 @@
<
script
>
<
script
>
export
default
{
export
default
{
/*接受user传值
mounted
(){
import User from '@/login/user.vue
let
tokenStr
=
window
.
localStorage
.
getItem
(
"token"
)
@header= "receiveH"
if
(
!
tokenStr
){
receive(data){
console
.
log
(
'1111'
)
this.isshow = data.changeStatus
}
else
{
this
.
showDefault
=
false
this
.
userName
=
window
.
localStorage
.
getItem
(
"companyName"
)
}
}
*/
},
data
()
{
data
()
{
return
{
return
{
input
:
''
,
input
:
''
,
userName
:
'来到捷安采'
,
userName
:
'来到捷安采'
,
isshow
:
true
showDefault
:
true
}
}
},
},
methods
:
{
methods
:
{
...
@@ -58,6 +60,10 @@
...
@@ -58,6 +60,10 @@
</
script
>
</
script
>
<
style
scoped
>
<
style
scoped
>
.right-pos
{
position
:
absolute
;
left
:
980px
;
}
.bg
{}
.bg
{}
.header-line
{
.header-line
{
...
...
pages/index/index.vue
View file @
2fcc836c
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
<div
class=
"login-title"
>
{{
userName
}}
</div>
<div
class=
"login-title"
>
{{
userName
}}
</div>
<div
class=
"login-button"
@
click=
"loginuser"
v-show=
"showDefault"
>
用户登录
</div>
<div
class=
"login-button"
@
click=
"loginuser"
v-show=
"showDefault"
>
用户登录
</div>
<div
class=
"login-button"
>
商家入驻
</div>
<div
class=
"login-button"
>
商家入驻
</div>
<div
class=
"login-button"
v-if=
"!showDefaul
t"
>
退出
</div>
<div
class=
"login-button"
@
click=
"checkou
t"
>
退出
</div>
</div>
</div>
</div>
</div>
<div
class=
"content message"
>
<div
class=
"content message"
>
...
@@ -52,11 +52,28 @@
...
@@ -52,11 +52,28 @@
<
script
>
<
script
>
import
{
getLoopPic
}
from
'@/common/list.js'
import
{
getLoopPic
}
from
'@/common/list.js'
import
{
getSecond
}
from
'@/common/list.js'
export
default
{
export
default
{
created
(){
created
(){
this
.
getLoopPic
()
this
.
getLoopPic
()
this
.
getSecond
()
},
},
methods
:{
methods
:{
//添加验证方法
async
getSecond
(){
let
tokenStr
=
window
.
localStorage
.
getItem
(
'token'
)
if
(
!
tokenStr
){
this
.
$router
.
push
(
'/login/user'
)
}
else
{
this
.
showDefault
=
false
const
{
data
:
res
}
=
await
getSecond
()
console
.
log
(
res
)
window
.
localStorage
.
setItem
(
"companyName"
,
res
.
companyName
)
this
.
userName
=
window
.
localStorage
.
getItem
(
"companyName"
)
}
/* const {data} = await getSecond()
console.log(data) */
},
loginuser
(){
loginuser
(){
this
.
$router
.
push
(
"/login/user"
)
this
.
$router
.
push
(
"/login/user"
)
},
},
...
@@ -70,15 +87,11 @@ import {getLoopPic} from '@/common/list.js'
...
@@ -70,15 +87,11 @@ import {getLoopPic} from '@/common/list.js'
changeOver
(){
changeOver
(){
this
.
isshow
=
true
this
.
isshow
=
true
},
},
//添加退出按钮 清空token
/*接受user传值
checkout
(){
import User from '@/login/user.vue
window
.
localStorage
.
clear
()
@index= "receiveI"
this
.
$router
.
push
(
"/login/user"
)
receiveI(data){
this.showDefault = data.changeStatus
this.userName = data.user
}
}
*/
},
},
data
()
{
data
()
{
return
{
return
{
...
...
pages/login/user.vue
View file @
2fcc836c
...
@@ -62,10 +62,6 @@
...
@@ -62,10 +62,6 @@
export
default
{
export
default
{
data
:
function
()
{
data
:
function
()
{
return
{
return
{
change
:{
changeStatus
:
false
,
user
:
''
},
changemessage
:
"手机验证码登录"
,
changemessage
:
"手机验证码登录"
,
message
:
"密码登录"
,
message
:
"密码登录"
,
type
:
"0"
,
type
:
"0"
,
...
@@ -108,11 +104,11 @@
...
@@ -108,11 +104,11 @@
created
()
{
created
()
{
},
},
methods
:
{
methods
:
{
/* await
getSecond(){
/* async
getSecond(){
const {data} = await getSecond()
const {data} = await getSecond()
console.log(data+'------------------------')
console.log(data+'------------------------')
}, */
}, */
async
submitForm
()
{
async
submitForm
(
event
)
{
try
{
try
{
const
valid
=
await
this
.
$refs
[
'param'
].
validate
()
const
valid
=
await
this
.
$refs
[
'param'
].
validate
()
if
(
valid
)
{
if
(
valid
)
{
...
@@ -123,15 +119,6 @@
...
@@ -123,15 +119,6 @@
}
=
await
powerLogin
(
this
.
param
)
}
=
await
powerLogin
(
this
.
param
)
if
(
code
==
200
)
{
if
(
code
==
200
)
{
localStorage
.
setItem
(
"token"
,
data
);
localStorage
.
setItem
(
"token"
,
data
);
/* 逻辑 :向组件index、header传改变状态的值*/
/* if(code ===200){
const {data,userInfo} = await getSecond()
this.change.user = userInfo
console.log(data+'------------------------')
this.$emit("index",this.change)
this.$emit("header",this.changeStatus)
},
} */
this
.
$message
({
this
.
$message
({
message
:
msg
,
message
:
msg
,
type
:
'success'
,
type
:
'success'
,
...
...
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