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

官网token验证模块

parent 67cce7f2
...@@ -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 {
......
...@@ -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="!showDefault">退出</div> <div class="login-button" @click="checkout">退出</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 {
......
...@@ -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',
......
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