<script>
export default {
  data() {
    return {
      basedata: {},
      title: "",
    };
  },
  onLaunch: function () {
    //console.log('App Launch')
    this.init();
    this.formatPlat();
  },
  onShow: function () {
    //console.log('App Show')
  },
  onHide: function () {
    //console.log('App Hide')
  },
  methods: {
    init() {
      console.log(uni.getStorageSync("basedata"));
      // if (uni.getStorageSync("basedata")) {
      //   this.basedata = uni.getStorageSync("basedata");
      //   this.formatTabbar();
      //   this.formatNavigation();
      // } else {
      this.request2(
        {
          url: "/api/Mall/GetHome",
          data: {},
        },
        (res) => {
          uni.setStorageSync("basedata", res.data);
          this.basedata = res.data;
          console.log("赋值：")
          console.log(res.data.mall.setting.mallStyle.main)
          this.$uiConfig.mainColor=res.data.mall.setting.mallStyle.main
          this.$uiConfig.secondary=res.data.mall.setting.mallStyle.secondary
          this.formatTabbar();
          this.formatNavigation();
        }
      );
      //}
    },
    formatPlat() {
      let modelmes = uni.getSystemInfoSync().model;
      let tempMoble = Boolean;
      if (
        modelmes.indexOf("iPhone X") >= 0 ||
        modelmes.indexOf("iPhone XR") >= 0 ||
        modelmes.indexOf("iPhone XS") >= 0 ||
        modelmes.indexOf("iPhone 12") >= 0 ||
        modelmes.indexOf("iPhone 11") >= 0 ||
        modelmes.indexOf("iPhone11") >= 0 ||
        modelmes.indexOf("iPhone12") >= 0 ||
        modelmes.indexOf("iPhoneXR") >= 0 ||
        modelmes.indexOf("iPhoneX") >= 0
      ) {
        tempMoble = true;
      } else {
        tempMoble = false;
      }
      this.$uiConfig.is_bang = tempMoble;
    },
    formatNavigation() {
      uni.setNavigationBarColor({
        frontColor: this.$uiConfig.topstyle.textColor,
        backgroundColor: this.$uiConfig.topstyle.background,
        animation: {
          duration: 400,
          timingFunc: "easeIn",
        },
      });
      // uni.setNavigationBarTitle({
      //   title: this.basedata.mall.name,
      // });
    },
    formatTabbar() {
      let navs = this.basedata.navbar.navs;
      this.$uiConfig.topstyle.background = this.basedata.navbar.top_background_color;
      this.$uiConfig.topstyle.textColor = this.basedata.navbar.top_text_color;

      //   uni.setTabBarStyle({
      //     color: navs[0].color,
      //     selectedColor: navs[0].active_color,
      //     backgroundColor: this.basedata.navbar.bottom_background_color,
      //     borderStyle: "#ccc",
      //   });

      //   navs.forEach((x,i) => {
      //     uni.setTabBarItem({
      //       index: i,
      //       text: x.text,
      //       iconPath: x.icon,
      //       selectedIconPath: x.active_icon,
      //     });
      //   });
    },
  },
};
</script>

<style lang="scss">
@import "uview-ui/index.scss";
@font-face {
  font-family: "oswald";
  src: url("https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/smallapp/Oswald-Regular.ttf");
}
html,
body {
  font-family: "oswald" !important;
}
swiper {
  height: unset;
}
</style>
