<template>
	<view class="container">
		<view class="list">
			<view class="listItem " v-for="(item,index) in list" :key="index">
				<view class="top">
					<view class="title">{{item.content}}</view>
					<view class="num" :class="{colorStyle: item.floatType=='add'}">{{item.floatType == 'add' ? '+' : ''}}{{item.floatPoints}}</view>
				</view>
				<view class="time">{{item.createTime}}</view>
			</view>
		</view>
		<image 
			v-if="list.length <= 0 "
			style="width: 402rpx;height: 442rpx;margin:240rpx auto 32rpx;" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/nomore.png"
			mode="aspectFill" 
			/>
		<u-loadmore :status="status" fontSize="28" color="#999" iconSize="28" style="margin-top: 32rpx;"/>
	</view>
</template>

<script>
	
	
	export default {
		data() {
			return {
				query: {
					page: 1,
					size: 10,
				},
				list: [],
				shopId: null,
				shopUserInfo: uni.cache.get('shopUserInfo'),
				status: "nomore" //  loadmore  nomore  loading
			};
		},
		onLoad(options) {
			if ( options.shopId ) {
				this.shopId = options.shopId;
			}
		},
		onShow() {
			this.getMemberPointsLogList()
		},
		onReachBottom() {
			this.getMemberPointsLogList()
		},
	
		methods: { 
			
			/**
			 * 获取积分明细列表
			 */
			async getMemberPointsLogList() {
				let res = await  this.api.memberPointsLogList({
					shopId: this.shopId,
					memberId: this.shopUserInfo.id,
					...this.query
				})
				if ( res.code == 0) {
					if (res.data.pages < this.query.page) {
						this.status = 'nomore'
						if (this.query.page == 1 && res.data.list.length == 0) {
							this.list = []
							this.is_end = true
						}
						return false;
					} else {
						this.status = 'loading';
						if (this.query.page == 1) {
							this.list = res.data.list
						} else {
							this.list = [...this.list, ...res.data.list];
						}
						this.query.page = ++this.query.page;
						if (this.query.page > res.data.pages) {
							this.status = 'nomore';
						} else {
							this.status = 'loading';
						}
					
					}
				}
				
			}
			
		}
	};
</script>

<style scoped lang="scss">
	.container{
		padding: 16rpx 0;
	}
	.list{
		background: #FFFFFF;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		.listItem{
			display: flex;
			flex-direction: column;
			padding: 32rpx 20rpx;
			border-bottom: 1rpx solid #E5E5E5;
			.top{
				display: flex;
				justify-content: space-between;
				align-items: center;
				font-weight: bold;
				color: #333333;
				.title{
					font-size: 28rpx;
				}
				.num{
					font-size: 32rpx;
				}
				.colorStyle {
					color: #FF7127;
				}
			}
			.time{
				font-weight: normal;
				font-size: 28rpx;
				color: #999999;
				margin-top: 16rpx;
			}
		}
		.listItem:last-child{
			border-bottom: none;
		}
		
	}
	
</style>