<template>
	<view class="content">
		<view class="background">
			<image src="../../static/merchant/vipbackground.png" mode=""></image>
			<view class="title">
				{{ number }}
				<text class="ren">人</text>
			</view>
		</view>
		<scroll-view scroll-y="true" class="scroll-wrapper" :style="{ height: height }">
			<!-- 空白页 -->
			<!-- <empty v-if=" loaded && vipList.length == 0"></empty> -->
			<view class="vip-wrapper">
				<view class="vip" v-for="item in vipList">
					<view class="img"><image :src="item.avatar" mode=""></image></view>
					<view class="vip-content">
						<view class="left">
							<view class="top">
								<view class="name">{{ item.nickname }}</view>
								<view class="nameplate"></view>
							</view>
							<view class="bottom">{{ item.phone }}</view>
						</view>
						<view class="right">消费:¥{{ item.consume_sum }}</view>
					</view>
				</view>
			</view>

			<uni-load-more :status="loadingType"></uni-load-more>
		</scroll-view>
		<!-- <view class="vip-box">
			
		</view> -->
	</view>
</template>

<script>
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
import empty from '@/components/empty';
import { member } from '@/api/merchant.js'
export default {
	components: {
		empty,
		uniLoadMore
	},
	data() {
		return {
			loadingType: 'more',
			page: 1,
			limit: 10,
			height: '',
			number: 0, //人数
			vipList: []
		};
	},
	onReady(res) {
		var _this = this;
		uni.getSystemInfo({
			success: resu => {
				const query = uni.createSelectorQuery();
				query.select('.scroll-wrapper').boundingClientRect();
				query.exec(function(res) {
					console.log(res, 'ddddddddddddd');
					_this.height = resu.windowHeight - res[0].top + 'px';
					console.log('打印页面的剩余高度', _this.height);
				});
			},
			fail: res => {}
		});
	},
	onLoad() {
		this.loadData();
	},
	methods: {
		loadData() {
			let obj = this;
			console.log('加载数据');
			if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
				return;
			}
			obj.loadingType = 'loading'
			member({}).then(({data}) =>{
				console.log(data)
				this.number = data.count
				this.vipList = this.vipList.concat(data.data)
				obj.page ++
				if (data.data.length == obj.limit) {
					obj.loadingType = 'more';
				} else {
					obj.loadingType = 'noMore';
				}
			})
		}
	}
};
</script>

<style lang="scss">
.background {
	display: flex;
	justify-content: center;
	position: relative;
	width: 100%;
	height: 360rpx;

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

.title {
	position: absolute;
	text-align: center;
	line-height: 360rpx;
	font-size: 72rpx;
	font-family: PingFang SC;
	font-weight: bold;
	color: #ffffff;

	.ren {
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #ffffff;
		line-height: 43rpx;
	}
}
.scroll-wrapper {
	margin-top: 20rpx;
}
.vip-wrapper {
	padding: 0 26rpx 0 23rpx;
	background-color: #fff;
}
.vip {
	border-top: 1rpx solid #e3e3e3;
	display: flex;
	align-items: center;

	.img {
		margin: 0 20rpx;
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;

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

	.vip-content {
		margin: 30rpx 0;
		display: flex;
		justify-content: space-between;
		width: 580rpx;
		display: flex;
		align-items: center;

		.left {
			display: flex;
			flex-direction: column;

			.top {
				display: flex;

				.name {
					font-size: 30rpx;
					font-family: PingFangSC;
					font-weight: 500;
					color: #3f454b;
				}

				.nameplate {
				}
			}

			.bottom {
				font-size: 22rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #999999;
			}
		}

		.right {
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #ff6f0f;
		}
	}
}
</style>