<template>
	<!-- <div>交易明细</div> -->
	<view class="box">
		<view class="top flex" :style="{ borderRadius: '31.5rpx' }">
			<view @click="changeTab(0)" :class="{ active : type == 0 }" class="income flex element"
				:style="{ borderRadius: '31.5rpx' }">
				收入明细
			</view>
			<view @click="changeTab(1)" :class="{ active : type == 1 }" class="income flex element"
				:style="{ borderRadius: '31.5rpx' }">
				支出明细
			</view>
		</view>

		<view v-for="(item,index) in list" :key="index" class="Recharge flex">
			<view class="flex">
				<image src="https://img1.baidu.com/it/u=3034232350,1041791648&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500"
					mode=""></image>
				<view class="text1">
					<view class="text2">
						{{ item.title }}
					</view>
					<view>
						2020-12-29 12:54:54
					</view>
				</view>
			</view>
			<view class="text3">
				{{ item.type == '收入' ? '+' : '-' }}{{ item.amount }}
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from "vue"
	import {
		amountLogList
	} from "@/api/amount/index.js"

	import {
		onShow
	} from "@dcloudio/uni-app"

	onShow(() => {
		getRunningWater()
	})

	const list = ref([]);
	const type = ref(0);

	// 获取流水
	const getRunningWater = async () => {
		let response = await amountLogList({
			type: type.value
		});
		if (response.code == 200) {
			list.value = response.data
		}
	}

	const changeTab = (index) => {
		type.value = index;
		getRunningWater();
	}
</script>

<style scoped lang="scss">
	.box {
		width: 750rpx;
		height: 1452rpx;
		background-color: #FFFFFF;
		padding: 2% 2% 0 2%;
		box-sizing: border-box;
	}

	.top {
		width: 722rpx;
		height: 63rpx;
		background-color: #F3F3F3;
	}

	.active {
		background-color: #FFBF60;
		color: white;
	}

	.income {
		width: 361rpx;
		height: 63rpx;
		line-height: 63rpx;
		font-size: 30rpx;
		justify-content: center;
	}



	.Recharge {
		padding: 3% 3% 0 2%;
		box-sizing: border-box;
		justify-content: space-between;
	}

	.flex {
		display: flex;
	}

	.text1 {
		font-size: 30rpx;
		color: #949494;
	}

	.Recharge image {
		width: 56rpx;
		height: 56rpx;
		margin-top: 0.5%;
	}

	.text2 {
		font-weight: 700;
		color: #333333;
	}

	.text3 {
		color: #FF2A2A;
	}
</style>