<template>
	<view class="center">
		<view class="content-money">
			<view class="money-box" v-if="list.length != 0">
				<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="ranking-box flex">
					<view class="ranking-bg"><image src="../../static/img/turnover1.png" mode=""></image></view>
					<view class="other-item ">
						<view v-if="list.length >= 2">
							<view class="other-avatar two">
								<view class="huangg"><image src="../../static/img/turnover3.png" mode=""></image></view>
								<image :src="list[1].image" mode=""></image>
							</view>
							<view class="other-name clamp">{{ list[1].group_name }}{{ list[1].store.name }}</view>
							<view class="other-price">
								<text>￥</text>
								{{ list[1].sum_pay_price || 0 }}
							</view>
						</view>
					</view>
					<view class="first-item">
						<view class="first-avatar">
							<view class="huangg"><image src="../../static/img/turnover2.png" mode=""></image></view>
							<image :src="list[0].image" mode=""></image>
						</view>
						<view class="first-name clamp">{{ list[0].group_name }}({{ list[0].store.name }})</view>
						<view class="first-price">
							<text>￥</text>
							{{ list[0].sum_pay_price || 0 }}
						</view>
					</view>
					<view class="other-item ">
						<view v-if="list.length >= 3">
							<view class="other-avatar three">
								<view class="huangg"><image src="../../static/img/turnover4.png" mode=""></image></view>
								<image :src="list[2].image" mode=""></image>
							</view>
							<view class="other-name clamp">{{ list[2].group_name }}({{ list[2].store.name }})</view>
							<view class="other-price">
								<text>￥</text>
								{{ list[2].sum_pay_price || 0 }}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="list">
			<view class="list-title flex">
				<view class="list-title-item left">排名</view>
				<view class="list-title-item zj">组名</view>
				<view class="list-title-item right">销售金额</view>
			</view>
			<scroll-view scroll-y="true" class="list-main" :style="{ height: maxheight + 'px' }" @scrolltolower="loadData()">
				<view class="list-main-item flex" v-for="(item, index) in list" :key="index">
					<view class="list-main-num left">{{ index + 1 }}</view>
					<view class="list-main-name zj">
						<!-- <image :src="item.image" mode=""></image> -->
						<view class="list-main-name-font clamp">{{ item.group_name }}({{ item.store.name }})</view>
					</view>
					<view class="list-main-price right">{{ item.sum_pay_price || 0 }}</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
import { groupList } from '@/api/info.js';
export default {
	data() {
		return {
			maxheight: '',
			list: [],
			pages: 1,
			limit: 1000
		};
	},
	onReady(res) {
		var _this = this;
		uni.getSystemInfo({
			success: resu => {
				const query = uni.createSelectorQuery();
				query.select('.list-main').boundingClientRect();
				query.exec(function(res) {
					_this.maxheight = resu.windowHeight - res[0].top;
					console.log('打印页面的剩余高度', _this.maxheight);
				});
			},
			fail: res => {}
		});
	},
	onLoad() {
		this.loadData();
	},
	methods: {
		toBack() {
			uni.navigateBack({});
		},
		loadData() {
			const obj = this;
			if (obj.loadType == 'nomore' || obj.loadType == 'loading') {
				return;
			}
			obj.loadType = 'loading';
			groupList({
				pages: obj.pages,
				limit: obj.limit
			}).then(({ data }) => {
				console.log(data);
				this.list = this.list.concat(data.list);
				if (data.list.length == obj.limit) {
					obj.loadType = 'more';
				} else {
					obj.loadType = 'nomore';
				}
			});
		}
	}
};
</script>

