zhangzengfei
2022-04-26 ba5f0a22558ce40300fa1668d98ea74ad56fd1e3
初始化页面添加信息刷新
1个文件已修改
151 ■■■■ 已修改文件
src/pages/index/App.vue 151 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/index/App.vue
@@ -9,13 +9,7 @@
        <el-step title="注册信息"></el-step>
      </el-steps>
      <el-carousel
        ref="carousel"
        trigger="click"
        :loop="false"
        :autoplay="false"
        :initial-index="active"
      >
      <el-carousel ref="carousel" trigger="click" :loop="false" :autoplay="false" :initial-index="active">
        <el-carousel-item>
          <formAccount ref="form0"></formAccount>
        </el-carousel-item>
@@ -42,141 +36,138 @@
</template>
<script>
import formAccount from "@/pages/index/components/formAccount";
import formNet from "@/pages/index/components/formNet";
import formInfo from "@/pages/index/components/formInfo";
import {
  getInitInfo,
  savePassword,
  initNetwork,
  saveRegInfo,
  getRegInfo,
  isOnNet,
} from "./api";
import formAccount from "@/pages/index/components/formAccount"
import formNet from "@/pages/index/components/formNet"
import formInfo from "@/pages/index/components/formInfo"
import { getInitInfo, savePassword, initNetwork, saveRegInfo, getRegInfo, isOnNet } from "./api"
export default {
  created() {
    window.addEventListener("keydown", (event) => {
      if (event.keyCode === 9) {
        console.log("tabfalse13");
        event.preventDefault();
        console.log("tabfalse13")
        event.preventDefault()
      }
    });
    })
  },
  mounted() {
    this.getInitInfo();
    let message = "网络正常";
    this.getInitInfo()
    let message = "网络正常"
    function onLine(callback) {
      var img = new Image();
      var img = new Image()
      //临时判断网络是否通畅
      img.src = "http://apps.smartai.com/img/icon_logo.f78688b5.png";
      img.onload = function () {
        console.log("11111");
        if (callback) callback(true);
      };
      img.onerror = function () {
        console.log("22222");
        if (callback) callback(false);
      };
      img.src = "http://apps.smartai.com/img/icon_logo.f78688b5.png"
      img.onload = function() {
        console.log("11111")
        if (callback) callback(true)
      }
      img.onerror = function() {
        console.log("22222")
        if (callback) callback(false)
      }
    }
    onLine((flag) => {
      let message = "";
      let message = ""
      if (flag) {
        this.isNet = true;
        message = "已有网络";
        this.isNet = true
        message = "已有网络"
      } else {
        //网络断网效果图出来后,将此地改为跳转路径到效果图上
        message = "未配置网络";
        message = "无法连接互联网"
        this.$notify({
          message: message,
        });
          message: message
        })
      }
    });
    })
  },
  data() {
    return {
      active: 0,
      formData: {},
      isWhite: true,
      isNet: false,
    };
      isNet: false
    }
  },
  components: {
    formAccount,
    formNet,
    formInfo,
    formInfo
  },
  methods: {
    preForm() {
      if (this.active == 0) {
        return;
        return
      }
      this.active--;
      this.$refs["carousel"].prev();
      this.active--
      this.$refs["carousel"].prev()
    },
    async nextForm() {
      if (this.active == 2) {
        const data = this.$refs[`form${this.active}`].getFormData();
        await saveRegInfo(data);
        location.assign("/view/login/");
        return;
        const data = this.$refs[`form${this.active}`].getFormData()
        await saveRegInfo(data)
        location.assign("/view/login/")
        return
      }
      if (this.active == 0) {
        const data = this.$refs[`form${this.active}`].getFormData();
        const data = this.$refs[`form${this.active}`].getFormData()
        if (!data) {
          return false;
          return false
        }
        const res1 = await savePassword(data);
        console.log(data);
        this.active++;
        this.$refs["carousel"].next();
        const res1 = await savePassword(data)
        console.log(data)
        this.active++
        this.$refs["carousel"].next()
      }
      if (this.active == 1) {
        const data = this.$refs[`form${this.active}`].getFormData();
        initNetwork(data);
        this.active++;
        this.$refs["carousel"].next();
        const data = this.$refs[`form${this.active}`].getFormData()
        initNetwork(data)
        this.active++
        this.$refs["carousel"].next()
      }
      this.getInitInfo()
    },
    nextFormNot() {
      this.active++;
      this.$refs["carousel"].next();
      this.getInitInfo()
      this.active++
      this.$refs["carousel"].next()
    },
    async getInitInfo() {
      const res = await getInitInfo().catch((err) => {
        this.isWhite = false;
      });
        this.isWhite = false
      })
      console.log(res);
      console.log(res)
      if (res.data && res.data.initPwd && !res.data.initRegInfo) {
        const res1 = await getRegInfo();
        this.active = 1;
        console.log(res1);
        const res1 = await getRegInfo()
        this.active = 1
        console.log(res1)
        setTimeout(() => {
          this.$refs["carousel"].setActiveItem(1);
        }, 0);
          this.$refs["carousel"].setActiveItem(1)
        }, 0)
      }
      if (res.data && res.data.initPwd && res.data.initRegInfo) {
        location.assign("/view/login/");
        return;
        location.assign("/view/login/")
        return
      }
      this.isWhite = false;
    },
      this.isWhite = false
    }
  },
  destroyed() {
    window.removeEventListener("keydown", (event) => {
      console.log(event.value);
      event.preventDefault();
    });
  },
};
      console.log(event.value)
      event.preventDefault()
    })
  }
}
</script>
<style lang="scss" scoped>
@@ -331,4 +322,4 @@
  height: 100%;
  background-color: #fff;
}
</style>
</style>