examCamera.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <view>
  3. <zhuapaiConfirm ref="zhuapaiConfirmRef" @success="zpConfirmSuccess" @error="zpConfirmError"
  4. @cancel="zpConfirmCancel" key="1"></zhuapaiConfirm>
  5. </view>
  6. </template>
  7. <script setup>
  8. import {
  9. onLoad,
  10. onShow,
  11. onHide
  12. } from "@dcloudio/uni-app";
  13. import {
  14. ref,nextTick
  15. } from "vue";
  16. import zhuapaiConfirm from "@/components/zhuapaiConfirm/index.vue";
  17. const opt = ref(null);
  18. const zhuapaiConfirmRef = ref(null);
  19. onLoad((options) => {
  20. opt.value = options;
  21. setTimeout(() => {
  22. zhuapaiConfirmRef.value.showDialog()
  23. },1000)
  24. })
  25. function zpConfirmSuccess() {
  26. uni.redirectTo({
  27. url: `/pages/client/Kaoshi/exam?ksId=${opt.value.ksId}&zhuapai=${opt.value.zhuapai}&userKaozhengId=${opt.value.userKaozhengId}&from=${opt.value.from}`
  28. })
  29. }
  30. function zpConfirmError(e) {
  31. uni.showToast({
  32. icon: 'none',
  33. title: '考试环境异常请检测摄像头是否正常',
  34. duration: 3000,
  35. mask: true // 防止触摸穿透
  36. })
  37. setTimeout(() => {
  38. handleBack();
  39. }, 3000)
  40. }
  41. function zpConfirmCancel() {
  42. handleBack();
  43. }
  44. function handleBack() {
  45. const pages = getCurrentPages();
  46. if (pages.length > 1) {
  47. uni.navigateBack()
  48. } else {
  49. history.back();
  50. }
  51. }
  52. </script>
  53. <style>
  54. </style>