<template>
	<view class="pages">
		<u-navbar title="账变记录" :border-bottom="false" :background="bgc" back-icon-color="#fff" title-color='#fff'
			title-size='36' height='44'></u-navbar>
		<!-- 金额明细 -->
		<view class="pricemx">
			<view class="tab">
				<view :class="activeindex == 1 ? 'active' : ''" @click="btntab(1)">全部</view>
				<view :class="activeindex == 2 ? 'active' : ''" @click="btntab(2)">收入</view>
				<view :class="activeindex == 3 ? 'active' : ''" @click="btntab(3)">提现</view>
			</view>
			<scroll-view class="list" scroll-y="true" @scrolltolower="onScrollToLower" style="height: 1280rpx;">
				<view class="list_item" v-for="(item,index) in wateringList" :key="index" @click="btntxdeta(item.id,item.bstType)">
					<view class="top">
						<view v-if="item.bstType == 1">充值订单</view>
						<view v-if="item.bstType == 2">订单退款</view>
						<view v-if="item.bstType == 3">提现申请</view>
						<view style="color: #f9693c;" v-if="item.amount < 0">￥{{item.amount}}</view>
						<view style="color: #48893B;" v-else>￥{{item.amount}}</view>
					</view>
					<view class="yiy">
						<view>{{item.createTime}}</view>
						<view>余额￥{{item.afterBalance}}</view>
					</view>
					<view class="yiy">
						<view>变动原因：{{item.reason.length > 30 ? item.reason.substring(0,30) + '...' : item.reason}}</view>
						<!-- <view>查看详情</view> -->
					</view>
				</view>
				<view class="" style="width: 100%;text-align: center;color: #ccc;margin-top: 50rpx;">
					-已经到底了-
				</view>
			</scroll-view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: "#48893B",
				},
				activeindex: 1,
				infoobj: {},
				pagenum: 1,
				pagesize: 10,
                wateringList:[],
				bstType:'',
			}
		},
		onLoad() {
			
		},
		onShow() {
			this.pagenum = 1
			this.wateringList = []
			this.getlist()
		},
        // 分享到好友（会话）
          onShareAppMessage: function () {  
            return {  
              title: '创想物联',  
              path: '/pages/shouye/index'  
            }  
          },  
          
          // 分享到朋友圈  
          onShareTimeline: function () {  
            return {  
              title: '创想物联',  
              query: '',  
              path: '/pages/shouye/index'  
            }  
          },
		methods: {
			// 获取财务明细
			getlist() {
				this.$u.get('/app/user/myChangeBalanceList?pageNum=' + this.pagenum + '&pageSize=' + this.pagesize + '&type=' + this.bstType).then(res => {
					if (res.code == 200) {
						this.total = res.total
						if (res.data.length > 0) {  
							this.wateringList = this.wateringList.concat(res.data)
							this.pagenum++
						}
					}
				})
			},
			// 滚动到底部
			onScrollToLower() {
				if (this.total > this.wateringList.length) {
					this.getlist() // 上拉加载更多  
				} else {
			        
				}
			},
			// 跳转到收支详情
			btntxdeta(id,type) {
				uni.navigateTo({
					url:'/page_user/order_detail?id=' + id
				})
			},
			// 切换tab
			btntab(num) {
				this.activeindex = num
				if(num == 1){
					this.bstType = ''
					this.pagenum = 1
					this.wateringList = []
					this.getlist()
				}else if(num == 2) {
					this.bstType = 1
					this.pagenum = 1
					this.wateringList = []
					this.getlist()
				}else if(num == 3){
					this.bstType = 2
					this.pagenum = 1
					this.wateringList = []
					this.getlist()
				}
			},

		}
	}
</script>

<style lang="scss" scoped>
	/deep/ .u-title {
		padding-bottom: 15rpx;
	}

	/deep/ .u-icon__icon {
		padding-bottom: 15rpx;
	}

	.active {
		border-bottom: 6rpx solid #48893B;
	}

	.pages {
		height: 100vh;
		width: 100%;
		overflow: hidden;

		.pricemx {
			width: 658rpx;
			margin: auto;
			box-sizing: border-box;
			margin-top: 56rpx;

			.list {
				margin-top: 28rpx;
				width: 658rpx;
				// height: 900rpx;
				background-color: #fff;
				border-radius: 20rpx;
				// overflow: scroll;
				padding-bottom: 20rpx;
				box-sizing: border-box;
				padding-top: 8rpx;
				padding-left: 36rpx;
				padding-right: 36rpx;
				box-sizing: border-box;

				.list_item {
					border-bottom: 1px solid #D8D8D8;
					padding-bottom: 26rpx;
					box-sizing: border-box;
					margin-top: 20rpx;

					.top {
						display: flex;
						justify-content: space-between;
						font-size: 32rpx;
						color: #3D3D3D;
						font-weight: 600;
					}

					.yiy {
						display: flex;
						justify-content: space-between;
						margin-top: 10rpx;
						font-size: 28rpx;
						color: #3D3D3D;
					}
				}
			}

			.tit {
				font-size: 40rpx;
				color: #3D3D3D;
				font-weight: 600;
			}

			.tab {
				margin-top: 28rpx;
				display: flex;
				font-size: 32rpx;
				color: #3D3D3D;
				font-weight: 600;
				padding-left: 28rpx;
				box-sizing: border-box;

				view {
					margin-right: 60rpx;
					padding-bottom: 10rpx;
					box-sizing: border-box;
				}
			}
		}

		.yue {
			position: relative;
			width: 658rpx;
			height: 334rpx;
			margin: auto;
			margin-top: 30rpx;
			padding-top: 34rpx;
			padding-left: 38rpx;
			padding-right: 38rpx;
			box-sizing: border-box;

			.zhye {
				font-size: 32rpx;
				color: #FFFFFF;
			}

			.yuan {
				font-size: 66rpx;
				color: #FFFFFF;
				font-weight: 600;
				margin-top: 14rpx;
			}

			.leiji {
				font-size: 32rpx;
				color: #FFFFFF;
				margin-top: 56rpx;
				display: flex;
				justify-content: space-between;

				.one {
					font-size: 32rpx;
					color: #FFFFFF;
				}

				.two {
					width: 182rpx;
					height: 64rpx;
					background: #FFFFFF;
					border-radius: 35rpx 35rpx 35rpx 35rpx;
					font-size: 32rpx;
					color: #8883F0;
					text-align: center;
					line-height: 64rpx;
					border-radius: 30rpx;
				}
			}

			.bj {
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				z-index: -1;
			}
		}
	}
</style>