<template>
	<view class="content">
		<image src="../../static/img/sharebase.png" mode="widthFix" class="baseimg"></image>
		<view class="erweima">
			<tki-qrcode
				:cid="cid"
				ref="qrcode"
				:val="val"
				:size="size"
				:unit="unit"
				:background="background"
				:foreground="foreground"
				:pdground="pdground"
				:iconSize="iconSize"
				:lv="lv"
				:onval="onval"
				:loadMake="loadMake"
				:usingComponents="usingComponents"
				@result="qrR"
			/>
		</view>
	</view>
</template>
<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import {
		getUserInfo
	} from '@/api/user.js';
	export default {
		data() {
			return {
				val: '',
				cid: 'cid',
				size: 150,
				unit: '150',
				background: '#FFFFFF',
				foreground: '#000000',
				pdground: '#000000',
				icon: '',
				iconSize: 40,
				lv: 3,
				onval: true,
				loadMake: true,
				usingComponents: true,
			};
		},
		onLoad() {
			const obj = this;
			if(!this.userInfo.uid){
				getUserInfo({}).then(e => {
					// 保存返回用户数据
					obj.setUserInfo(e.data);
					//成功跳转首页
					uni.switchTab({
						url: '/pages/index/index'
					});
				});
			}else{
				this.val = 'http://hgd.liuniu946.com/appdom/index.html?spread=' + this.userInfo.uid
			}
		},
		onShow() {
		},
		//下拉刷新
		onPullDownRefresh() {
	
		},
		computed: {
			...mapState(['baseURL', 'urlFile']),
			...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
		},
		methods: {
			qrR(res) {
				this.src = res;
			},

		}
	};
</script>

<style lang="scss">
.baseimg {
	width: 100%;
}
.erweima {
	width: 300rpx;
	position: absolute;
	top: 928rpx;
	left: 0;
	right: 0;
	margin: auto;
	display: flex;
	justify-content: center;
}
</style>
