<template>
	<view class="content">
		<view class="content-money">
			<view class="status_bar"><!-- 这里是状态栏 --></view>
			<view class="body-title">
				<view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view>
				<view class="header">李丹丹的裂变</view>
			</view>
			<view class="content-bg"><image src="https://cgst.liuniu946.com/image/fissioned-other.png" mode=""></image></view>
			<view class="money-box">
				<view class="money">{{ userInfo.white_integral | getMoneyStyle }}</view>
				<view>李丹丹的裂变总数</view>
			</view>
		</view>
		<swiper :style="{ height: height }" class="swiper-box" duration="300">
			<swiper-item class="tab-content">
				<scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
					<!-- 空白页 -->
					<!-- <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty> -->

					<!-- 订单列表 -->
					<view>
						<view class="order-item flex" v-for="(item, index) in 10" :key="index" @click="navto('/pages/shop/fissioned-other')">
							<view class="title-box flex_item">
								<view class="title-avatar"><image src="../../static/error/missing-face.png"></image></view>
								<view class="list_tpl">
									<view class="title"><text>御风</text></view>
									<view class="time"><text>13541202523</text></view>
								</view>
							</view>
							<view class="money">
								裂变量:
								<text class="status">3</text>
								<text class="jt">></text>
							</view>
						</view>
					</view>
					<!-- <uni-load-more :status="tabItem.loadingType" v-if="!(tabItem.orderList.length == 0 && tabItem.loaded)"></uni-load-more> -->
				</scroll-view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
import { getWhiteJf, getUserInfo } from '@/api/user.js';
import { spreadCommission, userBalance } from '@/api/wallet.js';
import { getMoneyStyle } from '@/utils/rocessor.js';
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
import empty from '@/components/empty';
export default {
	filters: {
		getMoneyStyle
	},
	components: {
		empty,
		uniLoadMore
	},
	onReady(res) {
		var _this = this;
		uni.getSystemInfo({
			success: resu => {
				const query = uni.createSelectorQuery();
				query.select('.swiper-box').boundingClientRect();
				query.exec(function(res) {
					_this.height = resu.windowHeight - res[0].top + 'px';
					console.log('打印页面的剩余高度', _this.height);
				});
			},
			fail: res => {}
		});
	},
	data() {
		return {
			height: '',
			// 头部图高度
			maxheight: '',
			navList: [],
			money: ''
		};
	},
	onLoad(options) {},
	onShow() {
		// this.loadData();
		// // 获取用户余额
		// getUserInfo({}).then(({ data }) => {
		// 	this.money = data.now_money;
		// 	this.setUserInfo(data);
		// });
	},
	computed: {
		...mapState(['userInfo'])
	},
	methods: {
		...mapMutations(['setUserInfo', 'setOrderInfo']),
		toBack() {
			uni.navigateBack({});
		},
		// 页面跳转
		navto(e) {
			uni.navigateTo({
				url: e
			});
		},
		//获取收入支出信息
		async loadData(source) {
			let obj = this;
			//这里是将订单挂载到tab列表下
			if (source === 'tabChange' && navItem.loaded === true) {
				//tab切换只有第一次需要加载数据
				return;
			}
			if (navItem.loadingType === 'loading') {
				//防止重复加载
				return;
			}
			// 修改当前对象状态为加载中
			navItem.loadingType = 'loading';

			getWhiteJf({
				page: navItem.page,
				limit: navItem.limit,
				pm: navItem.state
			})
				.then(({ data }) => {
					this.zc = data.zc;
					this.sr = data.sr;
					navItem.orderList = navItem.orderList.concat(data.list);
					navItem.page++;
					if (navItem.limit == data.list.length) {
						navItem.loadingType = 'more';
					} else {
						navItem.loadingType = 'noMore';
					}
					this.$set(navItem, 'loaded', true);
				})
				.catch(e => {
					console.log(e);
				});
		},

		//swiper 切换
		changeTab(e) {
			this.tabCurrentIndex = e.target.current;
			this.loadData('tabChange');
		},
		//顶部tab点击
		tabClick(index) {
			this.tabCurrentIndex = index;
		}
	}
};
</script>

<style lang="scss">
page {
	background: #fff;
	height: 100%;
}

.status_bar {
	height: var(--status-bar-height);
	width: 100%;
}

.content-money {
	position: relative;
	height: 430rpx;

	.content-bg {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		width: 750rpx;
		height: 430rpx;

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

	.body-title {
		height: 80rpx;
		text-align: center;
		font-size: 35rpx;
		position: relative;

		.header {
			position: absolute;
			left: 0;
			top: 0;
			width: 100%;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #fffeff;
			height: 80rpx;
			font-size: 36rpx;
			font-weight: 700;
			z-index: 9;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.goback-box {
			position: absolute;
			left: 18rpx;
			top: 0;
			height: 80rpx;
			display: flex;
			align-items: center;
		}

		.goback {
			z-index: 100;
			width: 34rpx;
			height: 34rpx;
		}
	}
}

.money-box {
	position: relative;
	z-index: 2;
	padding-top: 100rpx;
	color: #ffffff;
	text-align: center;
	/* #ifdef APP-PLUS */
	padding-top: 30rpx;

	/* #endif */
	.money {
		font-size: 72rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #ffffff;
		text {
			font-size: 36rpx;
		}
	}

	.text {
		font-size: 30rpx;
	}
}

//列表
.swiper-box {
	.order-item:last-child {
		margin-bottom: 60rpx;
	}

	.order-item {
		padding: 20rpx 30rpx;
		line-height: 1.5;

		.title-box {
			width: 100%;

			.title-avatar {
				width: 100rpx;
				height: 100rpx;
				margin-right: 25rpx;

				image {
					width: 100%;
					height: 100%;
					border-radius: 100%;
				}
			}

			.list_tpl {
				width: 50%;

				.title {
					font-size: $font-lg;
					color: $font-color-base;
					overflow: hidden; //超出的文本隐藏
					text-overflow: ellipsis; //溢出用省略号显示
					white-space: nowrap;
				}

				.time {
					margin-top: 15rpx;
					font-size: 22rpx;
					color: $font-color-light;
				}
			}
		}

		.money {
			width: 30%;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
			text-align: right;

			.status {
				color: #ff4c4c;
			}
			.jt {
				color: #999999;
				display: inline-block;
				margin-left: 10rpx;
			}
		}
	}
}

.list-scroll-content {
	background: #ffffff;
	height: 100%;
}

.content {
	height: 100%;

	.empty-content {
		background-color: #ffffff;
	}
}

.btn-box {
	width: 674rpx;
	height: 88rpx;
	background: linear-gradient(0deg, #2e58ff, #32c6ff);
	border-radius: 44rpx;
	font-size: 36rpx;
	font-family: PingFang SC;
	font-weight: 500;
	color: #ffffff;
	text-align: center;
	line-height: 88rpx;
	position: fixed;
	bottom: 48rpx;
	left: 0;
	right: 0;
	margin: 0 auto;
}
</style>
