<template>
	<view>
		<view style="text-align: left; padding-bottom: 10rpx">
			<view v-for="(item, index) in list" :key="index" class="item">
				<view>
					<view style="color: #999999; font-size: 28upx">
						<view style="margin-bottom: 8upx">{{ item.title }}</view>
						<view style="margin-bottom: 8upx">{{ item.content }}</view>
						<view style="margin-bottom: 8upx" v-if="classify == 1 && item.orderNumber">订单号：{{ item.orderNumber }}</view>
						<view style="margin-bottom: 8upx">获取时间：{{ item.createTime }}</view>
						<!-- <view style="margin-bottom: 8upx" v-if="classify == 1">有效期：{{ item.expTime ? item.expTime : '无时间限制' }}</view> -->
						<view style="margin-bottom: 8upx; text-align: right">
							<text v-if="item.type == 1" style="color: #ecd4b4; font-size: 32upx; font-weight: 600">
								<text style="color: #000000">+</text>
								{{ item.num }}积分
							</text>
							<text v-if="item.type == 2" style="color: #ecd4b4; font-size: 32upx; font-weight: 600">
								<text style="color: #000000">-</text>
								{{ item.num }}积分
							</text>
						</view>
					</view>
				</view>
			</view>

			<empty v-if="list.length == 0" content="暂无数据"></empty>
		</view>
	</view>
</template>

<script>
import empty from '@/components/empty.vue'
export default {
	components: {
		empty
	},
	data() {
		return {
			list: [],
			page: 1,
			limit: 10,
			classify: '',
			totalCount: 0
		}
	},
	onLoad(option) {
		this.classify = option.classify
		if (this.classify == 2) {
			uni.setNavigationBarTitle({
				title: '兑换记录'
			})
		}
		this.$queue.showLoading('加载中...')
		this.getList()
	},
	methods: {
		getList() {
			let data = {
				page: this.page,
				limit: this.limit,
				classify: this.classify == 2 ? this.classify : ''
			}
			this.$Request.getT('/app/userintegraldetails/selectIntegraldetailsList', data).then((res) => {
				// console.log(res, '999')
				if (res.code === 0) {
					this.totalCount = res.data.totalCount
					if (this.page === 1) {
						this.list = res.data.list
					} else {
						this.list = [...this.list, ...res.data.list]
					}
				}
				uni.stopPullDownRefresh()
				uni.hideLoading()
			})
		}
	},
	onReachBottom: function () {
		// this.page = this.page + 1;
		// this.getList();
		if (this.list.length < this.totalCount) {
			this.page = this.page + 1
			this.getList()
		} else {
			uni.showToast({
				title: '已经到底了',
				icon: 'none'
			})
		}
	},
	onPullDownRefresh: function () {
		this.page = 1
		this.getList()
	}
}
</script>

<style lang="less">
page {
	// background: #1c1b20;
}

.tui-tab-item-title {
	// color: #ffffff;
	font-size: 30rpx;
	height: 80rpx;
	line-height: 80rpx;
	flex-wrap: nowrap;
	white-space: nowrap;
}

.tui-tab-item-title-active {
	border-bottom: 1px solid #5e81f9;
	color: #5e81f9;
	font-size: 32upx;
	font-weight: bold;
	border-bottom-width: 6upx;
	text-align: center;
}

.item {
	background: #ffffff;
	padding: 32rpx;
	margin: 32rpx;
	font-size: 28rpx;
	box-shadow: 7px 9px 34px rgba(0, 0, 0, 0.1);
	border-radius: 16upx;
}
</style>