<script>
import { DOOR_BIND_STATUS } from "@/utils/const";
import { getPlatformEnv } from "@/utils";
import zlbConfig from "@/common/js/zlbConfig";
import { getSsoUserInfo ,updateUserInfo} from "@/api/user";
import { storageUserInfo } from "@/utils/index";
import Track from "@/common/js/track"
import Vconsole from "vconsole";
// app.js
export default {
  globalData: {
    doorplateInfo: {
      code: "",
      bzdz: "",
    },
    options: {}, //小程序跳进来的参数
    verify: false, //是否验证过
    openid: "", //openid在浙里办app,浙里办微信小程序，浙里办支付宝小程序内指的是票据ticket
    doorInfo: {
      baseInfo: {
        uuid: "",
        doorplateCode: "",
        bzdz: "斗门北路216号",
        bzdz1: "浙江省宁波市奉化区岳林街道金钟社区斗门北路252号",
      },
    },
    jumpUrl: "",
    bindStatus: DOOR_BIND_STATUS.WAIT.VALUE,
    NBID: "",
    doorType: "",
    fwzlDicList: [], //房屋租赁字典列表
    // 导航栏高度
    navBarHeight: 0,
    // 胶囊距底部间距（顶部间距也是这个）
    menuBottom: 0,
    // 胶囊高度
    menuHeight: 0,
    statusBarHeight: 0,
    trackIns:null,
    isLogin:false,//是否单点登录
    calcNavBarInfo() {
      const res = uni.getSystemInfoSync();
      let menuButtonInfo = {};

      if (res.platform === "ios") {
        // ios设备的胶囊按钮都是固定的
        menuButtonInfo = {
          width: 87,
          height: 32,
          left: res.screenWidth - 7 - 87,
          right: res.screenWidth - 7,
          top: res.statusBarHeight + 4,
          bottom: res.statusBarHeight + 4 + 32,
        };
      } else {
        // 安卓通过api获取
        menuButtonInfo = uni.getMenuButtonBoundingClientRect();
      } //状态栏高度

      this.statusBarHeight = res.statusBarHeight; // 导航栏高度 = 状态栏到胶囊的间距（胶囊距上位置-状态栏高度）* 2 + 胶囊高度 + 状态栏高度

      this.navBarHeight =
        (menuButtonInfo.top - res.statusBarHeight) * 2 +
        menuButtonInfo.height +
        res.statusBarHeight; // 按钮上下边距高度

      this.menuBottom = menuButtonInfo.top - res.statusBarHeight; // 导航栏右边到屏幕边缘的距离

      this.menuRight = res.screenWidth - menuButtonInfo.right; // 导航栏高度

      this.menuHeight = menuButtonInfo.height;
      console.log(this);
    },
    menuRight: "",
  },
  onLaunch() {
//      if (localStorage.getItem('debug')==='true') {
        new Vconsole();
//      }
  },
  methods: {
    //监听globalData数据，回调执行
    watch(key, cb) {
      const data = this.globalData;
      let val = data[key];
      Object.defineProperty(data, key, {
        configurable: true,
        enumerable: true,
        set: function (value) {
          val = value;
          cb(value); // 执行回调方法
        },
        get: function () {
          return val; // 返回当前值
        },
      });
    },
  },
};
</script>

<style>
@import "./app.css";

/* #ifdef H5 */
@import "@/libs/vant.css";
/* #endif */
</style>

<style>
@font-face {
  font-family: uniicons;
  src: url("data:font/truetype;charset=utf-8;base64,[encoded data, 47680 characters]") format("truetype");
}

.uni-icons {
  font-family: uniicons;
  text-decoration: none;
  text-align: center;
}
</style>
