hejianhao
2025-05-08 89ea93ff37fd5adcb39c7caad1101970dc78e38c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<template>
  <div class="login-page">
    <div class="login-content" :style="contentStyle">
      <div class="login-title">
        InnoLab
      </div>
      <div class="sub-title">
        账号登录
      </div>
 
      <div class="login-form">
        <div class="form-item flex">
          <img class="form-item-icon" :src="require('../../assets/login/account@2x.png')" alt="">
          <el-input v-model="loginForm.username" placeholder="请输入账号"></el-input>
        </div>
 
        <div class="form-item flex mt-40">
          <img class="form-item-icon" :src="require('../../assets/login/password@2x.png')" alt="">
          <el-input v-model="loginForm.password" type="password" placeholder="请输入密码"></el-input>
        </div>
 
        <div class="login-btn">
          <el-button type="primary" class="login-btn-item" @click="login">立即登录</el-button>
        </div>
      </div>
 
    </div>
  </div>
</template>
<script>
import { login } from './service'
export default {
  name: 'Login',
  data() {
    return {
      windowWidth: window.innerWidth,
 
      loginForm: {
        username: '',
        password: ''
      },
      viewWidth: '',
      scale: 1
    }
  },
  computed: {
    contentStyle() {
      return {
        transform: `scale(${this.scale})`,
        transformOrigin: 'center center'
      }
    }
  },
  watch: {
    viewWidth(newWidth) {
      if (newWidth <= 900) { // 小屏平板
        this.scale = 0.9
      } else if (newWidth <= 1200) { // 平板尺寸
        this.scale = 0.8
      } else {
        this.scale = 1
      }
    }
  },
  created() {
    // 初始化获取窗口宽度
    this.viewWidth = window.innerWidth
    // 添加窗口大小变化监听器
    window.addEventListener('resize', this.handleResize)
  },
  destroyed() {
    // 组件销毁时移除监听器
    window.removeEventListener('resize', this.handleResize)
  },
  methods: {
    // 添加处理窗口大小变化的方法
    handleResize() {
      this.viewWidth = window.innerWidth
      console.log(this.viewWidth)
    },
    login() {
      login(this.loginForm).then(res => {
        console.log(res,'1111111111111111111111111')
        if (res.code === 200) {
          sessionStorage.setItem('token', res.token)
          sessionStorage.setItem('userInfo', JSON.stringify(res.userInfo))
          this.$router.push('/')
        }
      })
    }
  }
}
</script>
<style scoped lang="less">
.flex {
  display: flex;
}
 
.j-between {
  justify-content: space-between;
}
 
.mt-40 {
  margin-top: 40px;
}
 
.login-page {
  width: 100%;
  height: 100vh;
  background: url('../../assets/login/backGround@2x.png') no-repeat center center;
  background-size: cover;
  // background-attachment: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
 
  .login-content {
    // width: 45%;
    width: 550px;
    // height: 694px;
    // padding: 4% 5% 4% 5%;
    padding: 82px 60px 72px 60px;
    background: #fff;
    box-shadow: 0px 20px 30px 0px rgba(0, 97, 95, 0.2);
    border-radius: 20px;
    border: 4px solid #FFFFFF;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s ease;
 
    .login-title {
      // width: 70%;
      text-align: center;
      font-family: SourceHanSansCN, SourceHanSansCN;
      font-weight: 500;
      font-size: 50px;
      color: #049C9A;
      line-height: 75px;
    }
 
    .sub-title {
      font-family: SourceHanSansCN, SourceHanSansCN;
      font-weight: 500;
      font-size: 30px;
      color: #049C9A;
      line-height: 45px;
      margin-top: 100px;
      margin-bottom: 45px;
    }
 
    .login-form {
      width: 100%;
 
      .form-item {
        height: 60px;
        border-radius: 30px;
        border: 2px solid #DBDBDB;
        display: flex;
        align-items: center;
        padding: 0 40px;
 
        .form-item-icon {
          width: 20px;
          height: 20px;
          margin-right: 17px;
        }
 
        ::v-deep .el-input__inner {
          border: none !important;
          background: transparent !important;
          height: 100% !important;
          padding: 0 !important;
          font-size: 20px;
          font-family: SourceHanSansCN, SourceHanSansCN;
          font-weight: 400;
          color: #000000;
          line-height: 30px;
        }
 
 
      }
    }
  }
 
  .login-btn {
    width: 100%;
    display: flex;
    justify-content: center;
  }
 
  .login-btn-item {
    width: 300px;
    height: 60px;
    background: linear-gradient(270deg, #05F2C2 0%, #05A0C1 100%);
    border-radius: 30px;
    border: none;
    margin-top: 95px;
    color: #fff;
    font-family: SourceHanSansCN, SourceHanSansCN;
    font-weight: bold;
    font-size: 20px;
    color: #FFFFFF;
    line-height: 30px;
  }
 
 
 
}
</style>