fileView.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <view class="container">
  3. <web-view :src="pdfUrl"></web-view>
  4. </view>
  5. </template>
  6. <script>
  7. import http from "@/common/service/http.js"
  8. import md5 from "@/common/util/md5.js"
  9. export default {
  10. data() {
  11. return {
  12. pdfUrl: '',
  13. from: 'app',
  14. type: '1'
  15. }
  16. },
  17. created() {
  18. let url = window.location.href
  19. let urlOne = url.split('#')[1]
  20. let urlTwo = urlOne.split('?')[1]
  21. let urlThree = urlTwo.split('=')
  22. if (urlThree[0] == 'url') {
  23. this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + decodeURIComponent(urlThree[1])
  24. // this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + encodeURIComponent(decodeURIComponent(urlThree[1]))
  25. }
  26. },
  27. mounted() {
  28. // window.addEventListener('mousedown', this.handleonmousedown)
  29. },
  30. onLoad(option) {
  31. if (!option.url) {
  32. this.getDe(option.fileId)
  33. }
  34. },
  35. methods: {
  36. /**
  37. * 根据报告的id查询没有盖章文档路径
  38. */
  39. getDe(id) {
  40. let access_token = uni.getStorageSync('Access-Token')
  41. console.log(access_token)
  42. let sql =
  43. `select FILE_PATH_ from ibps_file_attachment where ID_ = '${id}'`
  44. let requestData = this.$sig(sql)
  45. this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData).then(res => {
  46. if (res.data.state == 200) {
  47. const data = res.data.variables.data
  48. if (data.length > 0) {
  49. let dataItem = data[0]
  50. let url =
  51. http.apiHosp + dataItem.FILE_PATH_
  52. // this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + encodeURIComponent(url)
  53. this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + url
  54. }
  55. }
  56. })
  57. }
  58. }
  59. }
  60. </script>
  61. <style>
  62. </style>