export function scanCode() {
  uni.scanCode({
    scanType: ["qrCode"],
    success: (res) => {
      console.log(res);
      if (res.scanType === "QR_CODE" && res.result) {
        deCode(res.result);
      }
    },
  });
}

export function deCode(url: string) {
  // 线上 https://www.kuaiyuman.cn/#001091
  if (
    /h5\.en-plus\.com/.test(url) ||
    /www.en-plus.cn/.test(url) ||
    /dev\.en-plus\.com\.cn/.test(url) ||
    /dev\.kuaiyuman\.cn/.test(url) || 
    /www\.kuaiyuman\.cn/.test(url)
  ) {
    const split = url.split("/");
    const sn = split[split.length - 1].replace("#", "");
    uni.navigateTo({
      url: `/pages-charge/appointment/appointment?sn=${sn}`,
    });
  } else {
    uni.showToast({
        icon: "none",
      title: "请扫描正确的二维码",
      showCancel: false,
        duration:1000
    });
  }
}
