<template>
	<view>
		<!-- <u-sticky bgColor="#fff"> -->
		<view class="sticky">
			<!-- #ifdef MP-WEIXIN -->
			<NavigateBar title="使用须知" control="back" bgcolor="#a09cc4"></NavigateBar>
			<!-- #endif -->
			<!-- #ifdef MP-ALIPAY -->
			<NavigateBar title="使用须知" bgcolor="#a09cc4"></NavigateBar>
			<!-- #endif -->
			<u-tabs :list="protocolList" @click="tabChange" lineWidth="40"></u-tabs>
		</view>
		<!-- </u-sticky> -->
		<view class="text-area">
			<u-text :text="text"></u-text>
		</view>
	</view>
</template>

<script>
	import NavigateBar from "../../components/navigateBar/navigate-bar.vue";
	export default {
		components: {
			NavigateBar
		},
		data() {
			return {
				protocolList: [{
						name: '使用须知',
					},
					{
						name: '隐私政策',
					},
					{
						name: '个人信息授权',
					},
					{
						name: '反恐法',
					},
					{
						name: '旅游业治安管理办法',
					}
				],
				text: '',
				baseUrl: 'https://test.cloud.boyuantech.net/protocol/'
			};
		},
		methods: {
			tabChange(protocol) {
				console.log(protocol)
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 0
				})
				this.getProtocol(protocol.name)
			},
			async getProtocol(name) {
				uni.request({
					url: this.baseUrl + name + '.txt',
					success: (res) => {
						console.log(res)
						this.text = res.data
					}
				})
			}
		},
		onLoad() {
			this.getProtocol(this.protocolList[0].name)
		},
		// #ifdef MP-WEIXIN
		onShareAppMessage(info) {
			return {
				title: '源享住',
				path: 'pages/login/login',
				imageUrl: "/static/logo.png"
			}
		}
		// #endif
	}
</script>

<style lang="scss">
page {
	height: 100%;

	.sticky {
		position: sticky;
		background-color: #fff;
		top: 0;
	}

	.text-area {
		margin: 20rpx;
	}
}
</style>