<template>
	<view class="container">
		<view class="top">
			<view class="current-box">
				<view class="text">可使用积分</view>
				<view class="use-box">
					{{integralInfo.availableIntegral || 0}}
					<text class="unit">分</text>
				</view>
				<view class="total-box">
					<text class="text">当前总积分:</text>
					<text class="integral">{{integralInfo.totalIntegral || 0}}</text>
					<text class="unit">分</text>
					<text style="margin-left:50rpx" class="text">冻结积分:</text>
					<text class="integral">{{integralInfo.freezeIntegral || 0}}</text>
					<text class="unit">分</text>
				</view>
			</view>
			<view class="link">
				<view class="accumulate-box">
					<view class="text">累计获得</view>
					<view class="value">
						<text class="integral">{{integralInfo.getIntegral || 0}}</text>
						<text style="margin-left:5px" class="unit">分</text>
					</view>
				</view>
				<view class="accumulate-box">
					<view class="text">累计使用</view>
					<view class="value">
						<text class="integral">{{integralInfo.useIntegral || 0}}</text>
						<text style="margin-left:5px" class="unit">分</text>
					</view>
				</view>
				<view class="accumulate-box">
					<view class="text">累计节省</view>
					<view class="value">
						<text class="unit">￥</text>
						<text class="integral">{{integralInfo.deductionAmount || 0}}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="list">
			<view class="title-box" @click="onLookAll">
				<view class="title">近30天记录</view>
				<view class="more">
					<text class="text">查看全部</text>
					<image src="../../static/images/icon_more.png" class="icon"></image>
				</view>
			</view>
			<view class="item-box" v-for="item in integralList" :key="item.id">
				<view>
					<view class="describe">{{item.type === 'scanQrCodePay' ? '扫码支付' : '抵扣物业费'}}</view>
					<view class="date-time">{{item.createTime}}</view>
				</view>
				<view class="compute">{{item.integralChange < 0 ? item.integralChange : ('+' + item.integralChange)}}</view>
			</view>
		</view>
		<!-- <no-data :show="payList.length === 0" text="暂无缴费信息"></no-data> -->
	</view>
</template>

<script>
	import {
		getOwnerIntegralApi,
		ownerIntegralListApi,
	} from '@/config/api.js'
	import noData from '@/components/no-data/no-data'
	export default {
		components: {noData},
		data() {
			return {
				integralInfo: {},
				integralList: [],
				pageNo: 1
			}
		},
		methods: {
			async getMessage() {
				let {result} = await getOwnerIntegralApi({})
				result['freezeIntegral'] = (result.systemFreezeIntegral + result.manualFreezeIntegral).toFixed(2).replace('.00', '')
				result['totalIntegral'] = (Number(result.freezeIntegral) + result.availableIntegral).toFixed(2).replace('.00', '')
				this.integralInfo = {...result}
			},
			async getList() {
				let {result} = await ownerIntegralListApi({
					pageNo: this.pageNo
				})
				this.integralList = [...result.records]
			},
			toRecord(type) {
				if(type == 1){
					uni.navigateTo({
						url: '/pages/payCostStatistical/index',
					});
				}else if(type == 2){
					uni.navigateTo({
						url: '/pages/payCostRecord/index',
					});
				}
			},
			onLookAll() {
				uni.navigateTo({
					url: "/pages/integralRecord/index"
				});
			}
		},
		onLoad() {
			this.getMessage()
			this.getList()
		}
	}
</script>
<style>
	page {
		background-color: #F8F6F9;
	}
</style>
<style lang="scss" scoped>
	.container {
		padding: 30rpx;
	}

	.top {
		border-radius: 16rpx;
		background-color: #E8E5FF;
		margin-bottom: 30rpx;

		.current-box {
			// background-position: top center;
			background-repeat: no-repeat;
			background-size: 100% 100%;
			background-image: url('https://life.cloud.hjxbc.cn/sys/common/static/miniapp/bg_jifen.png');
			// border-radius: 16rpx;
			padding: 40rpx;
			line-height: 1;
			.text {
				font-size: 28rpx;
				color: #D5DCFF;
			}
			.use-box {
				font-size: 60rpx;
				font-weight: bold;
				color: #FFFFFF;
				margin-top: 20rpx;
				.unit {
					font-size: 28rpx;
					font-weight: 400;
					margin-left: 5px;
				}
			}

			.total-box {
				margin-top: 40rpx;
				font-size: 0;
				.integral {
					font-size: 32rpx;
					font-weight: bold;
					color: #ffffff;
					margin: 0 5px;
				}
				.unit {
					font-size: 12px;
					color: #ffffff;
				}
			}
		}

		.link {
			display: flex;
			padding: 30rpx 0;

			.accumulate-box {
				flex: auto;
				width: 33%;
				font-size: 0;
				text-align: center;
				position: relative;
				&:not(:last-child) {
					&::after {
						content: " ";
						position: absolute;
						top: 5%;
						right: 0;
						width: 0;
						height: 90%;
						border-left: 1rpx solid #D6D3EC;
						z-index: 1;
					}
				}
				.text {
					font-size: 28rpx;
					color: #8B7FE8;
				}
				.value {
					margin-top: 10rpx;
					color: #6A59F2;
					.integral {
						font-size: 32rpx;
						font-weight: bold;
					}
					.unit {
						font-size: 12px;
					}
				}
			}
		}
	}

	.list {
		background-color: #FFFFFF;
		box-shadow: 0rpx 0rpx 25rpx 0rpx rgba(81,89,234,0.06);
		border-radius: 16rpx;
		padding: 0 30rpx;
		.title-box {
			height: 86rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.title {
				line-height: 1;
				font-size: 32rpx;
				font-weight: bold;
				color: #373737;
				padding-left: 18rpx;
				border-left: 3px solid #6852F0;
			}
			.more {
				.text {
					color: #9D9CA6;
					font-size: 28rpx;
				}
				.icon {
					width: 15rpx;
					height: 24rpx;
					vertical-align: middle;
					margin-left: 20rpx;
				}
			}
		}
		.item-box {
			height: 130rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			border-top: 1rpx solid #F0F0F2;
			line-height: 1;
			.describe {
				font-size: 32rpx;
				color: #373737;
			}
			.date-time {
				font-size: 28rpx;
				color: #9D9CA6;
				margin-top: 20rpx;
			}
			.compute {
				font-size: 36rpx;
				font-weight: bold;
				color: #6A59F2;
			}
		}
	}

</style>