<script setup>
	/**
	 * 我的分享
	 */
	import {
		onMounted,
		ref,
		reactive,
		computed,
		getCurrentInstance,
		watch,
		defineExpose,
	} from 'vue';
	import {
		onLoad,
	} from '@dcloudio/uni-app'
	import {
		useStore,
	} from 'vuex'
	import api from '@/api/index.js';
	const store = useStore()
	const userinfo = computed(() => {
		let result = store.state.userinfo
		return result
	})
	// 二维码数据
	const qrData = ref("")

	onLoad(() => {
		myQrcode()
	})

	// 查看二维码
	function myQrcode() {
		api.intergral.myQrcode({}).then(rs => {
			qrData.value = `data:image/png;base64, ${uni.arrayBufferToBase64(rs)}`
		})
	}
</script>

<template>
	<view class="appbw df fdc aic">
		<view class="qrBox pr">
			<image src="/static/myShare.png" mode="aspectFill" />

			<image class="qr pmid" :src="qrData" mode="aspectFill" />
		</view>
		<view class="button btn lg colourful mt60 plr30">推荐码： {{userinfo.invitationCode}}</view>
	</view>
</template>

<style lang="scss">
	// 二维码
	.qrBox {
		margin-top: 10vh;
		width: 606rpx;
		height: 606rpx;

		// 二维码
		.qr {
			width: 374rpx;
			height: 374rpx;
		}
	}

	// 按钮
	.button {
		min-width: 350rpx;
	}
</style>