*-+
<template>
	<view class="content">
		<top></top>
		<view class="top-tit">邀请好友 变成壕友</view>
		<view class="center-wrap">
			<image src="../../static/img/tj-bg.png" mode="" class="tj-bg"></image>
			<view class="center-tit">邀请地址</view>
			<!-- <view class="tj-jl flex" @click="opneYj">
				<text>业</text>
				<text>绩</text>
			</view> -->
			<view class="tj-lj-tit">【链接地址】</view>
			<view class="tj-lj flex">
				<view class="lj-tit">邀请链接：</view>
				<view class="lj-info clamp">{{ address | addFile }}</view>
				<view class="lj-copy" @click="copy(address)">复制链接</view>
			</view>
			<view class="tj-lj1 flex">
				<view class="lj-tit">绑定关系：</view>
				<view class="lj-info clamp" v-if="!userInfo.spread"><input type="text" v-model="recommend" value="" /></view>
				<view class="lj-info clamp" v-if="userInfo.spread">{{ userInfo.spread.address | addFile }}</view>
				<view class="lj-copy" v-if="!userInfo.spread" @click="spare()">绑定关系</view>
			</view>
		</view>
<<<<<<< HEAD
		<view class="bottom">
			<image class="bottom-bg" src="../../static/img/bottom.png" mode=""></image>
			<view class="btn" @click="button()">查看推荐</view>
		</view>
		<!-- <uni-popup ref="yeji" type="center">
=======
<<<<<<< HEAD
		<view class="tj-look" @click="getReferrer()">
			查看推荐
		</view>
=======
		<view class="tj-look" @click="button()">查看推荐</view>
>>>>>>> 5fe50ff5c260e745ba7833a119b93bf915605eb5
		<uni-popup ref="yeji" type="center">
>>>>>>> be58bfe5874c430483ea559c136a0a93cde5e317
			<view class="yj-wrap">
				<view class="yj-tit">收益明细</view>
				<image src="../../static/img/yj-bg.png" mode="" class="yj-logo"></image>
				<view class="yj-hj flex">
					<view class="yj-hj-item">
						<view class="hj-item-val">0</view>
						<view class="hj-item-name">KGC总业绩</view>
					</view>
					<view class="yj-hj-item">
						<view class="hj-item-val">0</view>
						<view class="hj-item-name">FL总业绩</view>
					</view>
				</view>
				<view class="yj-nav flex">
					<view class="nav-item" v-for="(navitem, index) in navList" :class="{ active: index == tabIndex }" @click="navClick(index)">{{ navitem.name }}</view>
				</view>
				<view class="yj-info-wrap">
					<view class="yj-info-tit flex">
						<view class="">时间</view>
						<view class="">金额(KGC)</view>
					</view>
					<swiper class="yj-info-scroll" :current="tabIndex" duration="300">
						<swiper-item v-for="item in navList">
							<scroll-view scroll-y="true" class="yj-info-scroll" @scrolltolower="loadMore">
								<view v-for="itemt in item.list" class="">
									<view class="flex yj-info">
										<view class="">{{ itemt.time }}</view>
										<view class="">{{ itemt.val }}</view>
									</view>
								</view>
								<uni-load-more :status="item.loadingType"></uni-load-more>
							</scroll-view>
						</swiper-item>
					</swiper>
				</view>
			</view>
		</uni-popup> -->
		<uni-popup ref="yeji1" type="center">
			<view class="yj-wrap">
				<view class="yj-tit">我的推荐</view>
				<image src="../../static/img/yj-bg.png" mode="" class="yj-logo"></image>
				<view class="yj-info-wrap">
					<view class="yj-info-tit flex">
						<view class="">钱包地址</view>
						<view class="">时间</view>
					</view>
					<scroll-view scroll-y="true" class="yj-info-scroll" @scrolltolower="spreadList">
						<view v-for="itemt in List" class="">
							<view class="flex yj-info">
								<view class="address clamp">{{ itemt.address }}</view>
								<view class="time">{{ itemt.spread_time }}</view>
							</view>
						</view>
						<uni-load-more :status="loadingType"></uni-load-more>
					</scroll-view>
				</view>
			</view>
			<view class="popup-x" @click="closeRecord()"><image src="../../static/img/x.png" mode=""></image></view>
		</uni-popup>
	</view>
</template>

