<template>
	<view class="content">
		<view class="top hflex">
			<image src="https://ship.shipcc.cn/common/company1.png" class="top_img"></image>
			<view class="top_text">{{pageData.title}}</view>
		</view>
		<view class="box">
			<view class="tabs hflex acenter jcenter">
				<view class="tabs_item" :class="tab_active == 1 ? 'tab_active' : ''" @click="changeTab(1)">规则</view>
				<view class="tabs_item" :class="tab_active == 2 ? 'tab_active' : ''" @click="changeTab(2)">公约</view>
			</view>
			<view class="text">
				<u-parse :content="content"></u-parse>
			</view>
		</view>
	</view>
</template>

<script>
	import $api from '@/static/js/api.js'
	var that = ''
	export default {
		data() {
			return {
				pageData: {
				},
				content: '',
				tab_active: 1,
				id: ''
			}
		},
		onLoad(options) {
			that = this
			that.id = options.id
			that.getData()
		},
		methods: {
			getData() {
				$api.req({
					url: '/data/api.ResCenter/show',
					data: {
						id: that.id
					}
				}, function(res) {
					if(res.code == 1) {
						that.pageData = res.data
						that.content = res.data.c_rule
					}
				})
			},
			// 切换tab
			changeTab(index) {
				that.tab_active = index
				if(index == 1) {
					that.content = that.pageData.c_rule
				} else {
					that.content = that.pageData.c_conv
				}
			}
		},
	}
</script>

<style lang="scss" scoped>
	.content {
		background: #F4F4F4;
		.top {
			width: 100%;
			background: #FFFFFF;
			box-sizing: border-box;
			padding: 36rpx 30rpx;
			.top_img {
				width: 48rpx;
				height: 48rpx;
			}
			.top_text {
				max-width: calc(100% - 60rpx);
				font-size: 36rpx;
				font-weight: 500;
				color: #222222;
				line-height: 50rpx;
				padding-left: 12rpx;
			}
		}
		.box {
			margin: 20rpx 0 0;
			width: 100%;
			min-height: calc(100vh - 140rpx);
			background: #FFFFFF;
			.tabs {
				width: 100%;
				padding: 24rpx 0 16rpx;
				border-bottom: 1rpx solid #F4F4F4;
				.tabs_item {
					width: 50%;
					text-align: center;
					font-size: 30rpx;
					font-weight: 400;
					color: #222222;
					line-height: 42rpx;
				}
				.tab_active {
					color: #506DFF;
					position: relative;
				}
				.tab_active::after {
					position: absolute;
					content: "";
					bottom: -16rpx;
					left: 160rpx;
					width: 60rpx;
					height: 6rpx;
					background: #506DFF;
					border-radius: 8rpx;
				}
			}
			.text {
				width: 100%;
				box-sizing: border-box;
				padding: 30rpx;
			}
		}
	}
</style>