<template>
	<ciy-header title="PC端快捷拍照" ref="header"></ciy-header>
	<view class="ciy-card">
		<ciy-aicameraocr @change="addnew" ref="cameraocr" :height="camheight"></ciy-aicameraocr>
	</view>
</template>

<style>
</style>

<script>
	/*
	PC端生成唯一ID，显示二维码
	打开SSE或HTTP轮询请求，发现新图片传回后立即标记已用。
	可设置无回传3分钟后二维码失效，停止轮询。
	*/
	export default {
		data() {
			return {
				init: {},
				camheight: '56',
			}
		},
		onLoad() {
			var app = getApp();
			setTimeout(() => {
				this.getrefsSync('cameraocr').Step(1);
			}, 1000);
		},
		onUnload() {
			var postparam = {};
			postparam.id = this.opn.id;
			var retjson = this.callajax({
				func: 'pub.imgend',
				data: postparam
			});
		},
		watch: {},
		computed: {},
		methods: {
			async addnew(e) {
				var opn = {};
				opn.basepath = this.opn.basepath;
				opn.stor = this.opn.stor;
				opn.action = this.opn.action;
				var postparam = {};
				postparam.id = this.opn.id;
				postparam.txts = e.txts.join('\n');
				postparam.img = await this.file_upload1(e.tempimg, opn);
				var retjson = await this.callajax({
					func: 'pub.imgadd',
					data: postparam
				});
				if (retjson.code != 1)
					return this.alert(retjson.errmsg);
			}
		}
	}
</script>