<template>
	<!-- 账单明细 -->
	<view>
		<view class="bild">
			<view class="bildLeft">
				<text>我的余额</text>
				<view>{{info.amount}}</view>
			</view>
			<view class="bildRight">
				<text>我的积分</text>
				<view>{{info.accountPoints}}</view>
			</view>
		</view>
		<view class="navTop">
			<view @click="clickEvent(1)" :class="[active==1?'fonts':'']">
				余额明细
				<view :class="[active==1?'xian':'']" style="left: 36rpx;"> </view>
			</view>
			<view @click="clickEvent(2)" :class="[active==2?'fonts':'']">
				积分明细
				<view :class="[active==2?'xian':'']" style="left: 36rpx;"> </view>
			</view>
		</view>
		<view class="listStyle " v-for="(item,i) in list" :key="i">
			<!-- <image class="head_img" :src="item.head_img?item.head_img:'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/menber/head_default.png'" style="width: 76rpx;height: 76rpx;float: left;" mode=""></image> -->
			<view class="flex-start">
				<view class="listStyle_left">
					<view class="listrigth">
						<view>{{active == 1 ? item.biz_name : item.content}}</view>
						<view :class="{colorStyle: (active==1&&item.type == '+') || (active==2&&item.floatType=='add')}">
							{{ active == 1 ? item.type : (item.floatType == 'add'?'+':'')}}
							{{active == 1 ? item.amount : item.floatPoints}}
						</view>
					</view>
				</view>
				<view class="listrigth2">
					<view>{{$u.timeFormat(item.create_time, 'yyyy-mm-dd hh:MM:ss')}}</view>
					<view v-if="active == 1">余额:{{item.balance}}</view>
				</view>
			</view>
		
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				active: 1,
				list: [],
				form: {
					page: 1,
					pageSize: 10,
					memberId: null
				},
				info: null,
				shopId: null
			}
		},
		onLoad(e) {
			console.log(JSON.parse(e.shopUserInfo))
			this.info = JSON.parse(e.shopUserInfo)
			this.form.memberId = this.info.id;
			this.shopId = this.info.shopId;
			this.getlist()
		},
		onReachBottom() {
			this.getlist()
		},
		methods: {
			// 检测是否包含In
			checkIn(str) {
				let reg = RegExp(/In/)
				return str.match(reg)
			},
			async getlist() {
				if (this.active == 1) {
					let res = await this.api.queryMemberAccount({
						...this.form
					})
					if (res.code == 0 && res.data.list.length > 0) {
						this.list = this.list.concat(res.data.list)
						this.form.page++
					}
				} else {
					
					let res = await this.api.queryMemberPointsLog({
						shopId: this.shopId,
						...this.form
					})
					if (res.code == 0 && res.data.list.length > 0) {
						this.list = this.list.concat(res.data.list)
						this.form.page++
					}
				}
			},
			clickEvent(i) {
				this.active = i;
				this.form.page = 1;
				this.list = []
				this.getlist()
			}
		}
	}
</script>

<style scoped lang="less">
	.bild {
		height: 320rpx;
		background-image: url('https://czg-qr-order.oss-cn-beijing.aliyuncs.com/menber/billingDetails.png');
		background-size: 750rpx 320rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;

		.bildLeft,
		.bildRight {
			font-weight: 400;
			font-size: 32rpx;

			>view,
			>text {
				text-align: center;
				color: #333;
			}

			>view {
				margin-top: 34rpx;
				font-weight: bold;
			}
		}
	}

	.navTop {
		display: flex;
		justify-content: space-around;
		align-items: center;
		color: #333;
		margin-top: -60rpx;
		padding: 0 120rpx;
		font-size: 28rpx;
		.fonts {
			font-weight: bold;
			font-size: 32rpx;
		}

		>view {
			position: relative;

			.xian {
				width: 58rpx;
				height: 6rpx;
				background: #333;
				border-radius: 2rpx 2rpx 2rpx 2rpx;
				position: absolute;
				bottom: -16rpx;
			}
		}

	}

	.listStyle {
		padding: 28rpx;
		padding-top: 50rpx;
		width: 100%;

		.listrigth,
		.listrigth2 {
			width: 100%;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			// padding-left: 32rpx;
		}

		.listrigth {
			.colorStyle {
				color: #FF7127;
			}

			>view {
				font-weight: bold;
				font-size: 32rpx;
				color: #333333;
			}
		}
		.listStyle_left{
			width: 100%;
			display: flex;
			align-items: center;
		}
		.head_img{
			border-radius: 50%;
			margin-right: 32rpx;
		}
		.listrigth2 {
			margin-top: 16rpx;

			>view {
				font-weight: 500;
				font-size: 24rpx;
				color: #666666;
			}
		}
	}
</style>