<template>
	<view class="container">
		<navBar title="绘本生成" :back="true" @onBack="onBack" color="#333333" background="#FFFFFF" />
		<view class="mainBox">
			<view class="titleBox">
			</view>

			<view class="contentBox">
				<view class="bgTag">
					{{huibenRes.title?huibenRes.title:'内容生成中...'}}
				</view>
				<view class="storeBox">

					<view class="loadingBox" v-if="showLoading">
						<image class="loadingImg" mode="widthFix" :src="picBase+'loading.gif'"></image>
					</view>

					<u-parse v-else :content="huibenRes.pinyin_content"></u-parse>

					<!-- <u-parse :content="content"></u-parse> -->
				</view>

			</view>
		</view>

		<view class="btnBox">
			<view class="btn b1">
				下载PDF
			</view>
			<view class="btn b2">
				下载图片
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				webviewStyles: {
					progress: {
						color: '#FF3333'
					}
				}
			}
		}
	}
</script>

<style>

</style>
复制代码

</view>
</view>
</view>



<view class="btnBox">
	<view class="btn b1">
		下载PDF
	</view>
	<view class="btn b2">
		下载图片
	</view>
</view>
</view>
</template>

<script>
	import content from "../../../utils/pinyin.js"
	import {
		getGenRes
	} from '@/api/index/index.js'
	// import navBar from '@/components/navBar/index.vue'
	export default {
		// components: {
		// 	navBar
		// },
		data() {
			return {
				picBase: this.$picBase2,
				taskId: -1,
				huibenRes: null,
				showLoading: true,
				timer: null,
				content: ''
			}
		},
		onLoad(o) {

			console.log('content', content);
			this.content = content.content
			if (o.taskId) {
				this.taskId = o.taskId

				console.log('this.taskId', this.taskId);

				this.timer = setInterval(() => {
					this.getGenRes()
				}, 1000)
			}
		},
		methods: {
			onBack() {

				console.log('onBack()-----------');
				if (this.timer) {
					clearInterval(this.timer)
				}
			},
			async getGenRes() {
				let res1 = await getGenRes({
					id: this.taskId
				})
				console.log('查询生成结果返回值--------2', res1);
				if (res1.code == 0) {

					if (res1.data.state == 6) {
						this.huibenRes = res1.data
						this.content = `${res1.data.pinyin_content}`
						this.showLoading = false
						clearInterval(this.timer)
					}
					// this.chargeList=[]
				} else {
					this.$toast(res1.message)
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import "./index.scss";
	@import "./util.scss";
</style>