"use strict";
const common_vendor = require("../../common/vendor.js");
const store_index = require("../../store/index.js");
require("../../api/index.js");
require("../../api/request.js");
require("../../config/index.js");
if (!Array) {
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  _easycom_uni_popup2();
}
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
  _easycom_uni_popup();
}
const _sfc_main = {
  __name: "visionTest",
  setup(__props) {
    const store = store_index.useStore();
    common_vendor.onLoad((e) => {
      var _a;
      if (!((_a = store.userInfo) == null ? void 0 : _a.has_operation)) {
        setTimeout(() => {
          inputDialog.value.open();
        }, 0);
      }
    });
    const inputDialog = common_vendor.ref();
    const inputDialog2 = common_vendor.ref();
    const inputDialog3 = common_vendor.ref();
    const step1 = common_vendor.ref("先测右眼，请遮住左眼");
    common_vendor.ref("请遮住右眼");
    const countDown = common_vendor.ref(5);
    common_vendor.ref(1);
    const current_img = common_vendor.ref("");
    const current_img_index = common_vendor.ref(null);
    const sizes = common_vendor.ref([
      {
        size: 23,
        vision: 4.2
      },
      {
        size: 19,
        vision: 4.2
      },
      {
        size: 15,
        vision: 4.2
      },
      {
        size: 11,
        vision: 4.2
      },
      {
        size: 9,
        vision: 4.2
      },
      {
        size: 7,
        vision: 4.2
      },
      {
        size: 6,
        vision: 4.2
      },
      {
        size: 4,
        vision: 4.2
      },
      {
        size: 3,
        vision: 4.2
      }
    ]);
    const show_size = common_vendor.ref({
      width: "29px"
    });
    const num = common_vendor.ref(0);
    const now = common_vendor.ref(1);
    const vision_info = common_vendor.ref({
      left: 4,
      right: 4.1
    });
    function toStart() {
      inputDialog.value.close();
      inputDialog2.value.open();
      let s = setInterval(() => {
        countDown.value--;
        if (countDown.value == 0) {
          clearInterval(s);
          inputDialog2.value.close();
        }
      }, 1e3);
      randomFunc();
    }
    function randomFunc() {
      let ran = Math.ceil(Math.random() * 4);
      if (current_img_index.value == ran) {
        randomFunc();
      } else {
        current_img.value = "../../static/" + ran + ".png";
        current_img_index.value = ran;
      }
    }
    function chooseFunc(index) {
      randomFunc();
      if (num.value > 8) {
        if (now.value == 2) {
          return;
        }
        show_size.value.width = "29px";
        countDown.value = 5;
        step1.value = "测左眼，请遮住右眼";
        num.value = 8;
        now.value = 2;
        toStart();
      } else {
        show_size.value.width = sizes.value[num.value].size + "px";
        num.value++;
      }
    }
    function okFunc() {
      inputDialog3.value.open();
    }
    return (_ctx, _cache) => {
      return {
        a: current_img.value,
        b: common_vendor.s(show_size.value),
        c: common_vendor.o(($event) => chooseFunc()),
        d: common_vendor.o(($event) => chooseFunc()),
        e: common_vendor.o(($event) => chooseFunc()),
        f: common_vendor.o(($event) => chooseFunc()),
        g: common_vendor.o(($event) => chooseFunc()),
        h: common_vendor.o(toStart),
        i: common_vendor.sr(inputDialog, "29752d91-0", {
          "k": "inputDialog"
        }),
        j: common_vendor.p({
          ["is-mask-click"]: true
        }),
        k: common_vendor.t(countDown.value),
        l: common_vendor.t(step1.value),
        m: common_vendor.sr(inputDialog2, "29752d91-1", {
          "k": "inputDialog2"
        }),
        n: common_vendor.p({
          ["is-mask-click"]: false
        }),
        o: common_vendor.t(vision_info.value.left),
        p: common_vendor.t(vision_info.value.right),
        q: common_vendor.o(okFunc),
        r: common_vendor.sr(inputDialog3, "29752d91-2", {
          "k": "inputDialog3"
        }),
        s: common_vendor.p({
          ["is-mask-click"]: true
        })
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-29752d91"], ["__file", "F:/项目2023/视力表/vision-record/pages/index/visionTest.vue"]]);
wx.createPage(MiniProgramPage);
