LoginCard.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <el-card class="login-card">
  3. <div class="login-welcome">
  4. <img v-if="user.userVO&&user.userVO.photoUrl" :src="user.userVO&&user.userVO.photoUrl" 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} 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. }
  38. },
  39. methods: {
  40. loadData() {
  41. if (storageGet('user') != null) {
  42. this.isLogin = true;
  43. this.user = storageGet('user');
  44. }
  45. },
  46. userLogout() {
  47. this.isLogin = false
  48. logout().then((res) => {
  49. location.reload();
  50. this.$router.push('/home')
  51. })
  52. },
  53. },
  54. mounted() {
  55. this.loadData();
  56. }
  57. }
  58. </script>
  59. <style scoped lang="less">
  60. .login-card {
  61. margin-bottom: 15px;
  62. .welcome-img {
  63. width: 40px;
  64. height: 40px;
  65. display: inline-block;
  66. margin: 2px 0;
  67. }
  68. .welcome-title {
  69. font-size: 14px;
  70. font-family: Source Han Sans CN;
  71. font-weight: bold;
  72. color: rgba(0, 0, 0, 1);
  73. }
  74. .welcome-content {
  75. font-size: 13px;
  76. font-family: Source Han Sans CN;
  77. font-weight: 400;
  78. color: rgba(0, 0, 0, 1);
  79. }
  80. .welcome-btn {
  81. width: 100%;
  82. height: 28px;
  83. margin-top: 25px;
  84. .login-btn {
  85. background-color: rgba(0, 118, 203, 1);
  86. &:hover {
  87. background-color: rgba(0, 118, 203, 0.8);
  88. }
  89. }
  90. .cancel-btn {
  91. background-color: rgba(217, 92, 93, 1);
  92. &:hover {
  93. background-color: rgba(217, 92, 93, 0.8);
  94. }
  95. }
  96. }
  97. }
  98. </style>