<template>
	<view>
		<navbar :config="config" backColor="#999999">
			<template v-slot:right>
				<view class="" @click.stop="lookExplain()" style="font-size: 28rpx;margin-right: 30rpx;color: #fff;">
					<text class="iconfont3">&#xe64c;</text>
					<text style="margin-left: 6rpx;">收益说明</text>
				</view>
			</template>
		</navbar>
		<view class="consume-top">
			<view class="consume-content">
				<text class="consume-nuns">{{ $addDecimals(commission_able , 2)  }}</text>
				<text class="consume-text">贡献值</text>
				<text class="consume-text">累计贡献值：{{ $addDecimals(commission_settled , 2)  }}</text>
			</view>
			<view class="look-integral" @click.stop="goIntegrateBalance">
				查看积分
			</view>
		</view>
		<consume-list title="贡献值明细" :status="status" :list="pointsList" :keys="{title: 'remark',
						time: 'format_create_time_millis',
						val: 'entry_value',
						type: 'bill_type'}"></consume-list>

	</view>
</template>

<script>
	import {
		userbillInfo
	} from "@/api/personal-center.js"
	import {
		getAccountInfo
	} from "@/api/login.js"
	export default {
		data() {
			return {
				commission_able: 0,
				commission_settled: 0,
				config: {
					back: true, //false是tolbar页面 是则不写
					title: '贡献值明细',
					color: '#1A1A1A',
					// autoBack:true,
					//背景颜色;参数一：透明度（0-1）;参数二：背景颜色（array则为线性渐变，string为单色背景）
					backgroundColor: [1, "#fff"],
					statusBarFontColor: '#1A1A1A',
					rightSlot: true,
				},
				params: {
					page: 1,
					limit: 10
				},
				pointsList: [],
				status: 'loading', //more|loading|noMore
			};
		},
		onShow() {
			this.getUserInfo()
			this.params.page = 1;
			this.pointsList = [];
			this.getList();
		},
		onReachBottom() {
			if (this.status !== 'loading' && this.status !== 'noMore') {
				this.params.page++
				this.getList()
			}
		},
		onPullDownRefresh() {
			this.params.page = 1
			this.pointsList = []
			this.getList()
		},
		methods: {
			lookExplain(){
				uni.navigateTo({
					url: '/pages/protocol/index?code=income_statement'
				})
			},
			getList() {
				this.status = 'loading';
				this.$http.get(userbillInfo, this.params).then((res) => {
					if (res && res.code == 200) {
						uni.stopPullDownRefresh()
						this.pointsList = this.pointsList.concat(res.page.list);
						if (res.page.totalPage <= res.page.currPage) {
							this.status = 'noMore'
						} else {
							this.status = 'more'
						}
					}
				});
			},
			//获取个人信息
			getUserInfo() {
				this.$http.get(getAccountInfo).then(res => {
					if (res && res.code == 200) {
						this.commission_able = res.data.commission_able;
						this.commission_settled = res.data.commission_settled;
						uni.setStorageSync("personal", res.data)
					}
				})
			},
			// 积分余额
			goIntegrateBalance() {
				uni.navigateTo({
					url: "/pages/user/integrateBalance"
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.consume-top {
		width: 100%;
		min-height: 365rpx;
		background-color: #FA6138;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 50rpx 60rpx 173rpx;

		.consume-content {
			width: 1px;
			flex: 1;
			display: flex;
			flex-direction: column;

			.consume-nuns {
				font-size: 50rpx;
				font-family: PingFang SC, PingFang SC-Regular;
				font-weight: 400;
				color: #ffffff;
				padding-bottom: 15rpx;
			}

			.consume-text {
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC-Regular;
				font-weight: 400;
				color: #ffffff;
			}
		}

		.look-integral {
			flex-shrink: 0;
			width: 200rpx;
			height: 60rpx;
			background: #ffffff;
			border-radius: 30rpx;
			text-align: center;
			line-height: 60rpx;
			font-size: 26rpx;
			font-family: PingFang SC, PingFang SC-Regular;
			font-weight: 400;
			color: #FA6138;
		}
	}
</style>
