<template>
	<view>
		<view class="d-b-c search-data border-b f26 mb20">
			<view class="flex-1 gray9">{{ $t('w_0352') }}</view>
			<picker mode="date" :value="form.startDate" :start="startDate" :end="endDate" @change="bindDateChange1">
				<view class="picker-item-data">{{ form.startDate || $t('CK_KS_3') }}</view>
			</picker>
			<view style="margin: 0 60rpx;">{{ $t('w_0139') }}</view>
			<picker mode="date" :value="form.endDate" :start="startDate" :end="endDate" @change="bindDateChange2">
				<view class="picker-item-data">{{ form.endDate || $t('CK_KS_9') }}</view>
			</picker>
			<view class="search-radio" @click="searchSubmit"><text class="icon iconfont icon-sousuo"></text></view>
		</view>
		<view class="">
			<view class="real-itembox">
				<!-- 首购收益 -->
				<view class="realTime-title">{{ $t('ENU_MENU_531') }}</view>
				<view class="reallist">
					<!-- 直推收益 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_131') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.directIncome || 0) }}</view>
					</view>
					<!-- 拓展收益 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_132') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.expandIncome || 0) }}</view>
					</view>
					<!-- 辅导收益 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_133') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.coachIncome || 0) }}</view>
					</view>
					<!-- 服务补贴 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_135') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.serviceIncome || 0) }}</view>
					</view>
					<!-- 重复消费 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_136') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.backPoints || 0) }}</view>
					</view>
					<!-- 平台服务费 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_137') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.serviceSpend || 0) }}</view>
					</view>
					<!-- 实发小计 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_138') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.purRealSubtotal || 0) }}</view>
					</view>
				</view>
			</view>
			<view class="real-itembox">
				<!-- 复购收益 -->
				<view class="realTime-title">{{ $t('ENU_MENU_532') }}</view>
				<view class="reallist">
					<!-- 复购直推收益 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('w_0154') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.repurPushIncome || 0) }}</view>
					</view>
					<!-- 复购级差收益 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('w_0155') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.repurRangeIncome || 0) }}</view>
					</view>
					<!-- 复购拓展收益 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_141') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.repurExpandIncome || 0) }}</view>
					</view>
					<!-- 平台服务费 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_137') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.repServiceSpend || 0) }}</view>
					</view>
					<!-- 实发小计 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_138') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.repurRealSubtotal || 0) }}</view>
					</view>
				</view>
			</view>
			<view class="real-itembox">
				<!-- 海粉收益 -->
				<view class="realTime-title">{{ $t('w_0140') }}</view>
				<view class="reallist">
					<!-- 海粉直推收益 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_142') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.haiFunIncome || 0) }}</view>
					</view>
					<!-- 实发小计 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_138') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.haiFunRealSubtotal || 0) }}</view>
					</view>
				</view>
			</view>
			<view class="real-itembox">
				<!-- 复购券收益 -->
				<view class="realTime-title">{{ $t('ENU_MENU_536') }}</view>
				<view class="reallist">
					<!-- 复购券直推收益 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_147') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.repurCoupon || 0) }}</view>
					</view>
					<!-- 实发小计 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_138') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.repurCouponSubtotal || 0) }}</view>
					</view>
				</view>
			</view>
			<view class="real-itembox">
				<!-- 创客空间收益 -->
				<view class="realTime-title">{{ $t('ENU_MENU_537') }}</view>
				<view class="reallist">
					<!-- 创客直推收益 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_148') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.makerDirectIncome || 0) }}</view>
					</view>
					<!-- 创客共享收益 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_149') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.makerShareIncome || 0) }}</view>
					</view>
					<!-- 平台服务费 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_137') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.makerServiceSpend || 0) }}</view>
					</view>
					<!-- 实发小计 -->
					<view class="reallist-item d-c d-c-c">
						<view class="realitem-title mb10 tc f26 gray6">{{ $t('N_I_138') }}({{ currencyIcon() }})</view>
						<view class="realitem-number f26 gray3">{{ formatNum(detail.makerRealSubtotal || 0) }}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		const currentDate = this.getDate({
			format: true
		});
		return {
			/*是否正在加载*/
			loading: true,
			listData: [],
			form: {
				endDate: '',
				startDate: ''
			},
			detail: {
				directIncome: '', //直推收益
				expandIncome: '', //拓展收益
				coachIncome: '', //辅导收益
				shareIncome: '', //分红收益
				serviceIncome: '', //服务补贴
				backPoints: '', //重复消费
				serviceSpend: '', //平台服务费
				repBackPoints: '', //复购重复消费
				repServiceSpend: '', //复购平台服务费
				purRealSubtotal: '', //首购实发小计
				repurPushIncome: '', //复购推荐收益
				repurRangeIncome: '', //复购极差收益
				repurExpandIncome: '', //复购拓展收益
				repurRealSubtotal: '', //复购实发小计
				cloudDirectIncome: '',
				cloudPurIncome: '',
				cloudRepurIncome: '',
				cloudRealSubtotal: '',
				repurCoupon: '', //复购券直推收益
				repurCouponShare: '',
				repurCouponSubtotal: '', //复购券小计
				couponServiceSpend: '',
				globalPoints: '',
				carAwardPoints: '',
				hiFunIncome: '', //嗨粉直推收益
				hiFunRealSubtotal: '', //嗨粉直推小计
				makerDirectIncome: '', //创客直推收益
				makerShareIncome: '', //创客共享收益
				makerRealSubtotal: '', //创客实发小计
				haiFunIncome: '', //海粉直推收益
				haiFunRealSubtotal: '', //海粉实发小计
				haiFunServiceSpend: '', //海粉平台服务费
				makerServiceSpend: '', //创客空间平台服务费
				realIncomeTotal: ''
			}
		};
	},
	computed: {
		startDate() {
			return this.getDate('start');
		},
		endDate() {
			return this.getDate('end');
		}
	},
	onShow() {
		/*获取数据*/
		this.getData();
	},
	methods: {
		getData() {
			let self = this;
			self.loading = true;
			var formdata = self.form;
			self._post(
				'bonus/api/bonus/query-current-bonus',
				formdata,
				function(res) {
					self.detail = res.rows[0] || {};
				},
				{},
				() => {
					self.loading = false;
				}
			);
		},
		getDate(type) {
			const date = new Date();
			let year = date.getFullYear();
			let month = date.getMonth() + 1;
			let day = date.getDate();

			if (type === 'start') {
				year = year - 60;
			} else if (type === 'end') {
				year = year + 2;
			}
			month = month > 9 ? month : '0' + month;
			day = day > 9 ? day : '0' + day;
			return `${year}-${month}-${day}`;
		},
		bindDateChange1: function(e) {
			this.form.startDate = e.detail.value;
		},
		bindDateChange2: function(e) {
			this.form.endDate = e.detail.value;
		},
		resetSubmit: function() {
			this.form.gradeId = '';
			this.form.startDate = '';
			this.form.endDate = '';
		},
		searchSubmit: function() {
			/*获取数据*/
			this.listData = [];
			this.form.pageNum = 1;
			this.getData();
		}
	}
};
</script>

