Commit 2fcc836c authored by 吴冠's avatar 吴冠

官网token验证模块

parent 67cce7f2
......@@ -8,10 +8,10 @@
<nuxt-link to="/" class="head-title t1">首页</nuxt-link>
</div>
<div class="welcome t1">
<span>欢迎 {{userName}}</span>
<nuxt-link to="/login/user" class="login" v-show="isshow">登录</nuxt-link>
<span>你好,{{userName}}</span>
<nuxt-link to="/login/user" class="login" v-show="showDefault">登录</nuxt-link>
<span>商家免费入住</span>
<span @click="jump" v-show="!isshow">跳转后台</span>
<span @click="jump" v-show="!showDefault" class="right-pos">跳转后台</span>
</div>
</div>
<div class="flex-item t1 collection">
......@@ -26,18 +26,20 @@
<script>
export default {
/*接受user传值
import User from '@/login/user.vue
@header= "receiveH"
receive(data){
this.isshow = data.changeStatus
mounted(){
let tokenStr = window.localStorage.getItem("token")
if(!tokenStr){
console.log('1111')
}else{
this.showDefault = false
this.userName = window.localStorage.getItem("companyName")
}
*/
},
data() {
return {
input: '',
userName:'来到捷安采',
isshow: true
showDefault: true
}
},
methods: {
......@@ -58,6 +60,10 @@
</script>
<style scoped>
.right-pos{
position: absolute;
left:980px;
}
.bg {}
.header-line {
......
......@@ -13,7 +13,7 @@
<div class="login-title">{{userName}}</div>
<div class="login-button" @click="loginuser" v-show="showDefault">用户登录</div>
<div class="login-button">商家入驻</div>
<div class="login-button" v-if="!showDefault">退出</div>
<div class="login-button" @click="checkout">退出</div>
</div>
</div>
<div class="content message">
......@@ -52,11 +52,28 @@
<script>
import {getLoopPic} from '@/common/list.js'
import {getSecond} from '@/common/list.js'
export default {
created(){
this.getLoopPic()
this.getSecond()
},
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(){
this.$router.push("/login/user")
},
......@@ -70,15 +87,11 @@ import {getLoopPic} from '@/common/list.js'
changeOver(){
this.isshow = true
},
/*接受user传值
import User from '@/login/user.vue
@index= "receiveI"
receiveI(data){
this.showDefault = data.changeStatus
this.userName = data.user
//添加退出按钮 清空token
checkout(){
window.localStorage.clear()
this.$router.push("/login/user")
}
*/
},
data() {
return {
......
......@@ -62,10 +62,6 @@
export default {
data: function() {
return {
change:{
changeStatus:false,
user:''
},
changemessage: "手机验证码登录",
message: "密码登录",
type: "0",
......@@ -108,11 +104,11 @@
created() {
},
methods: {
/* await getSecond(){
/* async getSecond(){
const {data} = await getSecond()
console.log(data+'------------------------')
}, */
async submitForm() {
async submitForm(event) {
try {
const valid = await this.$refs['param'].validate()
if (valid) {
......@@ -123,15 +119,6 @@
} = await powerLogin(this.param)
if (code == 200) {
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({
message: msg,
type: 'success',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment