<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: '危险区二维码',
				dangerAreaName: '',
				dangerAreaPid: '',
				baseOSS: '',
				qrImageUrl: '',
			}
		},
		computed: {
			toQr() {
				if (this.qrImageUrl.length > 0) {
					let url = this.baseOSS + this.qrImageUrl;
					return url;
				} else {
					return '';
				}
			},
		},
		onLoad(options) {
			this.baseOSS = oss;
			this.dangerAreaPid = options.id;
			let that = this;
			let postData = {};
			postData['dangerAreaPid'] = this.dangerAreaPid;
			http.request({
				url: '/galaxy-business/map/dangerarea/qr',
				method: 'GET',
				data: postData
			}).then(res => {
				if (res.data != null) {
					that.qrImageUrl = res.data.qrUrl;
					that.dangerAreaName = res.data.dangerAreaName;
				}
			}).catch(err => {
				console.log(err)
			})
		},
		onShow() {

		},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
		}
	}
</script>

<style>

</style>