LoginCard.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <el-card class="login-card">
  3. <div class="login-welcome">
  4. <img :src="this.userImg" alt="welcome-img"
  5. class="pull-left welcome-img">
  6. <!-- <img v-else src="../../assets/img/logo-project.png" alt="welcome-img" class="pull-left welcome-img">-->
  7. <div style="margin-left: 46px">
  8. <div class="welcome-title">
  9. hi,欢迎使用群智众测平台
  10. </div>
  11. <div class="welcome-content">
  12. 众测群智,不一样的深度测试
  13. </div>
  14. </div>
  15. <div class="welcome-btn">
  16. <a :href="loginUrl">
  17. <el-button type="primary" size="mini" class="pull-left login-btn" v-if="!isLogin">登录</el-button>
  18. </a>
  19. <el-button type="danger" size="mini" class="pull-right cancel-btn" v-if="isLogin" @click.native="userLogout()">
  20. 登出
  21. </el-button>
  22. </div>
  23. </div>
  24. </el-card>
  25. </template>
  26. <script>
  27. import Http from '@/js/http.js'
  28. import Apis from '@/js/api.js'
  29. import {storageGet,logout} from '@/js/index.js'
  30. export default {
  31. name: "LoginCard",
  32. data() {
  33. return {
  34. isLogin: false,
  35. user: {},
  36. loginUrl: process.env.LOGIN_URL,
  37. userImg:require('../../assets/img/logo-project.png')
  38. }
  39. },
  40. methods: {
  41. loadData() {
  42. if (storageGet('user') != null) {
  43. this.isLogin = true;
  44. this.user = storageGet('user');
  45. }
  46. },
  47. userLogout() {
  48. this.isLogin = false
  49. logout().then((res) => {
  50. this.$router.go(0)
  51. })
  52. },
  53. getUserImg() {
  54. Http.get(`/api/user/image/${this.user.userVO.id}`).then((res)=>{
  55. if(res.data){
  56. this.userImg = res.data;
  57. }
  58. })
  59. }
  60. },
  61. mounted() {
  62. this.loadData();
  63. this.getUserImg();
  64. }
  65. }
  66. </script>
  67. <style scoped lang="less">
  68. .login-card {
  69. margin-bottom: 15px;
  70. .welcome-img {
  71. width: 40px;
  72. height: 40px;
  73. display: inline-block;
  74. margin: 2px 0;
  75. }
  76. .welcome-title {
  77. font-size: 14px;
  78. font-family: Source Han Sans CN;
  79. font-weight: bold;
  80. color: rgba(0, 0, 0, 1);
  81. }
  82. .welcome-content {
  83. font-size: 13px;
  84. font-family: Source Han Sans CN;
  85. font-weight: 400;
  86. color: rgba(0, 0, 0, 1);
  87. }
  88. .welcome-btn {
  89. width: 100%;
  90. height: 28px;
  91. margin-top: 25px;
  92. .login-btn {
  93. background-color: rgba(0, 118, 203, 1);
  94. &:hover {
  95. background-color: rgba(0, 118, 203, 0.8);
  96. }
  97. }
  98. .cancel-btn {
  99. background-color: rgba(217, 92, 93, 1);
  100. &:hover {
  101. background-color: rgba(217, 92, 93, 0.8);
  102. }
  103. }
  104. }
  105. }
  106. </style>