<template>
	<view class="content">
		<u-list @scrolltolower="scrolltolower">
			<view class="myUser">
				<view class="myUserNum">
					{{divideAmount}}
				</view>
				<view class="myUserTitle">
					佣金总金额
				</view>
			</view>
			<view class="pageList">
				<u-list-item v-for="(item, index) in pageList" :key="index">
					<view class="myUserInit" :key="index">
						<view class="myUserImg">
							<image class="init_image" :src="item.avatar" mode=""></image>
						</view>
						<view class="myUserInitInfo">
							<view class="myUserInitInfoTop">
								<view class="myUserInitInfoTop-name">
									{{item.name}}
								</view>
								<view class="myUserInitInfoTop-num">
									<span class="initDataActive">{{item.divide_price}}</span>所得佣金总额：
								</view>
							</view>
							<view class="myUserInitInfoBottom">
								{{item.created_at}}
							</view>
							<view class="infoBtn" @click="gotoOrderList(item.uid)">
								查看订单
							</view>
						</view>
					</view>
				</u-list-item>
				<u-empty :show="pageList.length == 0" mode="history"
					icon="http://cdn.uviewui.com/uview/empty/history.png"></u-empty>
			</view>
		</u-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageList: [],
				divideAmount: 0,
				pageNum: 1
			}
		},
		onShow() {
			this.pageList = [];
			this.pageNum = 1;
			this.getUserList();
		},
		methods: {
			scrolltolower() {
				this.pageNum += 1;
				this.getUserList()
			},
			gotoOrderList(id) {
				uni.navigateTo({
					url: '/pageSub/pages/orderList/orderList?id=' + id
				})
			},
			//获取用户列表
			getUserList() {
				this.$request('/my-member', 'GET', {
					page: this.pageNum
				}).then(res => {
					console.log(res.data)
					this.divideAmount = res.data.divideAmount;
					this.pageList = [...this.pageList, ...res.data.list];
				}).catch(err => {
					uni.showToast({
						icon: 'error',
						title: '' + err.message
					})
				})
			},
		}
	}
</script>

<style lang="scss">
	.content {
		width: 100vw;
		height: 100vh;
		background: linear-gradient(to bottom, #f3d4d7, #f8f8f8, #f8f8f8);
	}

	.myUser {
		width: 100%;
		height: 126rpx;
		padding: 78rpx 0;
		text-align: center;

		.myUserNum {
			line-height: 88rpx;
			font-size: 64rpx;
			color: #D3195E;
			font-weight: 500;
			font-style: normal;
		}

		.myUserTitle {
			line-height: 38rpx;
			font-size: 24rpx;
			color: #666666;
		}
	}

	.pageList {
		width: calc(100% - 60rpx);
		margin: 0 30rpx;
		height: auto;
		overflow-y: scroll;
	}

	.myUserInit {
		width: calc(100% - 60rpx);
		padding: 30rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		background-color: #ffffff;
		border-radius: 24rpx;
		margin-bottom: 20rpx;

		.myUserImg {
			height: 92rpx;
			width: 92rpx;
			border-radius: 92rpx;
			overflow: hidden;
			border-radius: 92rpx;
		}

		.myUserInitInfo {
			flex: 1;
			margin-left: 10rpx;
			height: 92rpx;
			position: relative;

			.infoBtn {
				position: absolute;
				right: -10rpx;
				bottom: -10rpx;
				border-radius: 45rpx;
				height: 45rpx;
				line-height: 45rpx;
				text-align: center;
				width: 140rpx;
				background-color: #F6588D;
				color: #ffffff;
				font-size: 23rpx;
			}

			.myUserInitInfoTop {
				height: 54rpx;
				line-height: 54rpx;
				display: flex;
				flex-direction: row;
				align-items: center;

				.myUserInitInfoTop-name {
					width: 40%;
					font-size: 28rpx;
					color: #333333;
					font-weight: 600;
				}

				.myUserInitInfoTop-num {
					width: 60%;
					font-size: 24rpx;
					color: #666666;
					font-weight: 600;
					display: flex;
					flex-direction: row-reverse;
				}
			}

			.myUserInitInfoBottom {
				height: 38rpx;
				line-height: 38rpx;
				width: 100%;
				font-size: 24rpx;
				color: #666666;
			}
		}
	}

	.initDataActive {
		color: #F6588D;
	}
</style>