Administrator
2022-05-09 c7735db135f9c3c99224d8b5d2157926efde0977
src/views/qiandao/forms.vue
@@ -5,6 +5,7 @@
      ref="form"
      v-model="obj"
      :option="option"
      res="formss"
      @reset-change="emptytChange"
    >
      <!-- @submit="submit" -->
@@ -35,7 +36,33 @@
import { mapGetters } from "vuex";
export default {
  computed: {
    ...mapGetters(["userInfo", "cardInfor", "haveCardid", "useZhiWen"]),
    ...mapGetters([
      "userInfo",
      "cardInfor",
      "haveCardid",
      "useZhiWen",
      "isClears",
    ]),
  },
  watch: {
    isClears() {
      if (this.isClears) {
        this.obj = {
          name: "",
          national: "",
          certAddress: "",
          sex: "",
          imgs: "",
          yxqend: "",
          yxqstart: "",
          birthday: "",
          id: "",
          qfjg: "",
        };
        this.emptytChange();
        this.$store.commit("setIsClears", false);
      }
    },
  },
  mounted() {
    // console.log(CertCtl);
@@ -45,12 +72,34 @@
      this.cardShebei = CertCtl.connect();
      //如果result为空,代表读卡插件未启动
      if (this.cardShebei == "") {
        console.log("未启动读卡插件!");
        console.log("未启动读卡插件!1");
        this.$confirm(
          "未安装身份证设备驱动,请安装后重试!点击确定开始刷新页面,点击取消需手动刷新?",
          "提示",
          {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }
        )
          .then(() => {
            location.reload();
          })
          .catch(() => {
            // this.$message({
            //   type: 'info',
            //   message: '已取消删除'
            // });
          });
        this.noone = true;
        return;
      } else {
        //result页面回显
        console.log("ok!");
      }
    } catch (e) {}
    } catch (e) {
      // console.log(e, "未启动读卡插件!2");
    }
    if (this.intTime) {
      clearInterval(this.intTime);
@@ -64,10 +113,13 @@
      cardShebei: "",
      intTime: "", //自动获取身份证;
      obj: {},
      noone: false,
      option: {
        // mockBtn: true,
        // submitText: "完成",
        // printBtn: true,
        // emptyBtn: false,
        size: "small",
        labelWidth: 70,
        submitBtn: false,
        disabled: true,
@@ -131,12 +183,16 @@
  methods: {
    setIntervals: function () {
      let that = this;
      if (this.noone) {
        console.log("请安装驱动!");
        return;
      }
      this.intTime = setInterval(function () {
        if (!that.haveCardid) {
          //定时读卡
          let result = CertCtl.readCert();
          if (result == "") {
            console.log("未启动读卡插件!");
            console.log("未启动读卡插件!3");
          } else {
            var resultObj = eval("(" + result + ")");
            //resultFlag为0代表读卡成功
@@ -144,20 +200,31 @@
              //回显相关数据
              // console.log(resultObj, 123);
              const data = resultObj.resultContent;
              // 判断是否是重新读卡
              // if (that.obj.id == data.certNumber) {
              //   //同一张身份证-不更新数据
              //   return;
              // }
              //赋值数据
              that.obj = {
                name: data.partyName,
                national: data.nation,
                certAddress: data.certAddress,
                // sex:
                //   data.certType == 0
                //     ? "未知"
                //     : data.certType == 1
                //     ? "男"
                //     : data.certType == 2
                //     ? "女"
                //     : data.certType == 9
                //     ? "未说明"
                //     : "未能识别",
                sex:
                  data.certType == 0
                    ? "未知"
                    : data.certType == 1
                    ? "男"
                    : data.certType == 2
                  data.gender == 0
                    ? "女"
                    : data.certType == 9
                    ? "未说明"
                    : data.gender == 1
                    ? "男"
                    : "未能识别",
                imgs: "data:image/bmp;base64," + data.identityPic,
                yxqend:
@@ -181,6 +248,7 @@
                id: data.certNumber,
                qfjg: data.certOrg,
              };
              // console.log("应用数据");
              that.$store.commit("setCardInfor", that.obj);
              that.$store.commit("setCardidState", true);
            } else if (resultObj.resultFlag == "-1") {
@@ -189,6 +257,9 @@
              } else {
                // console.log(resultObj.errorMsg);
                //无卡片提醒
                that.obj = {
                  id: "",
                };
              }
            } else if (resultObj.resultFlag == "-2") {
              console.log(resultObj.errorMsg);
@@ -207,7 +278,7 @@
        clear: true,
      };
      this.useZhiWen("setZhiwenData", zhiwen);
      this.$message.success("清空身份证数据");
      // this.$message.success("清空身份证数据");
    },
    // useZhiWen: function (fn, vals) {
    //   //读取指纹实例
@@ -224,13 +295,14 @@
</script>
<style lang="scss" scoped>
.zhiwenMain {
  width: 100%;
  height: 220px;
  width: 180px;
  height: 247px;
  // border: 1px solid rgba($color: #d3d3d3, $alpha: 1);
}
.formsss {
  height: 100% !important;
  // overflow-x: hidden;
  // border: 1px solid rgb(0, 255, 64);
  // overflow-y: scroll;
}
.imgss {