cube-ocr.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div :class="$style.mainDiv">
  3. <div v-show="loading" :class="$style.loadingDiv">
  4. <a-spin :spinning="loading" tip="单点认证中..."></a-spin>
  5. </div>
  6. <div v-show="!loading" :class="$style.frameDiv">
  7. <!-- <a-card> -->
  8. <iframe v-show="showFrame" :src="frameSrc" frameborder="0"></iframe>
  9. <!-- </a-card> -->
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. import cubeServices from '@product/iam/cube/cube-services'
  15. import axios from '@/common/services/axios-instance'
  16. import { sdLocalStorage } from '@/common/services/storage-service'
  17. import { Modal } from '@/common/one-ui'
  18. import components from './_import-components/cube-ocr-import'
  19. export default {
  20. name: 'CubeOcr',
  21. metaInfo: {
  22. title: 'OCR全文识别',
  23. },
  24. components,
  25. data() {
  26. return {
  27. loading: true, // 默认先显示加载中
  28. showFrame: false, // 默认不显示frame,拼接好url才显示
  29. frameSrc: '',
  30. }
  31. },
  32. mounted() {
  33. // 加载时,获取token
  34. setTimeout(() => {
  35. this.loading = false
  36. }, 2000)
  37. // 加载时,获取token
  38. this.getFrameUrl()
  39. },
  40. methods: {
  41. // 获取要素提取页面地址,主要是拼接token
  42. getFrameUrl() {
  43. cubeServices.checkCubeToken('review').then((res) => {
  44. if (!res) {
  45. Modal.warning({
  46. title: '提示',
  47. content: '未开启CUBE集成功能参数或单点认证失败,请联系管理员',
  48. })
  49. return false
  50. }
  51. const cubeJson = JSON.parse(sdLocalStorage.getItem('cube') || '{}')
  52. // 项目修改
  53. axios.get('api/xcoa-mobile/v1/iamcubecontract/getCubeWebUrl').then((res) => {
  54. if (res.data !== '') {
  55. this.frameSrc =
  56. res.data +
  57. `/projects/29/review/ocr/o/text_recognition?access_token=${cubeJson.review_token}&banner=false`
  58. this.showFrame = true
  59. }
  60. })
  61. })
  62. },
  63. },
  64. }
  65. </script>
  66. <style module lang="scss">
  67. @use '@/common/design' as *;
  68. .main-div {
  69. width: 100%;
  70. height: 100%;
  71. text-align: center;
  72. background: #fff;
  73. .loading-div {
  74. padding-top: 15%;
  75. }
  76. }
  77. .frame-div {
  78. width: 100%;
  79. height: 100%;
  80. :global(.ant-card) {
  81. width: 100%;
  82. height: 100%;
  83. }
  84. :global(.ant-card-body) {
  85. width: 100%;
  86. height: 100%;
  87. }
  88. iframe {
  89. width: 100%;
  90. height: 100%;
  91. }
  92. }
  93. </style>