<script>
import top from '@/components/top/top.vue';
import { mapState, mapMutations } from 'vuex';
import { addSpread, spreadList } from '@/api/index.js';
import { getTime } from '@/utils/rocessor.js';
import uniCopy from '@/components/js_sdk/xb-copy/uni-copy.js';
export default {
	comments: {
		top
	},
	computed: {
		...mapState('user', ['address', 'hasLogin', 'userInfo'])
	},
	filters: {
		addFile(provider) {
			if (provider.length >= 19) {
				var subStr1 = provider.substr(0, 13);
				var subStr2 = provider.substr(provider.length - 6, 6);
				var subStr = subStr1 + '...' + subStr2;
				provider = subStr;
			}
			return provider;
		}
	},
	data() {
		return {
			navList: [
				{
					name: '直推业绩',
					page: 1,
					limit: 8,
					list: [],
					loaded: false,
					loadingType: 'more'
				},
				{
					name: '间推业绩',
					page: 1,
					limit: 8,
					list: [],
					loaded: false,
					loadingType: 'more'
				}
			],
			List:[],
			tabIndex: 0,
			page: 1,
			limit: 8,
			loadingType: 'more'
		};
	},
	onShow() {
		this.spreadList();
	},
	methods: {
		closeRecord() {
			this.$refs.yeji1.close();
		},
		spreadList(){
			let obj = this;
			if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
				return;
			}
			spreadList({page:obj.page,limit:obj.limit}).then(({data}) =>{
				data.data.list.forEach(e =>{
					if(e.spread_time != null){
						e.spread_time = getTime(e.spread_time)
					}
				})
				this.List = this.List.concat(data.data.list);
				if(data.data.list.length != obj.limit){
					obj.loadingType = 'noMore'
				}else {
					obj.page++
					obj.loadingType = 'more'
				}
			})
			obj.loadingType = 'loading';
		},
		copy(value) {
			let obj = this;
			let content = value; //需要复制的内容
			console.log('复制的内容:', content);
			// content = typeof content === 'string' ? content : content.toString(); // 复制内容，必须字符串，数字需要转换为字符串
			const result = uniCopy(content);
			if (result === false) {
				uni.showToast({
					title: '不支持'
				});
			} else {
				uni.showToast({
					title: '复制成功',
					icon: 'none'
				});
			}
		},
		spare() {
			const obj = this;
			if (this.recommend == '') {
				this.$api.msg('请填写要加入流量的地址');
				return;
			}

			uni.showModal({
				title: '提示',
				content: '您是否要绑定到改流量（' + this.recommend + '）',
				success: function(res) {
					if (res.confirm) {
						addSpread({ address: obj.recommend }).then(e => {
							console.log(e, '123468');
							if (e.code == 1) {
								obj.$api.msg('绑定成功');
								window.location.reload();
							}
						});
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
		},
		qrR() {},
		opneYj() {
			this.$refs.yeji.open();
		},
		button() {
			this.$refs.yeji1.open();
		},
		// 点击切换
		navClick(index) {
			this.tabIndex = index;
		},
		// 下滑到底加载更多
		loadMore() {
			let obj = this;
			let index = obj.tabIndex;
			let navItem = obj.navList[index];
			if (navItem.loadingType == 'noMore' || navItem.loadingType == 'loading') {
				return;
			}
			navItem.loadingType = 'loading';
			console.log('jiaz');
		}
	}
};
</script>

<style lang="scss" scoped>
page {
	background-color: #00050f;
}

.top-tit {
	text-align: center;
	font-size: 160rpx;
	font-family: zihun164hao-fangyuehei;
	font-weight: 400;
	font-style: italic;
	color: #08ede7;
	line-height: 168rpx;
	margin-bottom: 62rpx;
}

.box-top {
	display: flex;
	padding: 36rpx 41rpx 72rpx 41rpx;

	.bg3 {
		width: 56rpx;
		height: 62rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.two {
		margin-left: 36rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}
}

.center-wrap {
	width: 680rpx;
	height: 891rpx;
	margin: auto;
	position: relative;

	.tj-bg {
		position: absolute;
		width: 680rpx;
		height: 891rpx;
	}

	.center-tit {
		width: 680rpx;
		height: 102rpx;
		line-height: 102rpx;
		text-align: center;
		font-size: 44rpx;
		font-family: zihun100hao-fangfangxianfengti;
		font-weight: 900;
		color: #08ede7;
		position: absolute;
		top: 0;
	}

	.tj-jl {
		text-align: center;
		width: 61rpx;
		height: 110rpx;
		background: #08ede7;
		border-radius: 10rpx 0px 0px 10rpx;
		position: absolute;
		right: 0;
		top: 170rpx;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #001337;
		// line-height: 40rpx;
		flex-direction: column;
		justify-content: center;
	}

	.tj-qr {
		width: 383rpx;
		height: 383rpx;
		background: #ffffff;
		border: 5rpx solid #08ede7;
		position: absolute;
		right: 0;
		left: 0;
		top: 204rpx;
		margin: auto;
	}

	.tj-lj-tit {
		width: 680rpx;
		text-align: center;
		font-size: 31rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #ffffff;
		line-height: 103px;
		position: absolute;
		top: 560rpx;
	}

	.tj-lj1 {
		width: 636rpx;
		height: 67rpx;
		background: #233b75;
		border: 2rpx solid #08ede7;
		border-radius: 10rpx;
		position: absolute;
		bottom: 30rpx;
		right: 0;
		left: 0;
		margin: auto;
	}

	.tj-lj {
		width: 636rpx;
		height: 67rpx;
		background: #233b75;
		border: 2rpx solid #08ede7;
		border-radius: 10rpx;
		position: absolute;
		bottom: 124rpx;
		right: 0;
		left: 0;
		margin: auto;
	}
	.lj-tit {
		width: 148rpx;
		flex-shrink: 0;
		text-align: right;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #ffffff;
		line-height: 67rpx;
	}

	.lj-info {
		width: 148rpx;
		flex-grow: 1;
		text-align: left;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #ffffff;
		line-height: 67rpx;
	}

	.lj-copy {
		flex-shrink: 0;
		width: 148rpx;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #08ede7;
		line-height: 67rpx;
		// opacity: 0.75;
	}
}

.bottom {
	padding-top: 182rpx;
	position: relative;
	width: 750rpx;
	height: 434rpx;
	margin-top: -118rpx;
	.bottom-bg {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		height: 100%;
		width: 100%;
	}
	.btn {
		position: relative;
		z-index: 3;
		margin: 0 auto;
		width: 450rpx;
		height: 76rpx;
		background: linear-gradient(0deg, #ff7206, #ffdd7e);
		box-shadow: 0px 2px 8px 0px rgba(207, 126, 57, 0.7);
		border-radius: 38rpx;
		text-align: center;
		line-height: 76rpx;
		font-size: 36rpx;
		font-family: zihun164hao-fangyuehei;
		font-weight: 400;
		color: #ffffff;
	}
}

.yj-wrap {
	width: 680rpx;
	height: 854rpx;
	background: linear-gradient(180deg, #254fab 0%, #230a8e 100%);
	border-radius: 20rpx;

	.yj-logo {
		display: block;
		width: 326rpx;
		height: 16rpx;
		margin: auto;
		border-radius: 20px;
	}

	.yj-tit {
		width: 100%;
		padding-top: 60rpx;
		padding-bottom: 15rpx;
		text-align: center;
		font-size: 46rpx;
		font-family: zihun100hao-fangfangxianfengti;
		font-weight: bold;
		color: #ffffff;
		// line-height: 38px;
	}

	.yj-hj {
		width: 653rpx;
		height: 147rpx;
		background: #233b75;
		border: 2rpx solid #08ede7;
		border-radius: 10rpx;
		margin: 40rpx auto;

		.yj-hj-item {
			width: 50%;
			text-align: center;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #ffffff;
			line-height: 38rpx;

			// opacity: 0.7;
			.hj-item-val {
				font-size: 41rpx;
				padding-bottom: 10rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #08ede7;
				line-height: 38rpx;
			}
		}
	}

	.yj-nav {
		width: 582rpx;
		border-bottom: 2rpx solid #fff;
		margin: auto;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #97a1d2;
		line-height: 38rpx;

		.nav-item {
			padding: 20rpx 40rpx;
		}

		.active {
			color: #fff;
		}
	}
}

.yj-info-wrap {
	height: 362rpx;
	width: 582rpx;
	margin: auto;

	// background-color: #fff;
	.yj-info-tit {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #ffffff;
		line-height: 38rpx;
		justify-content: space-between;
		padding: 10rpx 0;
	}

	.yj-info-scroll {
		width: 582rpx;
		height: 320rpx;
		.yj-info {
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #ffffff;
			line-height: 38rpx;
			.address {
				width: 60%;
			}
		}
	}
}
.popup-x {
	margin: 62rpx auto 0;
	width: 66rpx;
	height: 66rpx;
	image {
		width: 100%;
		height: 100%;
	}
}
</style>
