1. 程式人生 > >登入登出

登入登出

login.vue

if(response.data=="00"){

mymenu.vue

  <el-menu-item style="margin-left:150px" v-if="!this.$store.state.logined" index="6">登陸</el-menu-item>
                <el-menu-item  v-if="!this.$store.state.logined" index="7">註冊</el-menu-item>

                 <el-submenu 
style="margin-left:100px" v-else index="5"> <template slot="title"> <i class="el-icon-menu"></i> <span slot="title">我的賬號</span> </template> <
el-menu-item index="7-1">退出</el-menu-item> </el-submenu> getLoginStatus(thisvue){ var gvue=thisvue; this.$ajax({ method: 'get', url: 'api/loginstatus?time='+new Date().getTime(), /* data: { usrname: this.ruleForm2.usrname, pass: this.ruleForm2.pass }*/ }).then(function (response) { console.log(response); if(response.data=="sessionon"){ gvue.$store.state.logined=true; gvue.$store.state.identification=response.data.ret_msg.identification; }else{ gvue.$store.state.logined=false; } }) .catch(function (error) { console.log(error); gvue.$store.state.logined=false; }); }, sendLogout(){ var gvue=this; this.$ajax({ method: 'get', url: 'api/logout?time='+new Date().getTime(), }).then(function (response) { console.log(response); gvue.getLoginStatus(gvue); //alert("haha"); }) .catch(function (error) { gvue.getLoginStatus(gvue); console.log(error); }); }, if(key=="7-1") this.sendLogout();