<template>
	<view class="bg">
		<view class="" id="cpts" v-html="formateRichText(info.detail)"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: null,
				swiperCurrent: 1,
				info: {},
			}
		},
		onShow(options) {
		},
		onLoad(options) {
			this.id = options.id;
			this.getInfo();
		},
		methods: {
			swiperChange (e) {
				this.swiperCurrent = e.detail.current+1
			},
			// 获取信息
			getInfo() {
				this.Post({id: this.id},'/api/activity/getActivityCalendarDetail').then(res => {
					if (res.data.flag == 0) {
						uni.showToast({title: '商品不存在或已下架',icon: 'none'})
						setTimeout(() => {this.goBack()}, 2000)
					}
					// res.data.is_collect = 0 // 收藏图变更慢
					this.info = res.data;
				});
			},
			// 收藏
			collect() {
				this.Post({type: 7,id: this.id},'/api/scenic/collect').then(res => {
					if (res) {
						uni.showToast({title: res.msg,icon: 'none'});
						this.info.is_collect = !this.info.is_collect
					}
				});
			},
			share () {
				var pages = getCurrentPages() //获取加载的页面
				var view = pages[pages.length - 1] //获取当前页面的对象
				uni.share({
					provider: "weixin",
					scene: "WXSceneSession",
					type: 0,
					href: `${view.route}`,
					title: this.info.title,
					imageUrl: this.showImg(this.info.image),
					success: function (res) {
						console.log("success:" + JSON.stringify(res));
					},
					fail: function (err) {
						console.log("fail:" + JSON.stringify(err));
					}
				});
			}
			
		}
	}
</script>

<style scoped lang="scss">
	.bg{
		min-height: 100vh;
		background: #F8F8F8;
		padding: 25rpx;
	}
</style>
