<script>
export default {
  data() {
    return {
      basedata: {},
      title: "",
    };
  },
  onLaunch: function () {
    //console.log('App Launch')
    this.init();
    this.formatPlat();
  },
  onShow: function () {
    //console.log('App Show')
    this.$utils.VersionUpdate()
  },
  onHide: function () {
    //console.log('App Hide')
  },
  methods: {
    init() {
      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);
          uni.setStorageSync('navs', res.data.navbar.navs??[])
          this.basedata = res.data;
          this.$uiConfig.mainColor=res.data.mall.setting.mallStyle.main
          this.$uiConfig.secondary=res.data.mall.setting.mallStyle.secondary
		  if(res.data.mall.setting.mallStyle.pricecolor){
			  this.$uiConfig.pricecolor=res.data.mall.setting.mallStyle.pricecolor
		  }
          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";
@import url("./asset/font/iconfont.css");
@import url('asset/font/tffont.css');
/* 0123456789首页订单我的暂无图片第天 */
@font-face {
  font-family: "nav-font";src: url("//at.alicdn.com/wf/webfont/MQHUV6e56ce5/uWqIjWPWlbHR.woff2") format("woff2"),
  url("//at.alicdn.com/wf/webfont/MQHUV6e56ce5/uBscuKyX34mb.woff") format("woff");
  font-display: swap;
}
@font-face {
  font-family: "logo-font";src: url("//at.alicdn.com/wf/webfont/MQHUV6e56ce5/kznKMVuxE1tP.woff2") format("woff2"),
  url("//at.alicdn.com/wf/webfont/MQHUV6e56ce5/ViySHjFRkPg9.woff") format("woff");
  font-display: swap;
}
@font-face {
  font-family: "DFPLiJinHeiW8-GB";
  src: url("https://im.oytour.com/tripfont/cb76573b1580477fbea1ce0cc0d136e5.woff");
}

// @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;
  
}
image{will-change: transform}
</style>
