
<template>
	<view>
		<ujp-navbar title="充值记录">
		
		</ujp-navbar>
		<view class="rechargeTime" @click="show = true">
			<u-picker mode="time" v-model="show" :params="params" 
			:default-time="dateMonth"
			@confirm="confirmTime" @cancel="cancelTime"></u-picker>
			<span>{{month}}月</span>
			<u-icon name="arrow-down-s-fill" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
		</view>
		<view style="text-align: center;margin-top: 100px" v-if="!accountList.length">
		
			<img src="@/assets/img/blankpage.png">
			<p>暂无充值记录</p>
		</view>
	<!-- 	<view class="carNone" v-if="accountList.length == 0">
			<img src="static/img/暂无数据-缺省页.png" alt="">
			<p>暂无充值记录</p>
		</view> -->
		<view class="rechargeList" v-if="accountList.length > 0">
			<view class="rechargeList-item" v-for="(item,index) in accountList" :key="item.id" @click="gotoUrl('pages/user/rechargeDeatilsByPhone?id=' + item.id)">
				<view class="rechargeList-row"><span>帮人充值（{{item.phone}}）</span><h4>{{item.rechargeTotal}}元</h4></view>
				<view class="rechargeList-row"><p>{{item.payNameStr}}</p><p>{{item.createTime}}</p></view>
			</view>
		</view>
	</view>
</template>

<script>
	import * as API from '@/apis/otherRecharge.js'
	
	export default {
		data() {
			return {
				userId: '',
				params: {
					year: true,
					month: true,
					day: false,
					hour: false,
					minute: false,
					second: false,
					timestamp: true,
				},
				show: false,
				month: '',
				dateMonth: '',
				accountList: [],
			}
		},
		onReady() {			
			if(this.carhelp.getPersonInfo()) {
				this.userId = this.carhelp.getPersonInfo().id;
			}
			
			var date = new Date();
			this.month = date.getMonth() + 1;
			
			var year = date.getFullYear();
			var monthN = this.month;
			if(monthN >= 1 && monthN <= 9) {
				monthN = "0" + monthN;
			}
			this.dateMonth = year + '-' + monthN + '-01';
					
			this.getAccountRecordData();
		},
		methods: {
			toRefundList() {
				uni.navigateTo({
					url: '/pages/user/refundList'
				})
			},
			getAccountRecordData() {
				uni.showLoading({
					title: "加载中",
					mask: true,
				})		
				API.rechargeData({
					openId:this.carhelp.getOpenId(),
					queryDate: this.dateMonth,
					pageSize: 50,
				}).then((res) => {
					uni.hideLoading();
					
					this.accountList = res.data.data;
				}).catch(error => {
					uni.showToast({
						title: error,
						icon: "none"
					})
				})
			},
			confirmTime(params) {
				this.dateMonth = params.year + '-' + params.month + '-01';
				if(params.month.slice(0,1) == '0') {
					this.month = params.month.slice(1);
				} else {
					this.month = params.month;
				}
				this.getAccountRecordData();
				this.show = false;
			},
			cancelTime() {
				this.show = false;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.slot-wrap{
		flex: 1;
	}
	.navBtn{
		float: right;
		margin-right: 15px;
		color:#3fbd70;
	}
	.carNone{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		img{
			width: 100%;
			height: 100%;
		}
		p{
			margin-top: -60px;
		}
	}
	.rechargeTime{
		background-color: #fff;
		height: 44px;
		display: flex;
		align-items: center;
		padding: 12px 16px;
		border-bottom: 1px solid #f7f7f7;
		span{
			margin-right: 4px;
		}
	}
	.rechargeList{
		background-color: #fff;
		padding-left: 16px;
		.rechargeList-item{
			padding: 12px 16px 12px 0;
			border-bottom: 1px solid #f7f7f7;
			&:last-child{
				border-bottom: none;
			}
		}
		.rechargeList-row{
			display: flex;
			align-items: center;
			justify-content: space-between;
			h4{
				font-size: 16px;
			}
			p{
				font-size: 12px;
				margin-top: 4px;
				color:#888;
			}
		}
	}
</style>