zhangzengfei
2023-09-06 c0c034b3ef0fdf0fd9c802d5984dbd717db6817a
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<template>
  <div class="init" v-if="!isWhite">
    <img class="img-test" onerror="console.log('网络故障')" />
    <div class="content">
      <div class="title">欢迎注册Smart AI 人工智能操作系统</div>
      <el-steps :active="active" finish-status="success" :align-center="true">
        <el-step title="创建账号"></el-step>
        <el-step title="配置网络"></el-step>
        <el-step title="注册信息"></el-step>
      </el-steps>
 
      <el-carousel ref="carousel" trigger="click" :loop="false" :autoplay="false" :initial-index="active">
        <el-carousel-item>
          <formAccount ref="form0" v-show="active == createUser"></formAccount>
        </el-carousel-item>
        <el-carousel-item>
          <formNet ref="form1" v-show="active == configNet"></formNet>
        </el-carousel-item>
        <el-carousel-item>
          <formInfo ref="form2" v-show="active == registerInfo"></formInfo>
        </el-carousel-item>
      </el-carousel>
 
      <div class="control">
        <div class="pre" @click="preForm" v-if="active != createUser">上一步</div>
        <div class="next" @click="nextForm" v-if="active == createUser || (active == configNet && !isOnline)">
          下一步
        </div>
        <div class="next" @click="nextFormNot" v-if="active == configNet">跳过</div>
 
        <div class="next" @click="nextForm" v-if="active == registerInfo">完成</div>
      </div>
    </div>
  </div>
  <div class="white" v-else></div>
</template>
 
<script>
import formAccount from "@/pages/index/components/formAccount"
import formNet from "@/pages/index/components/formNet"
import formInfo from "@/pages/index/components/formInfo"
import { tologin, getLoginUserData, getServerName } from "./api.ts"
import { getMenuListData } from "@/api/utils"
 
export default {
  name: "smartai init",
  components: {
    formAccount,
    formNet,
    formInfo
  },
  data() {
    return {
      active: 0,
      formData: {},
      isWhite: true,
      isOnline: false,
      createUser: 0,
      configNet: 1,
      registerInfo: 2
    }
  },
  mounted() {
    this.testLogin()
  },
 
  methods: {
    async testLogin() {
      // location.assign("/view/desktop/")
      tologin({ username: "basic", password: "basic2019" })
        .then((json) => {
          const loginedInfo = {
            access_token: json.token_type + " " + json.access_token,
            refresh_token: json.refresh_token
          }
          sessionStorage.setItem("expires_in", json.expires_in)
          sessionStorage.setItem("loginedInfo", JSON.stringify(loginedInfo))
          sessionStorage.setItem("userInfo", JSON.stringify(json.userInfo))
 
          location.assign("/view/desktop/")
        })
        .catch()
    },
    async getLoginUserData() {
      let res = await getLoginUserData()
      if (res.success) {
        sessionStorage.setItem("userInfo", JSON.stringify(res.data))
        // 获取权限
        // await this.getMenuList()
 
        return res.data
      } else {
      }
    },
    async getMenuList() {
      let results = await getMenuListData({})
      if (results && results.success) {
        /* 存储权限 */
        let buttonAuthoritys = results.data
        sessionStorage.setItem("buttonAuthoritys", "," + buttonAuthoritys + ",")
        sessionStorage.setItem("menuInfo", JSON.stringify(results))
      }
    }
  }
}
</script>
 
<style lang="scss" scoped>
.init {
  background-image: url("/images/init/背景图.png");
  background-size: cover;
  background-attachment: fixed;
  color: #fff;
  user-select: none;
  height: 100%;
  min-width: 1000px;
  overflow: hidden;
  min-height: 760px;
  .content {
    margin: 0 auto;
    width: 1000px;
    padding-top: calc(6.4vh);
 
    .title {
      font-size: 28px;
      font-weight: 700;
      margin-bottom: 50px;
      letter-spacing: 5px;
    }
 
    .el-steps ::v-deep {
      margin-left: 22px;
      text-align: left;
 
      .el-step__icon {
        width: 48px;
        height: 48px;
      }
 
      .el-step__line {
        left: 210px;
        right: -110px;
        border: 0.5px solid #fff;
        border-bottom: none;
        border-top: none;
        opacity: 0.1;
        top: 22px;
      }
 
      .is-success .el-step__icon {
        background: none;
        border: 2px solid rgba(255, 255, 255, 0.3);
 
        .el-icon-check::before {
          color: #fff;
          font-size: 24px;
          font-weight: 700;
        }
      }
 
      .is-process .el-step__icon {
        background-color: rgba(255, 255, 255, 0.3);
        border: none;
 
        .el-step__icon-inner {
          color: #fff;
          font-size: 24px;
          font-weight: 700;
        }
      }
 
      .is-wait .el-step__icon {
        border: 2px solid rgba(255, 255, 255);
        opacity: 0.5;
        background: none;
 
        .el-step__icon-inner {
          color: #fff;
          font-size: 24px;
          font-weight: 700;
        }
      }
 
      .el-step__main {
        margin-top: 20px;
        .is-success,
        .is-process {
          font-size: 16px;
          color: #fff;
          font-weight: normal;
        }
 
        .is-wait {
          font-size: 16px;
          color: #fff;
          font-weight: normal;
          opacity: 0.5;
        }
      }
    }
 
    .formAccount {
      margin-left: 200px;
      width: 550px;
    }
 
    .formNet,
    .formInfo {
      margin-left: 200px;
      width: 550px;
    }
 
    .control {
      margin: 0 auto;
      line-height: 40px;
      margin-top: calc(3.2vh);
 
      .pre {
        margin: 10px auto;
        cursor: pointer;
        width: 260px;
        height: 40px;
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-radius: 20px;
        font-weight: bold;
        color: #ffffff;
      }
 
      .next {
        margin: 10px auto;
        cursor: pointer;
        width: 260px;
        height: 40px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 20px;
        font-weight: bold;
        color: #ffffff;
      }
    }
  }
 
  ::v-deep .el-carousel__indicators {
    display: none;
  }
 
  ::v-deep .el-carousel__container button {
    display: none;
  }
 
  ::v-deep .el-carousel__container {
    margin-top: calc(5.74vh);
    height: 290px !important;
  }
}
 
.white {
  height: 100%;
  background-color: #fff;
}
</style>