regulations.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view>
  3. <!-- <view class="pdfBox" id="mycanvas" ref="mycanvas"></view> -->
  4. <!-- <iframe :src="'http://10.0.1.159:9100/' + pdfUrl" frameborder="0" class="pdfBox"></iframe> -->
  5. <!-- <iframe src="https://docs.oracle.com/javaee/6/tutorial/doc/javaeetutorial6.pdf" frameborder="0" class="pdfBox"></iframe> -->
  6. <!-- <web-view :src="'http://172.16.1.159:9100/' + pdfUrl"></web-view> -->
  7. <view v-if="this.pdfUrl != ''">pdf文件如下:</view>
  8. <view class="fileDown" v-if="this.pdfUrl != ''">
  9. <view style="display: inline-block;">法律法规详情介绍PDF</view>
  10. <view style="float: right;margin-right:20upx;color: #0000BF;" @click="download(pdfUrl,'法律法规详情介绍PDF')">下载
  11. </view>
  12. <view></view>
  13. </view>
  14. <!-- <web-view src="https://www.geidcp.com/api/file/pub/cms/2021/05/10/c8db4efaf7fa4b49adf515b9334f2e77.pdf"></web-view> -->
  15. <!-- <web-view src="https://www.geidcp.com/api/file/pub/cms/2021/05/10/c8db4efaf7fa4b49adf515b9334f2e77.pdf"></web-view> -->
  16. <view class="pdfBox" v-if="this.pdfUrl == ''" style="text-align: center">{{$t('common.NoFile')}}</view>
  17. </view>
  18. </template>
  19. <script>
  20. import pdf from "@/static/pdf/build/pdf"
  21. export default {
  22. props: {
  23. baseEntityId: '',
  24. },
  25. data() {
  26. return {
  27. isLogin: false,
  28. token: '',
  29. info4: [],
  30. pdfUrl: '',
  31. }
  32. },
  33. mounted() {
  34. this.token = uni.getStorageSync('Auth-Token') ? uni.getStorageSync('Auth-Token') : '';
  35. // this.getUrl();
  36. this.tab4()
  37. console.log('this.baseEntityId')
  38. console.log(this.baseEntityId)
  39. },
  40. methods: {
  41. // getUrl() {
  42. // if (this.pdfUrl) {
  43. // console.log('this.pdfUrl')
  44. // console.log(this.pdfUrl)
  45. // }
  46. // },
  47. async tab4(baseEntityId) {
  48. const res = await this.$myRequest({
  49. url: '/cms/cmsInformationViews/getInformationList/',
  50. data: {
  51. pageSize: 5,
  52. pageNo: 1,
  53. businessType: 'countryShow',
  54. businessId: this.baseEntityId,
  55. typeDict: 8,
  56. language: this.$i18n.locale.toUpperCase()
  57. }
  58. });
  59. if (res.data.allDataList.length != 0) {
  60. this.info4 = res.data ? res.data.allDataList[0] : [];
  61. this.pdfUrl = this.info4.pdfPath ? this.info4.pdfPath : '';
  62. // this.pdfUrl = this.info4 ?pdfPath ? 'api/file/pub/' + this.info4 ? pdfPath : '':'';
  63. }
  64. console.log('info4', res)
  65. console.log('this.pdfUrl', this.pdfUrl)
  66. },
  67. download(path, fileName) {
  68. console.log('path,fileName')
  69. console.log(path, fileName)
  70. // const downloadTask = uni.downloadFile({
  71. uni.downloadFile({
  72. url: 'https://m.geidcp.com/api/file/pub/' + path, //下载地址接口返回
  73. success: (data) => {
  74. console.log(data)
  75. if (data.statusCode === 200) {
  76. //文件保存到本地
  77. uni.saveFile({
  78. tempFilePath: data.tempFilePath, //临时路径
  79. success: function(res) {
  80. uni.showToast({
  81. icon: 'none',
  82. mask: true,
  83. title: '文件已保存:' + res.savedFilePath, //保存路径
  84. duration: 3000,
  85. });
  86. setTimeout(() => {
  87. //打开文档查看
  88. uni.openDocument({
  89. filePath: res.savedFilePath,
  90. success: function(res) {
  91. // console.log('打开文档成功');
  92. }
  93. });
  94. }, 3000)
  95. }
  96. });
  97. }
  98. },
  99. fail: (err) => {
  100. console.log(err);
  101. uni.showToast({
  102. icon: 'none',
  103. mask: true,
  104. title: ' ',
  105. });
  106. },
  107. });
  108. // downloadTask.onProgressUpdate((res) => {
  109. // console.log('下载进度' + res.progress);
  110. // console.log('已经下载的数据长度' + res.totalBytesWritten);
  111. // console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
  112. //
  113. // // 测试条件,取消下载任务。
  114. // if (res.progress > 50) {
  115. // downloadTask.abort();
  116. // }
  117. // });
  118. // console.log('下载成功', 'https://localhost:8080/api/file/pub/' + path);
  119. },
  120. }
  121. }
  122. </script>
  123. <style scoped>
  124. .pdfBox {
  125. width: 100%;
  126. height: 50upx;
  127. }
  128. .footerText {
  129. text-align: center;
  130. color: #0c27ff;
  131. padding-bottom: 10px;
  132. }
  133. .loginText {
  134. cursor: pointer;
  135. }
  136. .pdfStyle {
  137. position: absolute;
  138. display: block;
  139. border: 0px;
  140. top: 0;
  141. left: 0px;
  142. width: 375px;
  143. height: 623px;
  144. z-index: 999;
  145. }
  146. .fileDown {
  147. width: 100%;
  148. padding: 20upx 0 40upx;
  149. }
  150. </style>