<template>
	<view class="share-page">
		<!-- 顶部导航栏 -->
		<custom-navbar 
			title="分享" 
			:show-back="true"
			backgroundColor="rgba(255, 236, 237, 1)"
		></custom-navbar>
		
		<!-- 二维码区域 -->
		<view class="qrcode-section">
			<!-- <view class="qrcode-box">
				<image 
					class="qrcode-img" 
					:src="qrCodeUrl" 
					mode="aspectFit"
				></image>
			</view> -->
			<view class="invite-code">
				<text class="code-text">{{userInfo.invite_code}}</text>
				<text class="code-label">邀请码</text>
			</view>
		</view>
		
		<!-- 邀请记录 -->
		<view class="record-section">
			<view class="record-title">
				<view class="title-icon icon_zuo"></view>
				<text class="title-text">邀请记录</text>
				<view class="title-icon icon_you"></view>
			</view>
			<view class="record-list"
				  v-if="invitelist.length != 0">
				<view 
					class="record-item"
					v-for="(item, index) in invitelist"
					:key="item.id"
				>
					<view class="user-info">
						<text class="user-name">{{item.name}}({{item.type}})</text>
						<text class="user-phone">{{item.account}}</text>
					</view>
					<text class="record-time">{{item.applyyes_time}}</text>
				</view>
			</view>
			<view class="nothing-box" v-else>
				<text class="nothing-text">当前暂无邀请记录</text>
			</view>
		</view>
		<view class="kong"></view>
	</view>
</template>

<script>
import request from '../../utils/request'
	export default {
		data() {
			return {
				qrCodeUrl: '/static/images/qrcode.png',
				userInfo: {},
				invitelist: []
			}
		},
		async onLoad() {
			let that = this;
			try {
				const result = await request.post('/user/getuser',{type: 1});
				that.userInfo = result.data;
				const invitelist = await request.post('/user/invitelist',{invite_code: result.data.invite_code});
				// console.log(invitelist)
				that.invitelist = invitelist;
			}catch(err) {
				console.log('报错',err)
			}
		},
		methods: {
			// 获取分享二维码
			getShareQrCode() {
				// TODO: 调用接口获取二维码
			},
			
			// 获取邀请记录
			getInviteRecord() {
				// TODO: 调用接口获取邀请记录
			}
		}
	}
</script>

<style>
.share-page {
	background-image: linear-gradient(to bottom,rgba(255, 236, 237, 1) 0,rgba(255, 246, 255, 0.89) 1000rpx);
	height: calc(100vh - 88rpx);
}

.kong {
	height: 42rpx;
}
.qrcode-section {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 64rpx 0 32rpx;
}

.qrcode-box {
	width: 360rpx;
	height: 360rpx;
	border-radius: 16rpx;
	border: 6rpx solid #FF4767;
	margin-top: 34rpx;
	background-color: #fff;
}

.qrcode-img {
	width: 100%;
	height: 100%;
}

.invite-code {
	width: 344rpx;
	height: 140rpx;
	background-color: #fff;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	margin-top: 26rpx;
	border-radius: 16rpx;
	box-shadow: 0 4rpx 16rpx 0 rgba(210, 213, 224, 0.50);
}

.code-text {
	font-size: 40rpx;
	color: #333333;
	font-weight: 500;
	margin-bottom: 8rpx;
}

.code-label {
	font-size: 24rpx;
	font-weight: 400;
	color: #858585;
}

.record-section {
	margin: 0 24rpx 0;
	background: #FFFFFF;
	border-radius: 32rpx;
}

.record-title {
	height: 114rpx;
	display: flex;
	flex-flow: row nowrap;
	justify-content: center;
	align-items: center;
	border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);
}

.title-icon {
	width: 40rpx;
	height: 6rpx;
	border-radius: 232rpx;
}
.icon_zuo {
	background-image: linear-gradient(to right,rgba(253, 71, 120, 0),#FD4778);
}
.icon_you {
	background-image: linear-gradient(to right,#FD4778,rgba(253, 71, 120, 0));
}
.title-text {
	font-size: 32rpx;
	color: #333333;
	font-weight: 500;
	margin: 0 16rpx;
}

.record-list {
	padding: 0 24rpx;
}

.record-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 24rpx 0;
	border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);
}

.record-item:last-child {
	border-bottom: none;
}

.user-info {
	width: 400rpx;
	display: flex;
	flex-direction: column;
}

.user-name {
	font-size: 28rpx;
	color: #333333;
	font-weight: 500;
	margin-bottom: 8rpx;
}

.user-phone {
	font-size: 24rpx;
	font-weight: 400;
	color: #666666;
}

.record-time {
	font-size: 24rpx;
	font-weight: 400;
	color: #333333;
}

.nothing-box {
	padding: 150rpx 0;
	display: flex;
	flex-flow: row nowrap;
	justify-content: center;
	align-items: center;
}
.nothing-text {
	font-size: 24rpx;
	font-weight: 400;
	color: #9E9E9E;
}
/* 平台适配 */
/* #ifdef MP-WEIXIN */
.share-page {
	padding-top: var(--status-bar-height);
	padding-bottom: calc(env(safe-area-inset-bottom) + 32rpx);
}
.kong {
	height: calc(env(safe-area-inset-bottom) + 32rpx);
}
/* #endif */

/* #ifdef APP-PLUS */
.share-page {
	padding-top: var(--status-bar-height);
	padding-bottom: calc(env(safe-area-inset-bottom) +  42rpx);
}
.kong {
	height: calc(env(safe-area-inset-bottom) + 42rpx);
}
/* #endif */
</style>
