<template>
	<view class="container">
		<!-- <nav-bar></nav-bar> -->
		<rich-text :nodes="siteGuideData"></rich-text>
	</view>
	
</template>

<script setup>
import { ref } from 'vue';
import { onLoad, onShareAppMessage } from '@dcloudio/uni-app'
import { ClientSite } from '/Apis/book.js'
import { projectInfo } from '@/config/index.js'
// import NavBar from '../../components/navBar.vue';

onLoad((option) => {
	siteId.value = option.id
	type.value = option.type
	getData()
})

onShareAppMessage((res) => {
	return {
		title: `${projectInfo.miniName}`,
		path: `/pages/book/navigate?id=${siteId.value}&type=${type.value}`
	};
});

const getApi = ClientSite()
const siteId = ref(null)
const type = ref()
const siteGuideData = ref([])
const getData = ()=>{
	//  tpye 1 是路线指引  2是停车指引 
	if(type.value==2){
		getStopCar()
	}else{
		getSiteGuide()
	}
}
function getStopCar() {
	uni.showLoading()
	getApi.GetSiteStopCarGuideById(siteId.value).then(res => {
		uni.hideLoading()
		if(res.code === 200) {
			siteGuideData.value = res.data
		}
	}).catch(err => {
		uni.hideLoading()
	})
	
}

function getSiteGuide() {
	uni.showLoading()
	getApi.GetSiteGuideById(siteId.value).then(res => {
		uni.hideLoading()
		if(res.code === 200) {
			siteGuideData.value = res.data
		}
	}).catch(err => {
		uni.hideLoading()
	})
	
}

</script>

<style scoped lang="scss">
	@import '@/static/style/theme.scss';
	.container {
		margin: 0;
		padding: 0;
		width: 100%;
		min-height: 100vh;
		display: flex;
		flex-direction: column;
		align-items: start;
		// background: linear-gradient(to bottom, #0A83B7, #00AFBD);
		background-attachment: fixed;
	}
	.image {
		width: 68rpx;
		height: 68rpx;
		margin-left: 40rpx;
		margin-top: 30rpx;
	}
</style>