<template>
	<view class="container">
		<uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
			@clickLeft="toBack">
			<view class="nav-title">
				<text>{{title}}</text>
			</view>
		</uni-nav-bar>
		<view class="page-body">
			<uni-card :title="dangerAreaName">
				<image style="width: 100%;" :src="toQr" mode="widthFix"></image>
			</uni-card>
		</view>
	</view>
</template>
<script>
	import http from '@/http/api.js';
	import {
		oss
	} from '@/common/setting';
	export default {
		components: {
		},
		data() {
			return {
				title: '危险区二维码',
				qrType: 1,
				dangerAreaName: '',
				dangerAreaPid: '',
				baseOSS: '',
				qrImageUrl: '',
			}
		},
		computed: {
			toQr() {
				if (this.qrImageUrl.length > 0) {
					return this.baseOSS + this.qrImageUrl;
					return url;
				} else {
					return '';
				}
			},
		},
		onLoad(options) {
			let that = this;
			this.baseOSS = oss;
			this.dangerAreaPid = options.id;
			this.qrType = options.qrType;
			let postData = {};
			postData['dangerAreaPid'] = this.dangerAreaPid;
			let url = "/galaxy-business/map/dangerarea/qr";
			if (this.qrType == 2) {
				this.title = "危险区群众注册二维码";
				url = "/galaxy-business/map/dangerarea/resident/reg/qr";
			}
			http.request({
				url: url,
				method: 'GET',
				data: postData
			}).then(res => {
				if (res.data != null) {
					if (that.qrType == 1) {
						that.qrImageUrl = res.data.qrUrl;
					} else if (that.qrType == 2) {
						that.qrImageUrl = res.data.residentRegQrUrl;
					}
					that.dangerAreaName = res.data.dangerAreaName;
				}
			}).catch(err => {
				console.log(err)
			})
		},
		onShow() {
		},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
		}
	}
</script>

<style>
</style>