check.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <headerBar
  3. title="拍摄物体镜头矫正"
  4. :menu="menu"
  5. showUser
  6. />
  7. <div class="check-wrap flex">
  8. <div class="check-page flex-col">
  9. <div class="main-container flex-col">
  10. <div class="content-wrapper flex-row justify-between">
  11. <div class="left-panel flex-col justify-between">
  12. <div class="tips-container flex-row" v-if="show">
  13. <img class="tips-icon" referrerpolicy="no-referrer" src="@/assets/images/Photography/tips-icon.png" />
  14. <span class="tips-tex">请在圆盘上摆上鞋子(注意左右脚),要求鞋外侧朝向拍照机,鞋子中轴线和红外线对齐</span>
  15. <img class="close-icon cu-p" referrerpolicy="no-referrer" src="@/assets/images/Photography/close-icon.png" @click="show = false"/>
  16. </div>
  17. <div class="camera-preview flex col center ">
  18. <span v-if="step === 1" class="fs-14">
  19. <img v-if="previewKey" class="camera-img" :src="preview+'?key='+previewKey" />
  20. </span>
  21. <template v-if="step === 2" >
  22. <img class="camera-img" :src="imageUrl+'?key='+imageUrlkey" />
  23. <span class="camera-description">这是一张用于检查镜头是否合适的测试图</span>
  24. </template>
  25. </div>
  26. </div>
  27. <div class="example-image flex-col"><img src="https://huilimaimg.cnhqt.com/frontend/zhihuiyin/demo.jpg?x-oss-process=image/resize,w_400"></div>
  28. </div>
  29. <div v-if="step === 1" class="action-button flex cente">
  30. <div @click="takePictures" class="check-button button--primary1 flex-col"><span class="button-text" v-loading="loading">拍照检查</span>
  31. </div>
  32. </div>
  33. <div v-else class="action-button flex center">
  34. <div @click="checkConfirm(false)" class="check-button button--white flex-col">
  35. <span class="button-text cu-p">重新拍照检查</span>
  36. </div>
  37. <router-link class="mar-left-20 " :to="{
  38. name: 'PhotographyShot'
  39. }">
  40. <div class="check-button button--primary1 flex-col">
  41. <span class="button-text cu-p">确认无误,下一步</span>
  42. </div>
  43. </router-link>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. <hardware-check
  49. isInitCheck
  50. @confirm="checkConfirm(true)"
  51. />
  52. </template>
  53. <script setup lang="ts">
  54. import { watchEffect,ref, reactive } from 'vue'
  55. import client from "@/stores/modules/client";
  56. import icpList from '@/utils/ipc'
  57. import useUserInfo from "@/stores/modules/user";
  58. import headerBar from '@/components/header-bar/index.vue'
  59. const clientStore = client();
  60. const menu = reactive([])
  61. const show = ref(true)
  62. const useUserInfoStore = useUserInfo()
  63. import HardwareCheck from '@/components/check/index.vue'
  64. function onCheckComplete(){
  65. }
  66. import { ref,onBeforeUnmount } from 'vue'
  67. import socket from "../../stores/modules/socket";
  68. import { digiCamControlWEB } from '@/utils/appconfig'
  69. const imageUrl = ref(digiCamControlWEB+'preview.jpg')
  70. const imageUrlkey = ref(0)
  71. const previewKey = ref(0)
  72. const preview = ref(digiCamControlWEB+'liveview.jpg')
  73. const step = ref(1)
  74. function checkConfirm(init){
  75. step.value =1
  76. if(menu.length === 0){
  77. menu.push({
  78. type:'setting'
  79. })
  80. if(useUserInfoStore.userInfo.brand_company_code === '1300'){
  81. menu.push({
  82. type:'developer'
  83. })
  84. }
  85. }
  86. if(!init) previewKey.value++;
  87. showVideo()
  88. }
  89. let interval:any = null
  90. function showVideo(){
  91. clientStore.ipc.removeAllListeners(icpList.camera.PreviewShow);
  92. clientStore.ipc.send(icpList.camera.PreviewShow);
  93. clientStore.ipc.on(icpList.camera.PreviewShow, async (event, result) => {
  94. setTimeout(()=>{
  95. interval = setInterval(()=>{
  96. previewKey.value++;
  97. },200)
  98. },2000)
  99. })
  100. }
  101. function hideVideo(){
  102. clientStore.ipc.removeAllListeners(icpList.camera.PreviewHide);
  103. clientStore.ipc.send(icpList.camera.PreviewHide);
  104. clientStore.ipc.on(icpList.camera.PreviewHide, async (event, result) => {
  105. if(interval) clearInterval(interval)
  106. })
  107. }
  108. const loading = ref(false)
  109. function takePictures() {
  110. if (clientStore.isClient) {
  111. clientStore.ipc.removeAllListeners(icpList.camera.takePictures);
  112. clientStore.ipc.send(icpList.camera.takePictures);
  113. clientStore.ipc.on(icpList.camera.takePictures, async (event, result) => {
  114. if(interval) clearInterval(interval)
  115. loading.value = true;
  116. imageUrlkey.value++;
  117. setTimeout(()=>{
  118. hideVideo()
  119. step.value = 2
  120. imageUrlkey.value++;
  121. loading.value = false;
  122. },8000)
  123. })
  124. }
  125. }
  126. /**
  127. * 页面卸载时移除所有事件监听器。
  128. */
  129. onBeforeUnmount(() => {
  130. clientStore.ipc.removeAllListeners(icpList.camera.takePictures);
  131. clientStore.ipc.removeAllListeners(icpList.camera.PreviewHide);
  132. clientStore.ipc.removeAllListeners(icpList.camera.PreviewShow);
  133. })
  134. </script>
  135. <style scoped lang="scss">
  136. .check-wrap {
  137. background-color: rgba(234, 236, 237, 1);
  138. width: 100%;
  139. min-height: calc(100vh - 30px);
  140. display: flex;
  141. }
  142. .check-page {
  143. position: relative;
  144. width: 1200px;
  145. height: 768px;
  146. overflow: hidden;
  147. .main-container {
  148. width: 1200px;
  149. height: 739px;
  150. margin-bottom: 1px;
  151. .content-wrapper {
  152. width: 896px;
  153. height: 644px;
  154. margin: 10px 0 0 284px;
  155. .left-panel {
  156. width: 633px;
  157. height: 644px;
  158. .tips-container {
  159. background-color: rgba(255, 241, 222, 0.8);
  160. border-radius: 4px;
  161. width: 633px;
  162. height: 40px;
  163. border: 1px solid rgba(255, 228, 190, 1);
  164. justify-content: flex-center;
  165. .tips-icon {
  166. width: 16px;
  167. height: 16px;
  168. margin: 12px 0 0 16px;
  169. }
  170. .tips-tex {
  171. width: 549px;
  172. height: 22px;
  173. overflow-wrap: break-word;
  174. color: rgba(0, 0, 0, 0.85);
  175. font-size: 14px;
  176. font-weight: NaN;
  177. text-align: left;
  178. white-space: nowrap;
  179. line-height: 22px;
  180. margin: 9px 0 0 7px;
  181. }
  182. .close-icon {
  183. width: 12px;
  184. height: 12px;
  185. margin: 14px 16px 0 17px;
  186. }
  187. }
  188. .camera-preview {
  189. box-shadow: 0px 2px 10px 0px rgba(0, 32, 78, 0.1);
  190. background-color: rgba(255, 255, 255, 1);
  191. height: 600px;
  192. width: 600px;
  193. margin: 4px 0 0 16px;
  194. position: relative;
  195. .camera-description {
  196. position: absolute;
  197. bottom: 20px;
  198. width: 60%;
  199. padding: 8px 20px;
  200. background: rgba($color: #ffffff, $alpha: .2);
  201. border-radius: 20px;
  202. font-size: 14px;
  203. }
  204. .camera-img {
  205. width: 100%;
  206. }
  207. }
  208. }
  209. .example-image {
  210. background-color: rgba(216, 216, 216, 1);
  211. height: 200px;
  212. margin-top: 10px;
  213. width: 200px;
  214. img {
  215. width: 200px;
  216. height: 200px;
  217. display: block;
  218. }
  219. }
  220. }
  221. .action-button {
  222. width: 100%;
  223. text-align: center;
  224. margin-top: 28px;
  225. .check-button {
  226. .button-text {
  227. width: 180px;
  228. overflow-wrap: break-word;
  229. font-size: 16px;
  230. text-align: center;
  231. white-space: nowrap;
  232. height: 40px;
  233. line-height: 40px;
  234. }
  235. }
  236. }
  237. }
  238. }
  239. </style>