heyujie
2022-03-02 7efeb8800e982837026475db39dc02f945f7f623
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
<template>
  <div class="v-sys-info">
    <div class="sys-content">
      <div class="sys-right">
        <div class="auto">
          <div class="title-bg">
            <div class="title">Smart AIOS</div>
            <div class="desc">Copyright © 贝思科技术有限公司</div>
          </div>
          <div class="bar" style="background-color: #f2f2f7">
            <div class="name">版本:</div>
            <div class="desc">
              {{
                serializedNumber == "" ? "SmartAIOS试用版" : "SmartAIOS正式版"
              }}
            </div>
          </div>
          <div class="bar">
            <div class="name">激活:</div>
            <div class="right-zone">
              <el-button
                type="primary"
                size="small"
                @click="confirmAgain"
                v-if="serializedNumber != ''"
                >导出产品密钥</el-button
              >
              <div class="desc activation">
                {{ serializedNumber == "" ? "未激活" : "已激活" }}
              </div>
            </div>
          </div>
          <div class="bar">
            <div class="name" style="min-width: 65px">请求码:</div>
            <div class="desc code" style="font-size: 12px">{{ q }}</div>
          </div>
          <div class="bar">
            <div class="name">产品密钥:</div>
            <div class="desc">
              {{ authorization || "-" }}
            </div>
          </div>
          <div class="bar">
            <div class="name">到期时间:</div>
            <div class="desc" style="font-size: 16px">{{ expireTime }}</div>
          </div>
        </div>
      </div>
    </div>
 
    <el-dialog
      title="再次确认"
      :visible.sync="dialogVisible"
      custom-class="my-confirm"
    >
      <div class="ver">
        <span
          class="iconfont"
          style="color: orangered; font-size: 40px; margin-bottom: 10px"
          >&#xe6e6;</span
        >
        <span class="ver-text">
          产品密钥导出后,系统大部分功能将无法使用,请确认是否继续?
        </span>
      </div>
      <div class="info">
        <span class="info-cont">
          如需继续,请输入管理员密码,并导入您要激活的设备请求码,然后点击“确定”。
        </span>
        <div style="margin-top: 10px">设备请求码获取方式:</div>
        <ul>
          <li style="list-style: inside">如系统已激活,在激活页面导出即可;</li>
          <li style="list-style: inside">
            如设备未激活,在SmartAI激活页面扫码获取
          </li>
        </ul>
        <!-- <span style="color: #8f949a; font-size: 14px"
          >。</span
        > -->
      </div>
      <!--  -->
      <div class="pw">
        <el-input
          size="small"
          placeholder="请输入管理员密码"
          v-model="password"
        ></el-input>
      </div>
      <div class="validate">
        <form id="myForm">
          <el-input
            type="textarea"
            autosize
            style="width: 460px"
            placeholder="将你想要激活的设备请求码粘贴在此处"
            v-model="secrectKey"
          >
          </el-input>
        </form>
        <el-button size="small" @click="txtbtn" type="primary"
          >导入文件</el-button
        >
        <input
          type="file"
          @change="loadTextFromFile"
          id="txt"
          style="display: none"
        />
      </div>
 
      <span slot="footer" class="dialog-footer">
        <div class="btns">
          <el-button class="cancel" @click="dialogVisible = false">取消</el-button>
          <el-button class="ok" type="primary" @click="confirmCancel">确定</el-button>
        </div>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import { getSN, cancelAuthorization } from "@/api/system";
export default {
  mounted() {
    this.refreshSn();
  },
  data() {
    return {
      authorization: "",
      expireTime: "",
      serializedNumber: "",
      secrectKey: "",
      q: "",
      activeState: "已激活",
      password: "",
      dialogVisible: false,
    };
  },
  methods: {
    refreshSn() {
      getSN().then((res) => {
        if (res.code == 200) {
          this.authorization = res.data.authorization;
          this.expireTime = res.data.expireTime;
          this.serializedNumber = res.data.sn;
          this.q = res.data.q;
        }
      });
    },
    confirmAgain() {
      this.dialogVisible = true;
    },
    txtbtn() {
      document.getElementById("txt").click();
    },
    loadTextFromFile(e) {
      const file = e.target.files[0];
      var reader = new FileReader(); //new一个FileReader实例
      let that = this;
      reader.onload = function () {
        that.secrectKey = this.result.trim();
      };
      reader.readAsText(file);
    },
    confirmCancel() {
      this.secrectKey = this.secrectKey.trim();
      this.password = this.password.trim();
      if (this.secrectKey == "" || this.password == "") {
        this.$message.warning("请先填写密码和请求码");
        return;
      }
      cancelAuthorization({
        q: this.secrectKey,
        passwd: this.password,
        down: 1,
      }).then((res) => {
        if (res.type == "application/json") {
          var reader = new FileReader();
          reader.readAsText(res, "utf-8");
          let that = this;
          reader.onload = function () {
            var receive_data = JSON.parse(this.result); //这个就是解析出来的数据
            that.$notify.error(receive_data.msg);
          };
          return;
        }
        let url = window.URL.createObjectURL(
          new Blob([res], { type: "text/plain" })
        );
        let a = document.createElement("a");
        a.href = url;
        a.download = "key.txt";
        a.click();
        window.URL.revokeObjectURL(url);
        this.refreshSn();
        window.parent.postMessage({ msg: "checkSN" }, "*");
        this.$notify.success("导出成功");
        this.dialogVisible = false;
      });
    },
  },
};
</script>
<style lang="scss">
div {
  color: #333;
}
 
