<<<<<<< HEAD
<template>
	<view class="content">
		<view class="top-bg">

		</view>
		<view class="yue-wrap flex">
			<view class="yue-tit">
				总资产(CNY)
			</view>
			<view class="yue-num flex">
				<view class="yue">
					{{userInfo.now_money || '0.00'}}
				</view>
				<view class="cz" @click="navto('/pages/money/recharge')">
					充值
					<image src="../../static/icon/dz.png" mode="widthFix"></image>
				</view>
			</view>
			<view class="lj-wrap flex">
				<view class="">
					累计消费：￥{{ userInfo.orderStatusSum || '0'}}
				</view>
				<view class="">
					累计充值：￥{{ userInfo.recharge || '0' }}
				</view>
			</view>
		</view>
		<scroll-view scroll-y="true" class="jl-wrap" :style="{'height': maxheight}" @scrolltolower="loadData">
			<view>
				<empty v-if="navList[tabCurrentIndex].orderList.length == 0 && navList[tabCurrentIndex].loaded"></empty>
				<view class="jl " v-for="item in navList[tabCurrentIndex].orderList">
					<view class="jl-tit flex">
						<view class="clamp2 tit">
							{{item.title}}
						</view>
						<view class="price" :class="{'add':item.pm == 1,'jian': item.pm == 0}">
							{{item.number*1}}
						</view>
					</view>
					<view class="jl-mark flex">
						<!-- <view class="mark">
							{{item.mark}}
						</view> -->
						<view class="">
							{{item.add_time}}
						</view>
					</view>
				</view>
				<uni-load-more :status="navList[tabCurrentIndex].loadingType"></uni-load-more>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import {
		spreadCommission,
		userBalance
	} from '@/api/wallet.js';
	import {
		getMoneyStyle
	} from '@/utils/rocessor.js';
	import {
		getUserInfo,
		getUser
	} from '@/api/user.js';
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import empty from '@/components/empty';
	export default {
		filters: {
			getMoneyStyle
		},
		components: {
			empty,
			uniLoadMore
		},
		onReady() {
			// 初始化获取页面宽度
			var obj = this;
			uni.getSystemInfo({
				success: resu => {
					const query = uni.createSelectorQuery();
					query.select('.jl-wrap').boundingClientRect();
					query.exec(function(res) {
						obj.maxheight = resu.windowHeight - res[0].top + 'px';
					});
				},
				fail: res => {}
			});
		},
		data() {
			return {
				// 头部图高度
				maxheight: '',
				tabCurrentIndex: 0,
				navList: [{
						state: 0,
						text: '收入',
						loadingType: 'more',
						orderList: [],
						page: 1, //当前页数
						limit: 10, //每次信息条数
						loaded: false
					}, {
						state: 2,
						text: '收入',
						loadingType: 'more',
						orderList: [],
						page: 1, //当前页数
						limit: 10, //每次信息条数
						loaded: false
					},
					{
						state: 1,
						text: '支出',
						loadingType: 'more',
						orderList: [],
						page: 1, //当前页数
						limit: 10, //每次信息条数
						loaded: false
					},

				],
				money: '',
				userInfo: {}
			};
		},
		onLoad(options) {},
		onShow() {
			this.loadData();
			this.getUserInfo()
		},
		methods: {
			...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
			getUserInfo() {
				getUser({}).then(({ data }) => {
					this.userInfo = data
				});
			},
			// 页面跳转
			navto(e) {
				uni.navigateTo({
					url: e
				});
			},
			//获取收入支出信息
			async loadData(source) {
				//这里是将订单挂载到tab列表下
				let index = this.tabCurrentIndex;
				let navItem = this.navList[index];
				let state = navItem.state;
				if (source === 'tabChange' && navItem.loaded === true) {
					//tab切换只有第一次需要加载数据
					return;
				}
				if (navItem.loadingType === 'loading') {
					//防止重复加载
					return;
				}
				// 修改当前对象状态为加载中
				navItem.loadingType = 'loading';

				spreadCommission({
							page: navItem.page,
							limit: navItem.limit
						},
						state
					)
					.then(({
						data
					}) => {
						console.log(data, '获取数据');
						// if (data.count > 0) {
						// 	navItem.orderList = navItem.orderList.concat(data.list);
						// 	console.log(navItem.orderList);
						// 	navItem.page++;
						// }
						if (data.length > 0) {
							data.forEach(item => {
								console.log(item.list, '内部列表')
								navItem.orderList = navItem.orderList.concat(item.list)
							})
							// navItem.orderList = navItem.orderList.concat(data[0].list);
							console.log(navItem.orderList);
							navItem.page++;
						}
						if (navItem.limit == data.length) {
							//判断是否还有数据， 有改为 more， 没有改为noMore
							navItem.loadingType = 'more';
							return;
						} else {
							//判断是否还有数据， 有改为 more， 没有改为noMore
							navItem.loadingType = 'noMore';
						}
						uni.hideLoading();
						this.$set(navItem, 'loaded', true);

					})
					.catch(e => {
						console.log(e);
					});
			},

			//swiper 切换
			changeTab(e) {
				this.tabCurrentIndex = e.target.current;
				this.loadData('tabChange');
			},
			//顶部tab点击
			tabClick(index) {
				this.tabCurrentIndex = index;
			},
			addmoney() {
				uni.navigateTo({
					url: '/pages/money/recharge'
				})
			}
		}
	};
</script>

<style lang="scss">
	page {
		background-color: #fff;
		height: auto;
		min-height: 100%;
	}

	.top-bg {
		background-color: #ee2f72;
		height: 180rpx;
		width: 750rpx;
	}

	.yue-wrap {
		width: 670rpx;
		height: 320rpx;
		margin: -160rpx auto 30rpx;
		background: linear-gradient(-70deg, #FF77A7, #FF4A8A);
		box-shadow: 0px 15rpx 22rpx 6rpx rgba(238, 47, 114, 0.1);
		border-radius: 25rpx;
		color: #fff;
		font-size: 26rpx;
		padding: 50rpx 75rpx;
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-start;

		.yue-num {
			width: 100%;
			justify-content: space-between;

			.yue {
				font-size: 76rpx;
				font-weight: bold;
			}

			.cz {
				image {
					width: 13rpx;
					margin-left: 10rpx;
				}
			}
		}

		.lj-wrap {
			width: 100%;
			justify-content: space-between;
			font-size: 24rpx;
		}
	}

	.jl {
		width: 670rpx;
		margin: 0 auto 20rpx;
		padding: 35rpx 30rpx;
		background: #FFFFFF;
		box-shadow: 0px 0px 28px 0px rgba(48, 48, 48, 0.1);
		border-radius: 8px;

		.jl-tit {
			width: 100%;
			font-size: 28rpx;
			font-weight: bold;
			color: #333333;

			.tit {
				max-width: 450rpx;
			}

			.price {
				font-size: 38rpx;
				font-weight: bold;

			}

			.add {
				color: #EE2F72;

				&::before {
					content: '+';
					font-size: 28rpx;
					color: #EE2F72;
				}
			}

			.jian {
				color: #808080;

				&::before {
					content: '-';
					font-size: 28rpx;
				}
			}
		}

		.jl-mark {
			padding-top: 20rpx;
			width: 100%;
			font-size: 24rpx;
			font-weight: 500;
			color: #808080;
			align-items: flex-start;

			// justify-content: flex-end;
			.mark {
				max-width: 470rpx;
			}
		}
	}
</style>
