export function isWeixin() {
  var ua = window.navigator.userAgent.toLowerCase();
  if (
    ua.match(/MicroMessenger/i) == "micromessenger" ||
    ua.match(/_SQ_/i) == "_sq_"
  ) {
    return true;
  } else {
    return false;
  }
}

export function isBase64(str) {
  var reg =
    /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i;
  return reg.test(str);
}
export function isObject(object) {
  return object !== null && typeof object === "object";
}
export function isEmptyObject(object) {
  return this.isObject(object) && Object.keys(object).length < 1;
}

export function modalComfirm(config = {}, t) {
  if (!isObject(config)) {
    config = {
      content: config,
      title: t,
    };
  }
  let {
    title = "提示",
    showCancel = false,
    content,
    scb = uni.navigateBack,
    ecb,
  } = config;
  uni.showModal({
    title: title,
    showCancel: showCancel,
    content: content,
    success: (k) => {
      if (k.confirm) {
        scb && scb();
      } else {
        ecb && ecb();
      }
    },
  });
}
