<template>
	<view>
		<view class="ymf-jf flex align-center justify-between">
			<view class="ymf-jf-l">
				<view class="ymf-jf-l-t">
					当前积分
				</view>
				<view class="ymf-jf-l-b">
					{{num}}
				</view>
			</view>
			<view class="ymf-jf-r" @click="ymfgoNav('/me/jifen/duanju-jifen-duihuan')">
				积分兑换
			</view>
		</view>
		<!-- <view>
			<image src="@/me/static/ymf/1b3d78fa5f92af069751ea64d493c0d85050b1e03cc5b-tPC378.png" mode=""></image>
			<image src="@/me/static/ymf/390e926273eea85c894e613d42c9931ee2cd1f0a200fd-ApyNVV.png" mode=""></image>
			<image src="@/me/static/ymf/79cbb0e34c24915f1883feaa3cf3179b0a1ceb1362a18-unU6xQ.png" mode=""></image>
			<image src="@/me/static/ymf/cb319b604e49b816971b708b1231321318e0023610d8c-I24hXU.jpg" mode=""></image>
			<image src="@/me/static/ymf/cf2d172a6da494b2e577f699254a780907b7c222246d7-ehahn1.png" mode=""></image>
			<image src="@/me/static/ymf/eaae3095c9e433fb8a015aaebbe52047009dd863ff2b9-igSItK.png" mode=""></image>
			<image src="@/me/static/ymf/f3c60c6f31c74bdf38ba2d8993bcb443ab9bc335cc875-xfx4CJ.png" mode=""></image>
			<image src="@/me/static/ymf/c93b4cc9363d52cba140f7239516344ece9388141079a4-do8mFc.png" mode=""></image>
			<image src="@/me/static/ymf/031da1e7f043de5d5e1ee355994a93e5ec983aca44dc-sZf0Vl_fw1200.jpg" mode=""></image>
			<image src="@/me/static/ymf/c4e6c5023b94de32df2f51d9ebd633790cc6125a88e4-TIyAcR_fw1200.jpg" mode=""></image>
			<image src="@/me/static/ymf/f7da7a8ca57f9f0d56bbb3d7be1d1c86f96304ce4b3a-iVbD8U_fw1200.jpg" mode=""></image>
			<image src="@/me/static/ymf/2e521eee5a8c80ea6879028ee866c5d0531bc4f1d5e48-Bh95lN_fw1200.jpg" mode=""></image>
			<image src="@/me/static/ymf/38cf4e97e52b50be9dcdcdc1352c497e1acc9266cd52-aUOrxn_fw1200.webp" mode=""></image>
			<image src="@/me/static/ymf/73170e6a596b72538dbe743b06ef8b96e4885aff5b4c3-MsouS7_fw1200.jpg" mode=""></image>
			<image src="@/me/static/ymf/e9f9cb6b95c21c714015f15c372f595367aa553f443a-WpOCNo_fw1200.webp" mode=""></image>
			<image src="@/me/static/ymf/f5d96faaa94cb0151a5c95db44e27b80ed6eeac5cb32-rApi2S_fw1200.webp" mode=""></image>
			<image src="@/me/static/ymf/0e114b9ac6afc2b4c0f29520178be64915a111e218a8b5-mbMpg2_fw1200.jpg" mode=""></image>
			<image src="@/me/static/ymf/4783f7272bf31eeafbe1362605477de14b7cd3da24b0-ggkAnW_fw658webp.webp" mode=""></image>
			<image src="@/me/static/ymf/8dce1d3c3a8287c35bc1bf394048d57a64acfa047d4e-6wXnWE_fw658webp.webp" mode=""></image>
			<image src="@/me/static/ymf/ff919b6254e376cc902c89afdcc194ac2ab39c93793b-8TdL1Z_fw658webp.webp" mode=""></image>
			<image src="@/me/static/ymf/3c9a5848127a67f98e25176a042511b89afd31daccc2f-5EHbxD_fw658webp.webp" mode=""></image>
			<image src="@/me/static/ymf/6c9e57bcbcb047039a8edb30ecdd3b912bac99555a8fc-9EK0oO_fw658webp.webp" mode=""></image>
			<image src="@/me/static/ymf/78a020586cfbb791918b767520a8ff3c2ab9660f1ee1b-GX4zcc_fw658webp.webp" mode=""></image>
			<image src="@/me/static/ymf/babf535567728d84346fbb13348e94aae3ec8f82106e2-QKPJoe_fw658webp.webp" mode=""></image>
			<image src="@/me/static/ymf/d1e4d760358ba0733faee6bcad1e23cb4a1d6d76ba290-O3hUrf_fw240webp.webp" mode=""></image>
			<image src="@/me/static/ymf/dcb5a4b0b1060b569f9fc618e6e2708b584f7def1cadf-R7jpIr_fw658webp.webp" mode=""></image>
			<image src="@/me/static/ymf/e4330f184149f502f4948ce3b60059edaffc9c3d94ca4-B11p5c_fw658webp.webp" mode=""></image>
			<image src="@/me/static/ymf/fa22e2a27871e5f8841e8abb12cc4347a6b9440816068-3XsAnJ_fw658webp.webp" mode=""></image>
		</view> -->
		<view class="listTitle flex align-center">
			<u-icon name="order" color="#2e2f33" size="50"></u-icon>
			<text>
				积分明细
			</text>
		</view>
		<view class="list">
			<scroll-view :refresher-enabled="refresherTriggered"
				@scrolltoupper="ymfscrolltoupper" scroll-y="true"
				style="width: 100%;height: 100%;background-color: #ffffff;padding-bottom: 30rpx;">
				<view class="list-item flex align-center justify-center" v-for="(item,index) in list" :key="index">
					<view class="list-item-box flex align-center justify-between">
						<view class="list-item-box-l">
							<view class="list-item-box-l-t">
								{{item.content}}
							</view>
							<view class="list-item-box-l-b">
								{{item.createTime}}
							</view>
						</view>
						<view class="list-item-box-r" v-if="item.type == 1">
							+{{item.num}}
						</view>
						<view class="list-item-box-r" v-else>
							-{{item.num}}
						</view>
					</view>
				</view>
				<view class="" style="width: 100%;height: 30rpx;" v-if="list.length>0"></view>
				<u-loadmore v-if="list.length>0" :status="status" />
				<empty :isShow="true" title="暂无明细" v-if="list.length == 0" />
			</scroll-view>

		</view>

	</view>
