<script>
export default {
  data() {
    return {
      basedata: {},
      title: "",
    };
  },
  onLaunch: function () {
    this.init();
    this.formatPlat();
	let that=this
	wx.getSystemInfo({
		success(res) {
			let lift=res.screenHeight-res.safeArea.bottom
			that.$uiConfig.is_bang = Number(lift)>0?true:false
		}
	})
  },
  onShow: function (options) {
	  if(options.referrerInfo.extraData){
		uni.setStorageSync("jxhData",options.referrerInfo.extraData)
	  }
  },
  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";
@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>