<style lang="scss">
.tips-box {
	padding: 30rpx 20rpx;
	background-color: #fff;
	border-bottom: 1rpx solid #eee;
}

.bonus-item {
	padding: 20rpx 25rpx 20rpx 23rpx;
	background-color: #fff;
	margin-bottom: 20rpx;

	.bonus-bottom {
		height: 104rpx;

		.order-btn {
			box-sizing: border-box;
			padding: 0 26rpx;
			min-width: 146rpx;
			height: 52rpx;
			line-height: 52rpx;
			text-align: center;
			border-radius: 26rpx;
			font-size: 24rpx;
			color: #fff;
			border: 1rpx solid #eee;
			margin-left: 18rpx;
			background: #fb3024;
			border: 1rpx solid #fb3024;
			flex-shrink: 0;
			display: flex;
			justify-content: center;
			align-items: center;
		}
	}
}

.bonus-item-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20rpx;
}
.real-itembox {
	padding: 0 24rpx 0 24rpx;
	background: #ffffff;
	margin-bottom: 23rpx;
	.realTime-title {
		height: 90rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #333;
		font-size: 32rpx;
		font-weight: bold;
		border-bottom: 1px solid #eee;
	}
	.reallist {
		padding: 24rpx 0 0 0;
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		flex-wrap: wrap;
		.reallist-item {
			padding: 20rpx;
			width: 342rpx;
			min-height: 136rpx;
			background: #ffffff;
			border: 1px solid #eeeeee;
			border-radius: 20rpx;
			box-sizing: border-box;
			margin-bottom: 25rpx;
		}
	}
}
</style>
