import Taro from "@tarojs/taro";

const globalData = {
  // domain:'https://flossom.ecolite.com.cn',
  // domain: "https://project10.xlovery.com",
  // domain: "https://flossom.gzlingren.com",
  domain: "http://110.41.134.131:8080",
  // domain: "http://192.168.10.147:8080",
  imgUrl: "https://oss.flossom.com",
  imgUrl2: "https://oss.flossom.com",
  token: "",
  userinfo: {},
  params: {
    params: "",
  },
  bindid: "", //当前点击的进入主页的设备id
  bindinfo: {}, //当前点击的进入设备信息
  connection: 0, //连接秒速
  deviceName: "WM100",
  bluetoothinfo: {},
  matrixid: "", //头模仪器切换到fr200
  deviceInfo: {},
  InstrumentTypeEnum: {
    //仪器类型
    FR200: 1,
    MATRIX: 2,
    WL200: 3,
    FR380: 4,
    FR390: 5,
    M01: 6,
  },
  OtaDeviceTypeEnum: {
    WL200: "WL200",
    WE100: "WE100",
    FACIALMASK: "FacialMask",
    STAND: "Stand",
  },
  needAuthorization: false, // 是否需要授权隐私
  requestUrlList: [],
  safeAreaBottom: 0,
  deviceChineseName: {
    FR100: "",
    FR200: "",
    FR380: "",
    FR390: "",
    WL200: "",
    M01: "",
    WE100: "",
    WL200Stand: "舱体",
  },
};

export function setGlobalData(key, val) {
  globalData[key] = val;

  if (key === "token") {
    Taro.setStorageSync(key, val);
  }
}
export function getGlobalData(key) {
  if (key === "token") {
    globalData[key] = Taro.getStorageSync(key) || globalData["token"];
  }
  return globalData[key];
}
