<template>
	<view class="consumptionbreakdown">
		<view class="consumptionbreakdown-header">
			<view class="consumptionbreakdown-header-text">
				<view class="consumptionbreakdown-header-text-neishi" @click="topgi">
					<view class="consumptionbreakdown-header-text-icon">
						<image src="https://cdn.bjtdba.com/vod/image/2022-08-11/20220811133828415.png" mode="widthFix">
						</image>
					</view>
				</view>

				<view class="consumptionbreakdown-header-text-title">
					消费分明细
				</view>
			</view>
		</view>
		<view class="hsuju">
			<view class="neiksd" v-for="(item,index) in list" :key="index">
				<view class="uisd">
					<view class="sfghj">
						<view class="ledt">
							<view class="" style="font-weight: 400;color: #333333;font-size: 30rpx;">
								{{item.mark}}
								<text style="color: #999999;font-size: 26rpx; margin-left:10rpx">
									({{item.status==0?"预估":
									item.status==1?"有效":
									item.status==2?"无效":"待释放"
									}})
								</text>
							</view>
							<view class="" v-if="item.pm==1"
								style="font-size: 30rpx;font-weight: normal;color: #FE0032;">
								+{{item.consumption_score}}
							</view>
							<view class="" v-else style="font-size: 30rpx;font-weight: normal;color: #333333;">
								-{{item.consumption_score}}
							</view>

						</view>
						<view class="ledtx">
							<view class="" style="font-weight: normal;color: #999999;font-size: 26rpx;">
								{{item.add_time}}
							</view>
							<view class="" style="font-weight: 400;color: #999999;font-size: 24rpx;">
								余额{{item.surplus}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="" v-if="tihsi==0" style="margin: 60rpx 0 30rpx 0; color: #999999; font-size: 26rpx;">
			—— 已经到最底部了哦 ——
		</view>
	</view>
</template>

<script>
	import {
		selectMerchantConsumption
	} from '@/commit/shop.js'
	export default {
		data() {
			return {
				page: 1,
				limit: 10,
				mer_id: '',
				list: '',
				is_panudn: true,
				tihsi: ''
			}
		},
		onLoad() {
			let selectmerchant = uni.getStorageSync('selectmerchant')
			this.mer_id = selectmerchant.merId
			this.selectMerchantConsumption()
		},
		onPullDownRefresh() {
			uni.showLoading({
				title: '加载中',
			});
			this.page = 1
			this.is_panudn = true
			this.list = []
			this.selectMerchantConsumption();
		},
		onReachBottom() {
			if (this.is_panudn == true) {
				this.page++;
				this.selectMerchantConsumption();
			} else {
				return
			}
		},
		methods: {
			selectMerchantConsumption() {
				uni.showLoading({
					title: '加载中',
				});
				selectMerchantConsumption({
					pageNum: this.page,
					pageSize: this.limit,
					mer_id: this.mer_id
				}).then(res => {
					uni.stopPullDownRefresh();
					if (res.data.status == 200) {
						this.tihsi = res.data.data.merchantConsumptionScoreLoglist.list.length
						if (res.data.data.merchantConsumptionScoreLoglist.list.length > 0) {
							if (this.page == 1) {
								this.list = res.data.data.merchantConsumptionScoreLoglist.list
							} else {
								this.list = this.list.concat(res.data.data.merchantConsumptionScoreLoglist.list)
							}
						} else {
							this.is_panudn = false
						}
						uni.hideLoading();
					}
				}, fail => {
					console.log(fail)
				})
			},
			topgi() {
				uni.redirectTo({
					url: 'consumption'
				});
			}
		}
	}
</script>

<style>
	page {
		background-color: #F7F8FC;
	}
</style>
<style lang="scss" scoped>
	.consumptionbreakdown {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;

		.consumptionbreakdown-header {
			position: fixed;
			top: 0;
			left: 0;
			z-index: 111;
			width: 100%;
			height: 176rpx;
			background: #FFFFFF;
			display: flex;
			justify-content: center;

			.consumptionbreakdown-header-text {
				width: 686rpx;
				font-size: 36rpx;
				font-weight: 500;
				color: #333333;
				display: flex;
				margin-top: 107rpx;
				align-items: center;

				.consumptionbreakdown-header-text-neishi {
					width: 45rpx;
					height: 45rpx;
					margin-right: 17rpx;

					.consumptionbreakdown-header-text-icon {
						width: 36rpx;
						height: 36rpx;
						margin-top: 2rpx;

						image {
							width: 100%;
							height: 100%;
						}
					}
				}
			}
		}

		.hsuju {
			width: 100%;
			height: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;
			margin-top: 202rpx;
			background-color: #FFFF;

			.neiksd {
				width: 686rpx;
				height: 100%;

				.uisd {
					width: 100%;
					height: 132rpx;
					border-bottom: 1rpx solid #E5E5E5;
					display: flex;
					align-items: center;

					.sfghj {
						width: 100%;
						height: 68rpx;
						display: flex;
						flex-direction: column;
						justify-content: space-between;

						.ledt {
							width: 100%;
							display: flex;
							justify-content: space-between;
						}

						.ledtx {
							width: 100%;
							display: flex;
							justify-content: space-between;
						}
					}
				}
			}

		}
	}
</style>
