<template>
	<view class="success">
		<image src="../static/images/bmcg.png"></image>
		<view class="tip">报名成功</view>
		<view class="tips">您已成功报名该活动，<!-- 请耐心等待主办方审核。预计1-3个工作日内审核完成， -->点击“<navigator url="/match/activitys/activity" hover-class="none" class="mine">我报名的活动</navigator>”查看详情</view>
		<!-- #ifndef H5 -->
		<button open-type="share" class="share">分享活动</button>
		<!-- #endif -->
		<!-- #ifdef H5 -->
		<view class="share" @click="showSharePop()">分享活动</view>
		<!-- #endif -->
		<navigator url="/match/activity/activity" open-type="reLaunch" hover-class="none" class="backhome">更多活动</navigator>
		<!-- #ifdef H5 -->
		<view class="share-pop" @click="hideSharePop" v-if="isShowSharePop">
			<image src="../static/fx-tip1.png"></image>
		</view>
		<wx-share :title="detail.title" :image="detail.pic" :desc="detail.brief" :type="2" :id="options.id" />
		<!-- #endif -->
	</view>
</template>

<script>
const req = require('../../utils/request.js');
const api = require('../../utils/api.js');
const util = require('../../utils/util.js');
const app = getApp();
import mpHtml from "../../components/mp-html/components/mp-html/mp-html";
export default {
	components: {
		mpHtml,
	},
	data() {
		return {
			options: {},
			detail: {},
			config: '',
			isShowSharePop: false
		};
	},
	onLoad(options) {
		// #ifndef H5
		uni.showShareMenu({
			withShareTicket: true,
			menus: ['shareAppMessage', 'shareTimeline']
		});
		// #endif
		this.options = options;
	},
	onShow() {
		if(req.getStorage('configRes')) this.config = JSON.parse(req.getStorage('configRes'));
		this.getData(true);
	},
	onReachBottom: function() {
	},
	onShareAppMessage: function() {
		let path = '';
		let isSolution = req.env[req.env.NODE_ENV].isSolution;
		let userInfo = req.getStorage('userInfo');
		if(isSolution){
			path = '/share/home/index?appId='+req.getStorage('appId')+'&userId='+userInfo.id;
		}else{
			path = '/match/activityDetail/activityDetail?id=' + this.detail.id;
		}
		this.saveShareBehavior();
		return {
			title: this.detail.title,
			imageUrl:this.detail.pic,
			path: path
		};
	},
	onShareTimeline() {
		this.saveShareBehavior();
		return {
			title: this.detail.title,
			image: this.detail.pic,
			query: '/match/activityDetail/activityDetail?id=' + this.detail.id
		};
	},
	methods: {
		showSharePop() {
			this.isShowSharePop = true;
		},
		hideSharePop() {
			this.isShowSharePop = false;
		},
		getData(isShow){
			req.getRequest('/api/match/detail',{id: this.options.id},res => {
				this.detail = res;
			},isShow);
		},
		saveShareBehavior(){
			let params={
				behavior: 6,
				type: 2,
				bindId: this.detail.id,
			}
			req.saveBehavior(params, data => {});
		},
	}
};
</script>

<style>
	@import "./success.css";
</style>
