<template>
	<view class="container">
		<view class="list">
			<view class="title-box">
				<!-- <view class="title">2017年5月</view> -->
				<uni-datetime-picker v-model="range" type="daterange" @change="onRangeChange" />
				<view class="statistics">
					<text class="text">获得：</text>
					<text class="text">{{getIntegral}}</text>
					<text style="margin-left: 10px" class="text">使用：</text>
					<text class="text">{{useIntegral}}</text>
				</view>
			</view>
			<view class="item-box" v-for="item in payList" :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 {
		ownerIntegralRecordsApi
	} from '@/config/api.js'
	import noData from '@/components/no-data/no-data'
	export default {
		components: {noData},
		data() {
			return {
				getIntegral: 0,
				useIntegral: 0,
				pageNo: 1,
				range: [],
				payList: []
			}
		},
		methods: {
			onRangeChange(val) {
				this.pageNo = 1
				this.range = val
				this.getList()
			},
			async getList() {
				let {result} = await ownerIntegralRecordsApi({
					pageNo: this.pageNo,
					startDate: this.range[0] || '',
					endDate: this.range[1] || ''
				})
				this.payList = result.pageList.records
				this.getIntegral = result.getIntegral
				this.useIntegral = result.useIntegral * -1
			},
			toRecord(type) {
				if(type == 1){
					uni.navigateTo({
						url: '/pages/payCostStatistical/index',
					});
				}else if(type == 2){
					uni.navigateTo({
						url: '/pages/payCostRecord/index',
					});
				}
			}
		},
		onLoad() {
			this.getList()
		}
	}
</script>
<style>
	page {
		background-color: #F8F6F9;
	}
</style>
<style lang="scss" scoped>
	.container {
		padding: 30rpx;
	}
	.list {
		background-color: #FFFFFF;
		box-shadow: 0rpx 0rpx 25rpx 0rpx rgba(81,89,234,0.06);
		border-radius: 16rpx;
		padding: 0 30rpx;
		margin-bottom: 30rpx;
		.title-box {
			padding: 30rpx 0;
			.title {
				line-height: 1;
				font-size: 34rpx;
				font-weight: bold;
				color: #373737;
			}
			.statistics {
				margin-top: 18rpx;
				font-size: 0;
				.text {
					color: #9D9CA6;
					font-size: 28rpx;
				}
			}
		}
		.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>