index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <web-view
  3. v-show="!controlStore.popup.show"
  4. ref="faceView"
  5. id="faceView"
  6. class="faceView"
  7. src="/static/face/door.html"
  8. bindmessage="receiveMessage"
  9. :webview-styles="webviewStyles"
  10. @message="onMessage"
  11. >
  12. </web-view>
  13. <u-popup :show="controlStore.popup.show" bgColor="#474747" :zIndex="10074">
  14. <oaPassBody :show="controlStore.popup.show" @change="change" @close="close"></oaPassBody>
  15. </u-popup>
  16. </template>
  17. <script setup>
  18. /*----------------------------------依赖引入-----------------------------------*/
  19. import config from "@/config";
  20. import { onLoad, onShow, onReady, onHide, onLaunch, onUnload, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  21. import { ref, reactive, computed, getCurrentInstance, toRefs, inject, nextTick, watch } from "vue";
  22. /*----------------------------------接口引入-----------------------------------*/
  23. /*----------------------------------组件引入-----------------------------------*/
  24. import oaPassBody from "@/components/oa-passBody/index";
  25. /*----------------------------------store引入-----------------------------------*/
  26. import { controlStores } from "@/store/modules/index";
  27. /*----------------------------------公共方法引入-----------------------------------*/
  28. const { proxy } = getCurrentInstance();
  29. const controlStore = controlStores();
  30. /*----------------------------------公共变量-----------------------------------*/
  31. const state = reactive({
  32. version: computed(() => {
  33. return config.appInfo.version;
  34. }),
  35. webviewStyles: {
  36. width: "100%",
  37. height: "100%",
  38. },
  39. });
  40. const { version, webviewStyles } = toRefs(state);
  41. // 初始化
  42. function init() {
  43. controlStore.initCamera(); //初始化摄像头
  44. // controlStore.initNfc();//初始化NFC
  45. controlStore.initData(); //初始化数据
  46. controlStore.openInterval("door"); //开启门禁数据定时任务
  47. }
  48. // 密码开门组件确认事件
  49. function change(event) {
  50. if (event == controlStore.form.door.password) {
  51. controlStore.popup.show = false;
  52. controlStore.analysisData({ funcName: "点击开门" });
  53. } else {
  54. controlStore.popup.show = false;
  55. proxy.$modal.msg("密码错误");
  56. }
  57. }
  58. // 密码开门组件关闭事件
  59. function close(event) {
  60. controlStore.popup.show = event;
  61. }
  62. /**
  63. * @接收子页面传过来的值
  64. */
  65. function onMessage(e) {
  66. controlStore.analysisData(e.detail.data[0]);
  67. }
  68. // #ifdef H5
  69. window.onmessage = function (event) {
  70. controlStore.analysisData(event.data);
  71. };
  72. // #endif
  73. onLoad((options) => {});
  74. onShow(() => {
  75. init();
  76. });
  77. onHide(() => {
  78. controlStore.clearInterval("door"); //关闭门禁数据定时任务
  79. });
  80. onUnload(() => {
  81. controlStore.clearInterval("door"); //关闭门禁数据定时任务
  82. });
  83. </script>
  84. <style>
  85. .faceView {
  86. width: 100% !important;
  87. height: 100% !important;
  88. }
  89. iframe {
  90. width: 100% !important;
  91. height: 100% !important;
  92. border-width: 0;
  93. }
  94. </style>
  95. <style lang="scss" scoped>
  96. :deep() {
  97. .u-modal {
  98. width: 20rem !important;
  99. &__title {
  100. font-size: 18px !important;
  101. }
  102. &__selector-item {
  103. color: black;
  104. }
  105. .slot-content {
  106. font-size: 16px;
  107. width: 100%;
  108. }
  109. }
  110. }
  111. </style>