"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_api = require("../../utils/api.js");
if (!Array) {
  const _easycom_uv_qrcode2 = common_vendor.resolveComponent("uv-qrcode");
  _easycom_uv_qrcode2();
}
const _easycom_uv_qrcode = () => "../../uni_modules/uv-qrcode/components/uv-qrcode/uv-qrcode.js";
if (!Math) {
  _easycom_uv_qrcode();
}
const _sfc_main = {
  __name: "quickMark",
  setup(__props) {
    const QRCodeUrl = common_vendor.ref("");
    const brightness = common_vendor.ref(0);
    const options = {
      typeNumber: -1,
      foregroundImageBorderRadius: 5,
      foregroundImageSrc: "/static/images/school-logo.jpg"
    };
    const timer = common_vendor.ref(null);
    const timerCode = common_vendor.ref(null);
    common_vendor.onLoad((data) => {
      QRCodeUrl.value = data.value;
      common_vendor.index.onUserCaptureScreen(showTips);
      getBrightness();
      setBrightness(1);
      timer.value = setInterval(() => {
        common_vendor.index.getScreenRecordingState({
          success: (res) => {
            if (res.state == "on") {
              common_vendor.index.showModal({
                title: "提示",
                content: "此页面不允许录屏",
                showCancel: false,
                success: () => {
                  common_vendor.index.redirectTo({
                    url: "/pages/home/home"
                  });
                }
              });
            }
          }
        });
      }, 1e3);
      if (common_vendor.wx$1.setVisualEffectOnCapture) {
        common_vendor.wx$1.setVisualEffectOnCapture({
          visualEffect: "hidden",
          complete: function(res) {
            console.log("开启", res);
          }
        });
      }
    });
    common_vendor.onShow(() => {
      if (timerCode.value) {
        clearInterval(timerCode.value);
      }
      timerCode.value = setInterval(() => {
        getQrcode();
      }, 55e3);
    });
    common_vendor.onUnload(() => {
      common_vendor.index.offUserCaptureScreen();
      setBrightness(brightness.value);
      clearInterval(timer.value);
      if (common_vendor.wx$1.setVisualEffectOnCapture) {
        common_vendor.wx$1.setVisualEffectOnCapture({
          visualEffect: "none",
          complete: function(res) {
            console.log("解除", res);
          }
        });
      }
      clearInterval(timerCode.value);
    });
    const getQrcode = async () => {
      const res = await utils_api.myRequest({
        url: "/wanzai/api/smartQrcode/generateQrcode",
        data: {
          userId: common_vendor.index.getStorageSync("userInfo").id
        }
      });
      QRCodeUrl.value = res.data.qrcode;
    };
    const getBrightness = () => {
      common_vendor.index.getScreenBrightness({
        success: (res) => {
          brightness.value = res.value;
        }
      });
    };
    const setBrightness = (data) => {
      common_vendor.index.setScreenBrightness({
        value: data
      });
    };
    const showTips = () => {
      common_vendor.index.showToast({
        title: "不要把二维码给他人使用，否则将冻结账号",
        icon: "none",
        duration: 3500
      });
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.sr("qrcodeRef", "c8904830-0"),
        b: common_vendor.p({
          size: "400rpx",
          value: QRCodeUrl.value,
          options
        })
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c8904830"], ["__file", "E:/workSpace/WanZai_School_app/pages/quickMark/quickMark.vue"]]);
wx.createPage(MiniProgramPage);
