index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="container">
  3. <navBar title="绘本生成" :back="true" @onBack="onBack" color="#333333" background="#FFFFFF" />
  4. <view class="mainBox">
  5. <view class="titleBox">
  6. </view>
  7. <view class="contentBox">
  8. <view class="bgTag">
  9. {{huibenRes.title?huibenRes.title:'内容生成中...'}}
  10. </view>
  11. <view class="storeBox">
  12. <view class="loadingBox" v-if="showLoading">
  13. <image class="loadingImg" mode="widthFix" :src="picBase+'loading.gif'"></image>
  14. </view>
  15. <u-parse v-else :content="huibenRes.pinyin_content"></u-parse>
  16. <!-- <u-parse :content="content"></u-parse> -->
  17. </view>
  18. </view>
  19. </view>
  20. <view class="btnBox">
  21. <view class="btn b1">
  22. 下载PDF
  23. </view>
  24. <view class="btn b2">
  25. 下载图片
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. webviewStyles: {
  35. progress: {
  36. color: '#FF3333'
  37. }
  38. }
  39. }
  40. }
  41. }
  42. </script>
  43. <style>
  44. </style>
  45. 复制代码
  46. </view>
  47. </view>
  48. </view>
  49. <view class="btnBox">
  50. <view class="btn b1">
  51. 下载PDF
  52. </view>
  53. <view class="btn b2">
  54. 下载图片
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import content from "../../../utils/pinyin.js"
  61. import {
  62. getGenRes
  63. } from '@/api/index/index.js'
  64. // import navBar from '@/components/navBar/index.vue'
  65. export default {
  66. // components: {
  67. // navBar
  68. // },
  69. data() {
  70. return {
  71. picBase: this.$picBase2,
  72. taskId: -1,
  73. huibenRes: null,
  74. showLoading: true,
  75. timer: null,
  76. content: ''
  77. }
  78. },
  79. onLoad(o) {
  80. console.log('content', content);
  81. this.content = content.content
  82. if (o.taskId) {
  83. this.taskId = o.taskId
  84. console.log('this.taskId', this.taskId);
  85. this.timer = setInterval(() => {
  86. this.getGenRes()
  87. }, 1000)
  88. }
  89. },
  90. methods: {
  91. onBack() {
  92. console.log('onBack()-----------');
  93. if (this.timer) {
  94. clearInterval(this.timer)
  95. }
  96. },
  97. async getGenRes() {
  98. let res1 = await getGenRes({
  99. id: this.taskId
  100. })
  101. console.log('查询生成结果返回值--------2', res1);
  102. if (res1.code == 0) {
  103. if (res1.data.state == 6) {
  104. this.huibenRes = res1.data
  105. this.content = `${res1.data.pinyin_content}`
  106. this.showLoading = false
  107. clearInterval(this.timer)
  108. }
  109. // this.chargeList=[]
  110. } else {
  111. this.$toast(res1.message)
  112. }
  113. },
  114. }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. @import "./index.scss";
  119. @import "./util.scss";
  120. </style>