<!-- 流水页面 -->
<template>
	<view class="running-water bx">
		
		<view class="type">
			<view 
			:class="{select : index == select}" 
			:key="index"
			@click="selectType(index)"
			v-for="(item, index) in type">
				<!-- <text>{{ item.name }}</text> -->
				<text>{{ $t(`page.runningWater.${item.name}`) }}</text>
			</view>
		</view>
		
		<u-list @scrolltolower="scrolltolower" height="calc(100vh - 90rpx)">
			<!-- 流水列表 -->
			<view class="running-water-list content">
				<view v-for="item in runningWaterList" :key="item.id" class="running-water-item">
					<view class="left">
						<view class="time">{{ item.createTime }}</view>
						<div :class="{ red : item.type == 1 }" class="tag">{{ $t(`page.runningWater.${item.state == 0 ? 3 : item.type }`) }}</div>
					</view>
					<view class="money-detail">
						{{ $store.state.unit }}{{ item.money }}
					</view>
				</view>
			</view>
		</u-list>
		
		<sTabbar/>
	</view>
</template>

<script>
	// import index from '../../uni_modules/uview-ui'
	import navbar from '@/components/base/m-navbar.vue'

	export default {
		components: {
			navbar
		},
		data() {
			return {
				queryparams: {
					pageNo: 1,
					pageSize: 10
				},
				runningWaterList: [],
				select : 0,
				type : [
					{
						name : 'all'
					},
					{
						name : 'expenditure'
					},
					{
						name : 'income'
					},
				]
			}
		},
		onShow() {
			this.getRunningWater()
		},
		methods: {

			leftClick() {
				uni.navigateTo({
					url: '/pages/center/center'
				})
			},
			
			selectType(index){
				this.select = index
				this.getRunningWater()
			},

			//获取流水
			getRunningWater() {
				let queryparams = {
					...this.queryparams
				}
				
				if(this.select != 0){
					queryparams.type = this.select - 1
				}
				
				this.request('WaterPage', {}, queryparams).then(res => {
					if (res.code == 200) {
						this.runningWaterList = res.result.records
					}
				})
			},
			
			//滑动到页面底部
			scrolltolower(){
				this.queryparams.pageSize += 10
				this.getRunningWater()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.running-water {
		width: 750rpx;
		min-height: 100vh;
		background-color: #f7f7f7;
		margin: 0 auto;
		background-size: 100%;
		background-repeat: no-repeat;
		padding-top: 90rpx;
		
		.type{
			display: flex;
			background-color: #fff;
			position: fixed;
			width: 100%;
			top: 0;
			left: 0;
			height: 90rpx;
			justify-content: center;
			align-items: center;
			color: #989898;
			font-size: 28rpx;
			z-index: 999;
			&>view{
				flex: 1;
				display: flex;
				justify-content: center;
				align-items: center;
			}
			.select{
				color: #000;
				text{
					padding-bottom: 10rpx;
					border-bottom: 3px solid #000;
				}
			}
		}

		.content {
			width: 96%;
			margin: 0 auto;
		}

		.running-water-list {
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;
			margin-top: 20rpx;

			.running-water-item {
				display: flex;
				justify-content: space-between;
				box-sizing: border-box;
				padding: 15rpx;
				width: 100%;
				margin-bottom: 25rpx;
				background: white;
				
				.left{
					.time {
						margin: 15rpx 0rpx;
					}
					
					.tag{
						display: inline-block;
						background: #61ABFF;
						font-size: 24rpx;
						border-radius: 50rpx;
						padding: 0rpx 15rpx;
					}
					
					.red{
						color: red;
					}
				}

				.money-detail {
					// color: #3AA56B;
					font-size: 36rpx;
					color: #3FCE9D;
				}
			}
		}
	}
</style>