<template>
	<!-- 转赠活动 -->
	<view class="activityEntry" style="background: url(../../../../static/chooseCade/reddogbg.png);">
		<far-bottom></far-bottom>
		<view >
			<view class="dis-flex" style="justify-content:center;align-items:center;padding-top: 180upx;">
				<image style="width: 120upx;height: 120upx;border-radius: 50%;" :src="particulars.avatar" mode="aspectFill"></image>
			</view>
			<view class="t-c f-36 " style="padding: 30upx 0 0;color: #FFFFFF;">{{ particulars.title }}</view>
			<view class="t-c f-30 " style="padding: 30upx 0;color: #FFFFFF;">{{ particulars.nickname }}转赠{{ particulars.money }}元</view>
			<view class="dis-flex" style="justify-content:center;align-items:center;" @longpress="saveImg(particulars.qrlink)">
				<image :src="particulars.qrlink" mode="" style="width: 45vw;height: 45vw;padding: 40upx;background-color: #FFFFFF;border-radius: 15upx;"></image>
			</view>
			<view class="t-c f-30" style="padding: 30upx 30upx;color: #FDC15E;width: 88vw;overflow: hidden;">{{ particulars.pageurl }}</view>
			<view class="dis-flex" style="justify-content:center;align-items:center;">
				<view class="t-c f-30" style="width: 55vw;height: 80upx;border-radius: 15upx;background-color: #FEEC62;line-height: 80upx;color: #333333;" @click="goshouqian">
					复制链接
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import App from '@/common/js/app.js';
import noneMores from '@/components/template/nonemores.vue';

// #ifdef H5
import wxApi from '@/common/js/wxApi.js';
// #endif
export default {
	data() {
		return {
			particulars: {},
			id: 0
		};
	},
	onLoad(e) {
		this.id = e.id;
		this.getActivityDetails(e.id);
	},
	methods: {
		saveImg(imgURL) {
			console.log(imgURL);
			uni.downloadFile({
				//下载图片
				url: imgURL,
				success: res => {
					console.log(res.tempFilePath);
					uni.saveImageToPhotosAlbum({
						//将图片保存在手机
						filePath: res.tempFilePath, //保存的位置
						success: res => {
							console.log(res);
							console.log('长按保存图片');
						}
					});
				}
			});
		},
		getActivityDetails(id) {
			App._post_form(`&p=member&do=transferDetail&id=${id}`, {}, res => {
				this.particulars = { ...this.particulars, ...res.data };
				console.log(this.particulars);
			});
		},
		goshouqian() {
			//#ifdef H5
				App.clipboard(this.particulars.pageurl);
			//#endif
			uni.setClipboardData({
				data: this.particulars.pageurl
			});
			uni.showToast({
				title: '链接已复制到粘贴板'
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.activityEntry {
	width: 100vw;
	height: 100vh;
	background-size: 100% 100%;
}
</style>