</template>

<script>
	import empty from '../../components/empty.vue'
	export default {
		components: {
			empty
		},
		data() {
			return {
				boxStyle: {
					margin: 0,
					padding: '200rpx 0 0 0',
				},
				num: 0,
				list: [],
				status: 'loadmore',
				page: 1,
				limit: 10,
				pages: 1,
				refresherTriggered: true
			};
		},
		onShow() {
			this.ymfgetNum()
			this.ymfgetList()
		},
		onPullDownRefresh() {
			this.ymfgetNum()
		},
		methods: {
			ymfgoNav(url) {
				uni.navigateTo({
					url: url
				})
			},
			//上拉刷新
			ymfscrolltoupper() {
				this.page = 1
				this.refresherTriggered = true
				this.ymfgetList()
			},
			//加载更多
			ymfscrolltoupper() {
				if (this.page < this.pages) {
					this.status = 'loading'
					this.page += 1
					this.ymfgetList()
				} else {
					this.status = 'nomore'
				}

			},
			//获取积分明细
			ymfgetList() {
				let data = {
					page: this.page,
					limit: this.limit
				}
				this.$Request.getT('/app/integral/details', data).then(res => {
					setTimeout(() => {
						this.refresherTriggered = false
					}, 1500)
					if (res.code === 0) {
						this.pages = res.data.pages
						if (this.page < this.pages) {
							this.status = 'loadmore'
						} else {
							this.status = 'nomore'
						}
						if (this.page === 1) {
							this.list = res.data.records
						} else {
							this.list = [...this.list, ...res.data.records]
						}
					}
				})
			},
			//获取当前积分
			ymfgetNum() {
				this.$Request.getT('/app/integral/selectByUserId').then(res => {
					uni.stopPullDownRefresh()
					if (res.code === 0) {
						this.num = res.data.integralNum
					} else {
						this.num = 0
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}

	.ymf-jf {
		width: 100%;
		height: 252rpx;
		background: linear-gradient(90deg, rgba(255, 117, 129, 0.6) 0%, #ff7581 100%);
		padding: 0 40rpx;

		.ymf-jf-l-t {
			color: #ffffff;
			font-size: 28rpx;
		}

		.ymf-jf-l-b {
			font-size: 40rpx;
			color: #ffffff;
			font-weight: 600;
			margin-top: 30rpx;
		}

		.ymf-jf-r {
			padding: 20rpx 40rpx;
			border-radius: 40rpx;
			color: #ff7581;
			background-color: #ffffff;
			font-size: 28rpx;
			font-weight: 500;

		}
	}

	.listTitle {
		width: 100%;
		height: 110rpx;
		margin-top: -40rpx;
		background-color: #ffffff;
		border-radius: 30rpx 30rpx 0 0;
		border-bottom: 1px solid hsla(0, 0%, 90.2%, .8);
		padding-left: 20rpx;

		text {
			color: #2e2f33;
			font-size: 32rpx;
			font-weight: bold;
			margin-left: 20rpx;
			padding-top: 8rpx;

		}
	}

	.list {
		width: 100%;
		/* #ifdef H5 */
		height: calc(100vh - 252rpx - 70rpx - 88rpx);
		/* #endif */
		/* #ifndef H5 */
		height: calc(100vh - 252rpx - 70rpx);
		/* #endif */
		background-color: #ffffff;

		.list-item {
			width: 100%;
		}

		.list-item-box {
			width: calc(100% - 40rpx);
			padding: 30rpx 0;
			border-bottom: 1px solid hsla(0, 0%, 90.2%, .8);

			.list-item-box-l-t {
				color: #2e2f33;
				font-size: 28rpx;
			}

			.list-item-box-l-b {
				font-size: 24rpx;
				color: #aeb2c1;
				margin-top: 30rpx;
			}

			.list-item-box-r {
				color: #2e2f33;
				font-weight: 600;
				font-size: 36rpx;
			}
		}
	}
</style>