<template>
	<view class="template-edit tn-safe-area-inset-bottom">
		<!-- 顶部自定义导航 -->
		<tn-nav-bar :isBack="false" backTitle="" :bottomShadow="false" backgroundColor="#FFFFFF">
			<view class="custom-nav tn-flex tn-flex-col-center tn-flex-row-left">
				<view style="padding-left: 15rpx;" @click="goBack()">
					<text class="tn-icon-left" style="font-size: 40rpx;"></text>
				</view>
				<view class="tn-margin-top"
					style=";text-shadow:  1rpx 0 0 #FFF, 0 1rpx 0 #FFF, -1rpx 0 0 #FFF , 0 -1rpx 0 #FFF;">
					<tn-tabs :list="[{name:'积分明细'}]" :current="topCurrent" activeColor="#000" :bold="false"
						:fontSize="36"></tn-tabs>
				</view>
			</view>
		</tn-nav-bar>
		<view class="tn-safe-area-inset-bottom" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
			<view class="tn-shadow tn-bg-white tn-margin">
				<view class="tn-text-center tn-color-blue" style="padding: 30rpx 0;">
					<text style="font-size: 110rpx;margin-left: -20rpx;">{{number}}</text>
					<text class="tn-text-lg tn-padding-left-xs" style="">积分</text>
				</view>
			</view>
		</view>
		<view class="tn-padding-bottom-lg">
			<view class="tn-flex tn-flex-row-between tn-strip-bottom-min tn-padding" v-for="(item,index) in integral"
				:key="index">
				<view class="justify-content-item">
					<view class="tn-color-gray--dark tn-text-lg">
						{{item.content}}
					</view>
					<view class="tn-color-gray tn-padding-top-xs">
						{{item.createtime}}
					</view>
				</view>
				<view class="justify-content-item tn-text-xl tn-padding-top">
					<view v-if="item.type==1" style="color: #28B93D;">+{{item.number}}</view>
					<view v-if="item.type==2" style="color: #E83A30;">-{{item.number}}</view>
				</view>
			</view>

		</view>
		<tn-toast ref="toast"></tn-toast>
	</view>
</template>

<script>
	import {
		integralIndex,

	} from "@/util/api";
	import store from "@/store";
	export default {
		data() {
			return {
				integral: [],
				page: 1,
				number: 0,
			}
		},
		onLoad() {
			this.getIntegralIndex();
		},
		onReachBottom() {
			this.page += 1;
			this.getIntegralIndex();
		},
		methods: {
			getIntegralIndex() {
				integralIndex({
						page: this.page
					})
					.then(res => {
						console.log(res);
						this.integral.push(...res.data.ret);
						this.number = res.data.number;
					})
					.catch(error => {
						uni.showToast({
							title: error,
							icon: 'none',
							duration: 2000
						});
					})
			},

			// 跳转
			tn(e) {
				uni.navigateTo({
					url: e,
				});
			},
			goBack() {
				if (getCurrentPages().length > 1) {
					uni.navigateBack()
				} else {
					uni.redirectTo({
						url: '/pages/index/index'
					})

				}
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>