CarSimulationMain.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <script setup>
  2. import { CommonValStore } from "../ChengGuangYuanJing/store/CommonValStore.js";
  3. import { CarMyThreeWorldStore } from "../CarSimulation/CarThreeWorldEvent/store/CarMyThreeWorldStore.js";
  4. import CarThreeWorldEventMain from "../CarSimulation/CarThreeWorldEvent/CarThreeWorldEventMain.vue";
  5. import LoadingDemo from "../CarSimulation/CarThreeWorldEvent/LoadingDemo.vue";
  6. import CarCourseChapter3dView from "../CarSimulation/CarCourseChapter3d/view.vue";
  7. import { CarCourseChapter3dShowStore } from "../CarSimulation/CarCourseChapter3d/store/CarCourseChapter3dShowStore.js";
  8. import { CarProcessDb } from "../CarSimulation/CarThreeWorldEvent/event/CarProcessDb.js";
  9. const props = defineProps({
  10. // 重置流程到第一个流程
  11. processInitRestTime : {
  12. type: String,
  13. default : function() {
  14. return "0";
  15. }
  16. },
  17. });
  18. // 定义发射给父组件的方法
  19. const emits = defineEmits([
  20. 'callbackShengNa',
  21. 'callbackChuanGongZuoFu',
  22. 'callbackProcessUpdate',
  23. ])
  24. /**
  25. * 是否触发回到声纳车逻辑
  26. * bool
  27. */
  28. const callbackShengNaEvent = (bool) => {
  29. emits('callbackShengNa', bool);
  30. }
  31. /**
  32. * 是否穿完工作服回调
  33. * bool
  34. */
  35. const callbackChuanGongZuoFuEvent = (bool) => {
  36. emits('callbackChuanGongZuoFu', bool);
  37. }
  38. /**
  39. * 每次进入流程回调
  40. * db
  41. */
  42. const callbackProcessUpdateEvent = (db) => {
  43. emits('callbackProcessUpdate', db);
  44. }
  45. // 操作帮助点击退出
  46. const showOperationHelpExitEvent = () => {
  47. // 触发下一步逻辑
  48. // nextStep();
  49. };
  50. /**
  51. * 车的完成下井实验
  52. */
  53. const carShutDownEvent = () => {
  54. // 触发下一步逻辑
  55. // nextStep();
  56. let configDownUpdate = CarProcessDb.find().configDownUpdate();
  57. if (configDownUpdate != null && configDownUpdate != undefined) {
  58. CarMyThreeWorldStore().obj.processConfig = configDownUpdate;
  59. console.log(
  60. "carShutDownEvent 切换下一步的配置", configDownUpdate
  61. );
  62. }
  63. };
  64. /**
  65. * 车的相机截图
  66. * img base64位图片
  67. */
  68. const carCameraScreenshotEvent = (img) => {
  69. // console.log(
  70. // "车的相机截图", img
  71. // );
  72. // // 将 base64为转换成,Blob格式
  73. // let objBlob = dataURLtoBlob(img);
  74. // // blob 转换成 file对象
  75. // const file = new File([objBlob], 'example.png', { type: 'text/plain' });
  76. CarCourseChapter3dShowStore().show.showToastViewBool = false;
  77. CarCourseChapter3dShowStore().show.showPromptEvent('截图上传完成', null, function (res) {
  78. // console.log("yes", res);
  79. });
  80. };
  81. /**
  82. * 将base64转换为blob
  83. * @param dataurl base64位图片
  84. */
  85. const dataURLtoBlob = (dataurl) => {
  86. let arr = dataurl.split(','),
  87. mime = arr[0].match(/:(.*?);/)[1],
  88. bstr = atob(arr[1]),
  89. n = bstr.length,
  90. u8arr = new Uint8Array(n);
  91. while (n--) {
  92. u8arr[n] = bstr.charCodeAt(n);
  93. }
  94. return new Blob([u8arr], { type: mime });
  95. };
  96. /**
  97. * 上一步是否显示
  98. * open true - 显示, false - 隐藏
  99. */
  100. const tipsBtnsUpOpenEvent = (open) => {
  101. // console.log("上一步是否显示", open);
  102. CarMyThreeWorldStore().obj.tipsBtnsUpOpenEventBool = open;
  103. };
  104. /**
  105. * 下一步是否显示
  106. * open true - 显示, false - 隐藏
  107. */
  108. const tipsBtnsDownOpenEvent = (open) => {
  109. // console.log("下一步是否显示", open);
  110. CarMyThreeWorldStore().obj.tipsBtnsDownOpenEventBool = open;
  111. };
  112. /**
  113. * 是否到声纳车逻辑
  114. * bool
  115. */
  116. CarProcessDb.find().callbackShengNa = function(bool) {
  117. callbackShengNaEvent(bool);
  118. }
  119. /**
  120. * 是否穿完工作服了
  121. * bool
  122. */
  123. CarProcessDb.find().callbackChuanGongZuoFu = function(bool) {
  124. // console.log("是否穿完工作服了 CarProcessDb.find().callbackChuanGongZuoFu ===> ", bool);
  125. callbackChuanGongZuoFuEvent(bool);
  126. }
  127. // 自定义回调流程
  128. CarProcessDb.find().callbackProcessUpdate = function(res) {
  129. // console.log(
  130. // "callbackProcessUpdate res", res
  131. // );
  132. callbackProcessUpdateEvent(res);
  133. }
  134. </script>
  135. <template>
  136. <div class="CarSimulationMain">
  137. <!-- 自定义自己建的加载3d场景的逻辑 -->
  138. <CarThreeWorldEventMain
  139. :processInitRestTime="props.processInitRestTime"
  140. @tipsBtnsUpOpen="tipsBtnsUpOpenEvent"
  141. @tipsBtnsDownOpen="tipsBtnsDownOpenEvent"
  142. ></CarThreeWorldEventMain>
  143. <!-- 自定义加载百分比 -->
  144. <LoadingDemo
  145. v-if="CarMyThreeWorldStore().obj.loadSuccess == false"
  146. ></LoadingDemo>
  147. <!-- 我们会通过一个全局的变量,来控制什么组件是否显示 CarMyThreeWorldStore().obj.loadSuccess 是一种方式,3d场景加载完成后会变成 true -->
  148. <div
  149. v-show="CarMyThreeWorldStore().obj.loadSuccess == true"
  150. >
  151. <CarCourseChapter3dView
  152. @showOperationHelpExitEvent="showOperationHelpExitEvent"
  153. @carCameraScreenshot="carCameraScreenshotEvent"
  154. @carShutDown="carShutDownEvent"
  155. ></CarCourseChapter3dView>
  156. </div>
  157. </div>
  158. </template>
  159. <style lang="scss" scoped>
  160. .CarSimulationMain * {
  161. -moz-user-select: none;
  162. -webkit-user-select: none;
  163. -ms-user-select: none;
  164. -khtml-user-select: none;
  165. user-select: none;
  166. }
  167. .CarSimulationMain {
  168. position: fixed;
  169. z-index: 0;
  170. width: 0px;
  171. height: 0px;
  172. top: 0px;
  173. left: 0px;
  174. }
  175. </style>