<script>
import PHead from "./head/index.vue";
import PMain from "./main/index.vue";

import UpdateDialog from "@/views/design/updateDialog.vue";

export default {
  components: { PHead, PMain, UpdateDialog },
  data() {
    return {
      user: {},
      factoryType: "CN",
    };
  },
  mounted() {
    this.user = this.$dataStore.get("user");
    if (this.user.factory && this.user.factory.countryCode) {
      this.factoryType = this.user.factory.countryCode;
    }
    // console.log(17, this.user);
    this.$refs.updateDialog.checkUpdate().then((data) => {
      // console.log(17, data);

      if (data) {
        // 有新版本更新
        this.$refs.updateDialog.open(data);
      }
    });
  },
};
</script>

<template>
  <div class="page">
    <p-head :user="user" :factoryType="factoryType" />
    <p-main :factoryType="factoryType" />
    <update-dialog ref="updateDialog" />
  </div>
</template>

<style scoped>
.page {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
</style>
