<template>
	<view class="presale">
		<view class="p" v-html="content"></view>
	</view>
</template>

<script>
	import * as Api from '@/api/help'
	export default {
		data() {
			return {
				content: '',
				type: 4
			}
		},
		onLoad(op) {
			let title = ''
			if (op.type == 4) {
				title = '新人首单规则'
			}
			if (op.type == 5) {
				title = '预售规则'
			}
			if (op.type == 6) {
				title = '排行榜规则'
			}
			if (op.type == 7) {
				title = '优惠券规则'
			}
			uni.setNavigationBarTitle({
				title: title
			})
			this.type = op.type
			this.getCarouselList(op.type)
		},
		onShow() {},
		methods: {
			// 获取预售规则
			getCarouselList(type) {
				const app = this;
				let rule=''
				if (app.type == 4) {
					rule = 'presale_rule'
				}
				if (app.type == 5) {
					rule = 'presale_rule'
				}
				if (app.type == 6) {
					rule = 'rank_rule'
				}
				if (app.type == 7) {
					rule = 'rank_rule'
				}
				Api.getAgreement({
						type: rule
					})
					.then(result => {
						let content = result.data.detail.content || '';
						if (content) {
							content = content.replace(/style=""/g, '').replace(/<img src=/g,
								'<img style="width: 100%; display:block" src=')
						}
						this.content = content
					})
					.finally(() => app.isLoading = false)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.presale {
		padding: 40rpx;

		.p {
			font-size: 26rpx;
			line-height: 50rpx;
			color: #212121;
		}
	}
</style>