<template>
	<view>
		<view class="top ddflex">
			<view class="ke"><text>{{count.ktx}}</text>可提现</view>
			<view class="datas ddflex fflex">
				<view class="li"><text>总收益</text>{{count.profit}}</view>
				<view class="li"><text>已提现</text>{{count.ytx}}</view>
				<view class="li"><text>待结算</text>{{count.djs}}</view>
				<view class="li"><text>已消费</text>{{count.yxf}}</view>
			</view>
		</view>
		<view v-for="(item, index) in pageList" :key="index" class="pintuan">
			<view class="li">
				<view class="dflex item">
					<view class="pinimgs">
						<image src="/promote/static/promote/images/purchase.png" mode="aspectFit" class="pinimg"
							v-if="item.logType==3||item.logType==31">
						</image>
						<image src="/promote/static/promote/images/recharge.png" mode="aspectFit" class="pinimg"
							v-if="item.logType==6||item.logType==5||item.logType==32||item.logType==7||item.logType==8||item.logType==30">
						</image>
						<image src="/promote/static/promote/images/commission.png" mode="aspectFit" class="pinimg"
							v-if="item.logType==1"></image>
						<image src="/promote/static/promote/images/service.png" mode="aspectFit" class="pinimg"
							v-if="item.logType==2"></image>
					</view>
					<view class="pininfo ">
						<view class="proname">
							<!-- {{item.source==1?item.note:item.sourceStr}} -->
							<!-- <text>充值赠送-{{item.changeMoney}}</text> -->
							<text>{{item.logTypeName}} </text>
							<text class="orderId" v-if="item.orderId">NO：{{item.orderId}}</text>
						</view>
						<view class="operate">
							<view class="introduce">
								{{item.createDate}}
							</view>
						</view>
					</view>
					<view class="price">
						<view class="give" v-if="item.logType==5">赠送：{{item.giveMenoy}}</view>
						<view>
							<text v-if="item.logType!=5"
								:class="item.changeMoney>0?'prc':'prc1'">{{item.changeMoney>0?'+':''}}{{item.changeMoney}}</text>
							<text v-if="item.logType==5"
								:class="item.actuallyMenoy>0?'prc':'prc1'">{{item.actuallyMenoy>0?'+':''}}{{item.actuallyMenoy}}</text>
						</view>
						<view><text class="num">余额 {{item.currentMoney?item.currentMoney:'0'}}</text></view>
						<!-- <view class="btn file" >积分不足</view> -->
					</view>
				</view>
			</view>
		</view>
		<view class="nodata" v-if="ishow">
			<image :src="picUrlss+'empty_dd.png'"></image>
			<text>暂无明细</text>
		</view>
	</view>
</template>

<script>
	const route = require("../../../utils/route.js");
	const req = require("../../../utils/request");
	export default {
		data() {
			return {
				picUrlss: req.public.picUrls,
				searchTitle: '',
				isLoad: true,
				page: 1,
				pageList: "",
				ishow: false,
				count: {}
			};
		},
		onLoad: function(options) {
			this.getProfit();
		},

		onShow: function() {
			this.balanceLogs();
		},
		onReachBottom: function() {
			this.page++;
			this.balanceLogs();
		},
		methods: {
			getProfit(){
				req.getRequest('/api/rrLogs/profit',{},res=>{
					this.count = res;
				})
			},
			balanceLogs() {
				let that = this;
				let from = {
					smallType: 1,
					page: that.page,
					limit: 10
				};
				let isShowLoading = false;

				if (that.page == 1 && !isShowLoading) {
					console.log('一直在加载');
					req.loadIng('加载中');
					isShowLoading = true;
				}

				if (!that.isLoad) return false;
				that.isLoad = false;
				route.balanceLogs(from, res => {
					if (res && res.length >= 10) that.isLoad = true;
					if (that.page > 1) res = that.pageList.concat(res);
					console.log(res);
					res.map(it => {
						if (it.orderId) {
							it.orderId = it.orderId.substring(it.orderId.length - 6);
						}
						return it;
					});
					this.setData({
						pageList: res
					});

					if (this.pageList && this.pageList.length <= 0) {
						that.setData({
							ishow: true
						});
					} else {
						that.setData({
							ishow: false
						});
					}

					if (isShowLoading) {
						uni.hideLoading();
						isShowLoading = false;
					}
				});
			}

		}
	};
</script>

<style>
	@import "./income.css";
</style>