<style lang="scss">
.center,
page {
	min-height: 100%;
	// height: auto;
	background: #f6f6f6;
}
.content-money {
	padding-bottom: 30rpx;
	background: linear-gradient(0deg, #fe6f61 0%, #ff4343 100%);
}
.money-box {
	padding-top: var(--status-bar-height);
	height: 468rpx;
	color: #ffffff;
	text-align: center;
	justify-content: center;
	position: relative;
	.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: 32rpx;
			font-weight: 700;
			z-index: 9;
			display: flex;
			justify-content: center;
			align-items: center;
		}
		.goback-box {
			position: absolute;
			z-index: 10;
			left: 24rpx;
			top: 0;
			height: 80rpx;
			display: flex;
			align-items: center;
		}
		.goback {
			width: 30rpx;
			height: 36rpx;
		}
	}
	.ranking-box {
		margin: 64rpx auto 0;
		width: 720rpx;
		height: 286rpx;
		position: relative;
		align-items: flex-end;
		padding-bottom: 30rpx;
		.ranking-bg {
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			width: 720rpx;
			height: 286rpx;
			image {
				width: 100%;
				height: 100%;
			}
		}
		.other-item {
			width: 216rpx;
			display: flex;
			flex-direction: column;
			justify-content: flex-end;
			align-items: center;
			line-height: 1;
			.two {
				border: #c8d2de 3px solid;
			}
			.three {
				border: #f2aa70 3px solid;
			}
			.other-avatar {
				position: relative;
				width: 84rpx;
				height: 84rpx;
				border-radius: 50%;
				image {
					width: 100%;
					height: 100%;
				}
				.huangg {
					position: absolute;
					width: 40rpx;
					height: 40rpx;
					top: -26rpx;
					left: -26rpx;
					image {
						width: 100%;
						height: 100%;
					}
				}
			}
			.other-name {
				position: relative;
				z-index: 2;
				margin-top: 15rpx;
				font-size: 22rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #000000;
			}
			.other-price {
				margin-top: 14rpx;
				text-align: center;
				position: relative;
				z-index: 2;
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #ef041f;
				text {
					font-size: 24rpx;
				}
			}
		}
		.first-item {
			width: 290rpx;
			display: flex;
			flex-direction: column;
			justify-content: flex-end;
			align-items: center;
			line-height: 1;
			.first-avatar {
				position: relative;
				width: 126rpx;
				height: 126rpx;
				border-radius: 50%;
				border: #ffd010 3px solid;
				image {
					width: 100%;
					height: 100%;
				}
				.huangg {
					position: absolute;
					z-index: 2;
					width: 52rpx;
					height: 52rpx;
					top: -28rpx;
					left: -28rpx;
					image {
						width: 100%;
						height: 100%;
					}
				}
			}
			.first-name {
				position: relative;
				z-index: 2;
				margin-top: 14rpx;
				font-size: 29rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #000000;
			}
			.first-price {
				margin-top: 14rpx;
				text-align: center;
				position: relative;
				z-index: 2;
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #ef041f;
				text {
					font-size: 24rpx;
				}
			}
		}
	}
}
.list {
	width: 690rpx;
	background: #ffffff;
	border-radius: 10rpx;
	margin: 20rpx auto 0;
	padding: 20rpx 42rpx 0;
	.list-title {
		background: linear-gradient(90deg, #fe6f61 0%, #ff4343 100%);
		border-radius: 42rpx;
		padding: 16rpx 0;
		.list-title-item {
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #ffffff;
			text-align: center;
		}
	}
	.list-main {
		margin-top: 20rpx;
	}
	.list-main-item {
		border-bottom: 1px solid #e8e8e8;
		padding: 30rpx 0;
		.list-main-num {
			text-align: center;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
		}
		.list-main-name {
			display: flex;
			justify-content: center;
			image {
				width: 44rpx;
				height: 44rpx;
			}
			.list-main-name-font {
				margin-left: 12rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
			}
		}
		.list-main-price {
			text-align: center;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #ef041f;
		}
	}
}
.left {
	width: 120rpx;
}
.zj {
	width: 316rpx;
}
.right {
	width: 184rpx;
}
</style>
