| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <template>
- <el-card class="login-card">
- <div class="login-welcome">
- <img :src="!this.userImg?logo_background:this.userImg" alt="welcome-img"
- class="pull-left welcome-img">
- <div style="margin-left: 46px">
- <div class="welcome-title">
- hi,欢迎使用{{ logoTitle }}
- </div>
- <div class="welcome-content">
- {{ login_description }}
- </div>
- </div>
- <div class="welcome-btn">
- <a :href="loginUrl">
- <el-button type="primary" size="mini" class="pull-left login-btn" v-if="!isLogin">登录</el-button>
- </a>
- <el-button type="primary" size="mini" class="pull-right cancel-btn" v-if="isLogin" @click.native="userLogout()">
- 登出
- </el-button>
- </div>
- </div>
- </el-card>
- </template>
- <script>
- import Http from '@/js/http.js'
- import {logout, storageGet} from '@/js/index.js'
- import {mapActions, mapGetters} from 'vuex'
- import {CONFIG, login_url} from "../../config";
- import {storageRemove} from "../../js/index";
- export default {
- name: "LoginCard",
- data() {
- return {
- logoTitle: CONFIG.logoTitle,
- logo_background: CONFIG.logo_background,
- isLogin: false,
- user: {},
- loginUrl: login_url,
- userImg: '',
- login_description: CONFIG.login_description
- }
- },
- computed: {
- ...mapGetters(['getUserInfo'])
- },
- methods: {
- loadData() {
- if (storageGet('user') || this.getUserInfo.id) {
- this.isLogin = true;
- this.user = storageGet('user') || this.getUserInfo;
- }
- },
- userLogout() {
- this.isLogin = false
- logout().then((res) => {
- console.log('logout');
- storageRemove('user');
- location.reload();
- })
- },
- getUserImg() {
- if (this.user && this.user.userVO && this.user.userVO.id) {
- Http.get(`/api/user/image/${this.user.userVO.id}`).then((res) => {
- if (res.data) {
- this.userImg = res.data;
- }
- })
- }
- }
- },
- mounted() {
- this.loadData();
- this.getUserImg();
- },
- watch: {
- getUserInfo(val) {
- this.loadData();
- this.getUserImg();
- }
- }
- }
- </script>
- <style scoped lang="scss">
- @import "../../style/main";
- .login-card {
- margin-bottom: 13px;
- .welcome-img {
- width: 40px;
- height: 40px;
- display: inline-block;
- margin: 2px 0;
- }
- .welcome-title {
- font-size: 14px;
- font-family: Source Han Sans CN;
- font-weight: bold;
- color: rgba(0, 0, 0, 1);
- }
- .welcome-content {
- font-size: 13px;
- font-family: Source Han Sans CN;
- font-weight: 400;
- color: rgba(0, 0, 0, 1);
- }
- .welcome-btn {
- width: 100%;
- height: 28px;
- margin-top: 20px;
- }
- }
- </style>
|