<template>
	<view class="page" :style="themeColor">
		<view class="flex align-stretch benben-position-layout flex balanceDetail_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex align-center justify-between flex-sub balanceDetail_fd0_0'>
				<view class='flex align-center balanceDetail_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
					data-url="1">
					<text class='fu-iconfont2  balanceDetail_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<view class='flex align-center'>
					<text class='balanceDetail_fd0_0_c1_c0'>余额明细</text>
				</view>
				<view class='flex align-center justify-end balanceDetail_fd0_0_c2'
					@tap.stop="popupShow1661324616108=true">
					<image class='balanceDetail_fd0_0_c2_c0' :src='STATIC_URL+"9.png"'
						@tap.stop="popupShow1661324616108=true"></image>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<!---flex布局flex布局开始-->
		<view class="flex benben-flex-layout flex-wrap align-center">
			<view>
				<benben-flex-tabs class-name='balanceDetail_benbenTabsfd1_0' v-model="tabs" ref="benben_tabsfd1_0"
					select-mark="benben_tabsfd1_0" key="benben_tabsfd1_0" :open-title-type='false' :open-sticky='true'
					:top='88' :is-show-content='false' :scrollspy='false' :tabs-info.sync="tabsInfofd1_0">

					<scroll-view @scroll="tabsInfofd1_0.scrollX = $event.detail.scrollLeft" id="benben_tabsfd1_0"
						class="benben-tabs" style="width:750rpx" :scroll-x="true"
						:scroll-left.sync="tabsInfofd1_0.moveX" scroll-with-animation="all .3s ease">
						<view class="benben-tabs-content" id="benben_tabsfd1_0-content">
							<view id="benben_tabsfd1_0-title" class="benben-tabs-title flex align-center flex ">
								<view
									:class="{ 'checkTitlefd1_0': tabs == '1', 'flex flex-wrap align-center balanceDetail_titlefd1_0_c3': true }"
									@tap="tabClick(1)" :id="`benben_tabsfd1_0-title-item-${'1'}`">

									<text>全部</text>

								</view>
								<view
									:class="{ 'checkTitlefd1_0': tabs == '2', 'flex flex-wrap align-center balanceDetail_titlefd1_0_c4': true }"
									@tap="tabClick(2)" :id="`benben_tabsfd1_0-title-item-${'2'}`">

									<text>收入记录</text>

								</view>
								<view :class="{ 'checkTitlefd1_0': tabs == '3', 'flex flex-wrap align-center': true }"
									@tap="tabClick(3)" :id="`benben_tabsfd1_0-title-item-${'3'}`">

									<text>支出记录</text>

								</view>
							</view>
							<view :style="{ left: tabsInfofd1_0.lineleft, maxWidth: tabsInfofd1_0.lineWidth }"
								id="benben_tabsfd1_0-line"
								class="benben-tabs-line flex benben-flex-tabs-line balanceDetail_linefd1_0"></view>
						</view>
					</scroll-view>

				</benben-flex-tabs>

			</view>
		</view>

		<!---flex布局flex布局结束-->
		<!---flex布局flex布局开始-->
		<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout balanceDetail_flex_2">
			<view class="text-333 choose-time" v-if="start_data">
				<view class="flex align-center padding justify-between">
					<text>{{start_data}} - {{end_data}}</text>
					<image @tap="clearTap" :src='STATIC_URL+"17.png"'></image>
				</view>
			</view>
			<view class='flex flex-direction flex-wrap align-stretch balanceDetail_fd2_0'>
				<view class='flex flex-wrap align-center justify-between balanceDetail_fd2_0_c0' v-for="(item, index) in lists" :key="index">
					<view class='flex flex-direction flex-wrap align-stretch flex-sub'>
						<text class='balanceDetail_fd2_0_c0_c0_c0'>{{ item.remark }}</text>
						<text class='balanceDetail_fd2_0_c0_c0_c1'>{{ item.create_time }}</text>
					</view>
					<view class='flex flex-wrap align-center balanceDetail_fd2_0_c0_c1' v-if="item.after_money > item.before_money">
						<text class='balanceDetail_fd2_0_c0_c1_c1'>+{{ item.change_money }}</text>
					</view>
					<view v-else class='flex flex-wrap align-center balanceDetail_fd2_0_c1_c1'>
						<text class='balanceDetail_fd2_0_c1_c1_c1'>-{{ item.change_money }}</text>
					</view>
				</view>
			</view>
		</view>

		<!---flex布局flex布局结束-->
		<benben-popup v-model="popupShow1661324616108" :mask="true" mode="center">
			<benben-calendar :query="benbenCalendar" @change="change" active-bg-color="#FA2233" range-bg-color="#f7d4d6"  :future="true" start-text="" end-text="" mode="range" :isDefaultDay="false" :start-time="start_data" :end-time="end_data">
			</benben-calendar>
		</benben-popup>
		
		<!-- 空布局 start -->
		<fu-empty-ui v-if="lists.length == 0 && isInit"></fu-empty-ui>
		<!-- 空布局 end -->
		<!-- 页面加载 start -->
		
		<!-- 页面加载 end -->
		<!-- 底部数据加载状态  start-->
		<uni-load-more v-if="lists.length > 8" :status="status"></uni-load-more>
		<!-- 底部数据加载状态  end-->

	</view>