.v-sys-info {
  width: 100%;
  background-color: #fbfaff;
  border-top: 4px solid #f2f2f7;
  border-left: 4px solid #f2f2f7;
 
  .el-dialog {
    width: 640px;    border-radius: 24px;
 
  }
 
  .el-dialog__header {
    padding: 14px 20px 13px;
    text-align: center;
    box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.08);
    .el-dialog__title {
      font-weight: 600;
      font-size: 18px;
      color: #5f5f5f;
      line-height: 25px;
    }
  }
  .el-dialog__body {
    text-align: left;
    padding: 30px;
    .pw {
      .el-input--small .el-input__inner {
        height: 32px;
        line-height: 32px;
        border-radius: 16px;
        border-color: #d4d6d9 !important;
      }
    }
  }
  .el-dialog__footer {
    padding: 10px 20px 20px;
  .btns {
    display: flex;
    justify-content: right;
    .cancel {
      width: 140px;
      height: 40px;
      cursor: pointer;
      border-radius: 20px;
      line-height: 40px;
      font-size: 14px;
      color: var(--colorCard);
      border-color: var(--colorCard) !important;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .ok {
      width: 140px;
      height: 40px;
      cursor: pointer;
      border-radius: 20px;
      background-color: var(--colorCard) !important;
      border-color: var(--colorCard) !important;
      color: #fff;
      line-height: 40px;
      font-size: 14px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
}
  .el-divider--horizontal {
    margin: 20px 0;
  }
  .validate {
    display: flex;
    align-items: baseline;
    margin-top: 15px;
    .el-button--small {
        font-size: 14px;
        border-radius: 3px;
        border-radius: 16px;
        background-color: var(--colorCard) !important;
        border-color: var(--colorCard) !important;
        min-width: 120px;    padding: 8px 15px;
 
      }
  }
  #myForm {
    display: flex;
    align-items: center;
    margin-right: 10px;
    .single-input {
      margin: 0 8px;
      width: 60px;
    }
    .el-textarea__inner {
      min-height: 32px;
      height: 32px;
      border: 1px solid #d4d6d9;
      box-sizing: border-box;
      border-radius: 16px;
    }
  }
  .ver {
    margin-bottom: 30px;
 
    display: flex;
    flex-direction: column;
    align-items: center;
    .ver-text {
      font-weight: bold;
      font-size: 16px;
      line-height: 22px;
      color: #5f5f5f;
    }
  }
  .info {
    line-height: 25px;
    margin: 15px 0;
    font-size: 12px;
    line-height: 21px;
    color: #666666;
    .info-cont {
      font-weight: bold;
      font-size: 14px;
      color: #5f5f5f;
    }
  }
  .qr-code-img {
    width: 100px;
    height: 100px;
  }
  .ask {
    margin-top: 20px;
    font-size: 15px;
  }
}
 
.sys-content {
  height: 100%;
  display: flex;
  flex-direction: row;
  flex: 1;
  flex-basis: auto;
  box-sizing: border-box;
  .sys-right {
    flex: 1;
    flex-basis: auto;
    overflow: auto;
    box-sizing: border-box;
    position: relative;
    padding: 10px 15px 0 10px;
    .el-form-item.is-required:not(.is-no-asterisk)
      > .el-form-item__label:before,
    .el-form-item.is-required:not(.is-no-asterisk)
      .el-form-item__label-wrap
      > .el-form-item__label:before {
      display: none;
    }
    .el-select {
      width: 100%;
    }
    .el-form-item {
      margin-bottom: 10px;
      height: 50px;
      background: #f8f8f8;
      padding: 4px 20px;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
      border-radius: 10px;
      .el-form-item__label {
        text-align: left;
        line-height: 42px;
      }
    }
    .el-form-item__content {
      line-height: 40px;
      position: relative;
      font-size: 14px;
    }
    .ip-input-container {
      max-width: none !important;
    }
    .auto {
      .title-bg {
        background-color: #fff;
        height: 110px;
        border-radius: 8px;
        margin-bottom: 10px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        .title {
          font-size: 24px;
          font-weight: 700;
          line-height: 33.6px;
        }
        .desc {
          margin-top: 10px;
          font-size: 12px;
          line-height: 16.8px;
          font-weight: 700;
        }
      }
      .bar {
        display: flex;
        align-items: center;
        padding: 12px 40px;
        background-color: #fff;
        justify-content: space-between;
        border-radius: 12px;
        margin-bottom: 10px;
        .right-zone {
          display: flex;
          align-items: center;
        }
        .name {
          font-size: 16px;
          font-weight: 700;
          text-align: left;
          min-width: 180px;
        }
        .desc {
          font-size: 16px;
          font-weight: 700;
          margin-left: 30px;
          max-width: 568px;
          line-height: normal;
          word-wrap: break-word;
          text-align: left;
        }
        .activation {
          width: 90px;
          height: 28px;
          background: rgba(78, 148, 255, 0.1);
          border: 1px solid #4e94ff;
          border-radius: 20px;
          text-align: center;
          line-height: 28px;
          color: #333;
          font-size: 14px;
        }
        .el-input {
          width: 100%;
          .el-input {
            height: auto;
          }
          .el-input__inner {
            border: none;
            border-radius: 8px;
            background-color: rgba(240, 240, 240, 1);
            text-align: left;
          }
        }
      }
    }
  }
}
</style>