zhangzengfei
2022-07-31 85391dc1a2458202bdf0fb7a5394022aa17b9126
src/pages/vindicate/views/sysInfo.vue
@@ -4,25 +4,19 @@
      <div class="sys-right">
        <div class="auto">
          <div class="title-bg">
            <div class="title">Smart AIOS</div>
            <div class="desc">Copyright © 贝思科技术有限公司</div>
            <div class="title">{{ productName }}</div>
            <div class="desc">{{ copyright }}</div>
          </div>
          <div class="bar" style="background-color: #f2f2f7">
            <div class="name">版本:</div>
            <div class="desc">
              {{
                serializedNumber == "" ? "SmartAIOS试用版" : "SmartAIOS正式版"
              }}
              {{ serializedNumber == "" ? `${productName}试用版` : `${productName}正式版` }}
            </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 type="primary" size="small" @click="confirmAgain" v-if="serializedNumber != ''"
                >导出产品密钥</el-button
              >
              <div class="desc activation">
@@ -32,7 +26,7 @@
          </div>
          <div class="bar">
            <div class="name" style="min-width: 65px">请求码:</div>
            <div class="desc code" style="font-size: 12px">{{ q }}</div>
            <div class="desc code" style="font-size: 12px">{{ queryCode }}</div>
          </div>
          <div class="bar">
            <div class="name">产品密钥:</div>
@@ -48,17 +42,9 @@
      </div>
    </div>
    <el-dialog
      title="再次确认"
      :visible.sync="dialogVisible"
      custom-class="my-confirm"
    >
    <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="iconfont" style="color: orangered; font-size: 40px; margin-bottom: 10px">&#xe6e6;</span>
        <span class="ver-text">
          产品密钥导出后,系统大部分功能将无法使用,请确认是否继续?
        </span>
@@ -71,7 +57,7 @@
        <ul>
          <li style="list-style: inside">如系统已激活,在激活页面导出即可;</li>
          <li style="list-style: inside">
            如设备未激活,在SmartAI激活页面扫码获取
            {{ `"如设备未激活,请在${product_name}激活页面扫码获取"` }}
          </li>
        </ul>
        <!-- <span style="color: #8f949a; font-size: 14px"
@@ -80,11 +66,7 @@
      </div>
      <!--  -->
      <div class="pw">
        <el-input
          size="small"
          placeholder="请输入管理员密码"
          v-model="password"
        ></el-input>
        <el-input size="small" placeholder="请输入管理员密码" v-model="password"></el-input>
      </div>
      <div class="validate">
        <form id="myForm">
@@ -97,15 +79,8 @@
          >
          </el-input>
        </form>
        <el-button size="small" @click="txtbtn" type="primary"
          >导入文件</el-button
        >
        <input
          type="file"
          @change="loadTextFromFile"
          id="txt"
          style="display: none"
        />
        <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">
@@ -119,10 +94,11 @@
</template>
<script>
import { getSN, cancelAuthorization } from "@/api/system";
import { getSN, cancelAuthorization, getVasystemInfo } from "@/api/system"
export default {
  mounted() {
    this.refreshSn();
    this.refreshSn()
  },
  data() {
    return {
@@ -130,76 +106,81 @@
      expireTime: "",
      serializedNumber: "",
      secrectKey: "",
      q: "",
      queryCode: "",
      activeState: "已激活",
      password: "",
      dialogVisible: false,
    };
      productName: "",
      copyright: ""
    }
  },
  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;
          this.authorization = res.data.authorization
          this.expireTime = res.data.expireTime
          this.serializedNumber = res.data.sn
          this.queryCode = res.data.q
        }
      });
      })
      getVasystemInfo().then((rsp) => {
        this.productName = rsp.product_name
        this.copyright = rsp.copyright
      })
    },
    confirmAgain() {
      this.dialogVisible = true;
      this.dialogVisible = true
    },
    txtbtn() {
      document.getElementById("txt").click();
      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);
      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();
      this.secrectKey = this.secrectKey.trim()
      this.password = this.password.trim()
      if (this.secrectKey == "" || this.password == "") {
        this.$message.warning("请先填写密码和请求码");
        return;
        this.$message.warning("请先填写密码和请求码")
        return
      }
      cancelAuthorization({
        q: this.secrectKey,
        passwd: this.password,
        down: 1,
        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;
          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;
      });
    },
  },
};
        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 {
@@ -213,8 +194,8 @@
  border-left: 4px solid #f2f2f7;
  .el-dialog {
    width: 640px;    border-radius: 24px;
    width: 640px;
    border-radius: 24px;
  }
  .el-dialog__header {
@@ -242,38 +223,38 @@
  }
  .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;
    .btns {
      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;
      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;
  }
@@ -282,14 +263,14 @@
    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;
      }
      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;
@@ -356,11 +337,8 @@
    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 {
    .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 {