</template>
<script>
	export default {
		components: {},


		data() {
			return {
				"popupShow1661324616108": false,
				"benbenCalendar": {
					'width': 686,
					'background': '#ffffff',
					'borderRadius': '24rpx 24rpx 24rpx 24rpx',
					'mode': 'range',
					'future': false,
					'changeTitle': true,
					'changeYear': true,
					'changeMonth': true,
					'yearArrowColor': '#666666',
					'monthArrowColor': '#999999',
					'startText': '',
					'endText': '',
					'activeBgColor': '#FA2233',
					'rangeBgColor': '#f7d4d6'
				},
				"tabsInfofd1_0": {
					lineleft: '',
					lineWidth: '',
					moveX: 0,
					scrollX: 0,
					PageScrollX: 0
				},
				"tabs": "1",
				"begin": "",
				"over": "",
				lists: [], //订单列表
				page: 1, //页码说
				size: 10, //一页显示几条数据
				status: 'more', //  加载状态  more:有更多数据  noMore:已加载全部数据  loading:数据加载中
				isInit: false, //是否已经初始化
				type: 0, //请求的订单类别
				isShow: false, //日历弹框
				start_data: '', //开始日期
				end_data: '' //结束日期
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		onShow() {
			this.page = 1;
			this.status = 'more';
			this.getOrderList(true);
		},
		onPullDownRefresh() {
		  this.page = 1;
		  this.status = 'more';
		  this.getOrderList(false);
		},
		onReachBottom() {
		  this.getOrderList();
		},
		methods: {
			tabClick(index) {
			  this.tabs = index;
			  uni.pageScrollTo({
			    scrollTop: 0,
			    duration: 0
			  });
			  this.refreshOrderList();
			},
			
			/**
			 * @description  显示日历
			 */
			showCalendar() {
			  this.isShow = true;
			},
			/**
			 * @description  隐藏日历
			 */
			closePopup() {
			  this.isShow = false;
			},
			
			/**
			 * @description  获取列表
			 * @param {Object} value  用来判断第页码初始化第一次 加载页面loading
			 */
			change(value) {
			  if (value.isInit) return;
			  this.start_data = value.start;
			  this.end_data = value.end;
			  this.page = 1;
			  this.status = 'more';
			  setTimeout(() =>{
			    this.popupShow1661324616108 = false;
			  },800)
			  this.getOrderList(true);
			},
			clearTap(){
				this.start_data ="";
				this.end_data ="";
				this.page = 1;
				this.status = 'more';
				setTimeout(() =>{
				  this.isShow = false;
				},800)
				this.getOrderList(true);
			},
			getOrderList(value) {
			  // this.isShow = false;
			  if (this.status != 'more') return;
			  this.status = 'loading';
			  let data = {
			    create_time: this.start_data,
			    end_time: this.end_data,
			    page: this.page,
			    list_rows: this.size,
				change_type:this.tabs
			  };
			  console.log('请求的数据', data);
			  if (this.page == 1 && value) {
			    this.isShowLoading = true;
			  }
			  this.$api
			    .post(global.apiUrls.getMoneyDetail, data)
			    .then(res => {
			      console.log('抵用券明细', res);
			      this.isShowLoading = false;
			      if (res.data.code == 1) {
			        var curPageData = res.data.data.data;
			        let total = res.data.data.total;
			        if (this.page == 1) this.lists = [];
			        this.lists = this.lists.concat(curPageData);
			        if (this.lists.length < total) {
			          this.status = 'more';
			          this.page++;
			        } else {
			          this.status = 'noMore';
			        }
			      } else {
			        this.$message.info(res.data.msg);
			      }
			      this.isInit = true;
			      uni.stopPullDownRefresh();
			    })
			    .catch(err => {
			      this.isShowLoading = false;
			      uni.stopPullDownRefresh();
			    });
			},
			
			/**
			 * @description  重置列表
			 * @param {Object} value 页面是否初始化
			 */
			refreshOrderList(value) {
			  this.page = 1;
			  this.status = 'more';
			  if (value) {
			    this.getOrderList(true);
			  } else {
			    this.getOrderList();
			  }
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto !important;
	}
	.choose-time{
		image{
			width: 32rpx;
			height: 32rpx;
		}
	}

	.balanceDetail_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.balanceDetail_fd0_0_c2_c0 {
		width: 36rpx;
		height: 36rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.balanceDetail_fd0_0_c2 {
		width: 180rpx;
	}

	.balanceDetail_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}

	.balanceDetail_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
	}

	.balanceDetail_fd0_0_c0 {
		width: 180rpx;
	}

	.balanceDetail_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.balanceDetail_titlefd1_0_c4 {
		margin: 0rpx 120rpx 0rpx 0rpx;
	}

	.balanceDetail_titlefd1_0_c3 {
		margin: 0rpx 140rpx 0rpx 107rpx;
	}

	.balanceDetail_linefd1_0 {
		background: rgba(255, 147, 0, 1);
		width: 40rpx;
		height: 6rpx;
		top: 82rpx;
		background-size: 100% auto !important;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
	}

	.checkTitlefd1_0 {
		font-weight: 700 !important;
		font-size: 28rpx !important;
		color: rgba(51, 51, 51, 1) !important;
		background-color: rgba(255, 255, 255, 1) !important;
	}

	::v-deep .balanceDetail_benbenTabsfd1_0 {
		background: #fff;
		width: 750rpx;
		height: 90rpx;
		white-space: nowrap;
		text-align: center;
		font-size: 28rpx;
		font-weight: 400;
		color: #999999;
	}

	.balanceDetail_flex_2 {
		background: transparent;
		background-size: 100% auto !important;
		padding: 24rpx 24rpx 0rpx 24rpx;
	}

	.balanceDetail_fd2_0_c1_c1_c1 {
		padding: 0rpx 5rpx 0rpx 0rpx;
		font-size: 32rpx;
		font-weight: 700;
		color: rgba(102, 102, 102, 1);
	}

	.balanceDetail_fd2_0_c1_c1_c0 {
		font-size: 32rpx;
		font-weight: 700;
		color: rgba(102, 102, 102, 1);
		margin: 0rpx 5rpx 0rpx 0rpx;
	}

	.balanceDetail_fd2_0_c1_c1 {
		color: rgba(250, 32, 51, 1);
		font-weight: 500;
		font-size: 32rpx;
	}

	.balanceDetail_fd2_0_c1_c0_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		margin: 16rpx 0rpx 0rpx 0rpx;
	}

	.balanceDetail_fd2_0_c1_c0_c0 {
		font-size: 28rpx;
		font-weight: 500;
		color: #333333;
		padding: 0rpx 24rpx 0rpx 0rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		line-height: 42rpx;
	}

	.balanceDetail_fd2_0_c1 {
		border-bottom: 1px solid #eee;
		padding: 24rpx 0rpx 24rpx 0rpx;
	}

	.balanceDetail_fd2_0_c0_c1_c1 {
		padding: 0rpx 5rpx 0rpx 0rpx;
		font-size: 32rpx;
		font-weight: 700;
		color: rgba(237, 64, 64, 1);
	}

	.balanceDetail_fd2_0_c0_c1_c0 {
		font-size: 32rpx;
		font-weight: 700;
		color: rgba(237, 64, 64, 1);
		margin: 0rpx 5rpx 0rpx 0rpx;
	}

	.balanceDetail_fd2_0_c0_c1 {
		color: rgba(250, 32, 51, 1);
		font-weight: 500;
		font-size: 32rpx;
	}

	.balanceDetail_fd2_0_c0_c0_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		margin: 16rpx 0rpx 0rpx 0rpx;
	}

	.balanceDetail_fd2_0_c0_c0_c0 {
		font-size: 28rpx;
		font-weight: 500;
		color: #333333;
		padding: 0rpx 24rpx 0rpx 0rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		line-height: 42rpx;
	}

	.balanceDetail_fd2_0_c0 {
		border-bottom: 1px solid #eee;
		padding: 24rpx 0rpx 24rpx 0rpx;
	}

	.balanceDetail_fd2_0 {
		background: rgba(255, 255, 255, 1);
		padding: 0rpx 24rpx 0rpx 24rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		background-size: 100% auto !important;
	}
</style>
