<template>
	<view class="content" :class="test!=0?'he':''">
	   <navigation>
		  bonus record
	   </navigation>
  <view class="prore_body">
  	<view class="prore_lev">
  		<view class="level" v-for="(item,index) in levelCon" :key="item.id" @click="qiehuan(item.id,index)" :class="index==qie?'on':''">
  			{{item.text}}
  		</view>
  	</view>
	

  </view>
  <view class="noRes" v-if="test==0">
  	<view class="imgcon">
  		<image src="../../../../static/promo/menban@3x.png" mode="aspectFit"></image>
  	</view>
      <view class="res">
      	No results
      </view>
  </view>
  <view class="record_body">
  <view class="record_item flex" v-for="(item,index) in promotionRecord" :key="item.id">
  	<view class="numcon flex">
  	    <view class="num">
  	    	<view class="rec">
				<view class="Nop1">
						{{currencySymbol}}{{item.witAmount}}
				</view>
				<view class="Nop2">
					{{item.addTime}}
				</view>
  	    		
  	    	</view>
  	    </view>
  	</view>
  	<view class="time">
		<view class="money">
			{{currencySymbol}}{{item.amount}}
		</view>
		<view class="nickname">
			 	{{item.nickname}}
		</view>
  	  
  	</view>
  </view>
    </view>
	</view>
	
</template>

<script>
	import api from '@/utils/api'
	import utils from '@/utils'
	import cont from "@/components/navigation/navigation.vue"
	import index from '@/utils/index'
	export default{
		data(){
			return{
				currencySymbol:'',
				test:0,
			  promotionRecord:[],
			  qie:0,
			  level:1,
			  pageSize:10,
			totalElements:'',
			  levelCon:[
				  {
					  id:1,
					  text:'level1'
				  },
				  {
				  					  id:2,
				  					  text:'level2'
				  },
				  {
				  					  id:3,
				  					  text:'level3'
				  },
			  ],
				}
			},
		
		onLoad() {
		this.currencySymbol=uni.getStorageSync('siteInfo').currencySymbol;	
	this.getBounsRecord();
			
		
	
		},
		onReachBottom() {
			this.pageSize += 3;
			if(this.pageSize>this.totalElements){
				return;
			}
			
			this.getBounsRecord()
			
		},
		methods:{
		qiehuan(i,index){
			this.qie=index;
			this.level=i;
			this.getBounsRecord();
		},
			getBounsRecord(){
				
				this.promotionRecord=[];
	
			const post = api.bonusRecords({
				"ticket": uni.getStorageSync('logInfo').data,
				"level":this.level,
				"pageNumber": 1,
				"pageSize": this.pageSize,
					 })
					 post.then(res => {
		this.totalElements=res.data.totalElements;
		if(res.data.content){
			this.promotionRecord=res.data.content;
			for(var i=0;i<this.promotionRecord.length;i++){
				this.promotionRecord[i].addTime=index.formatyymmddhhmmss(this.promotionRecord[i].addTime);
		this.promotionRecord[i].witAmount=parseFloat(this.promotionRecord[i].witAmount).toFixed(2)
			this.promotionRecord[i].amount=parseFloat(this.promotionRecord[i].amount).toFixed(2)
			}
			this.test=this.promotionRecord.length;
			console.log(res.data)
		}else{
		
		}	
					 	})
					 	.catch(e => {
					 		uni.showToast({
					 			title: e,
					 			icon: 'none',
					 			duration: 2500
					 		})
					 	})
				
				
				
				
				
				
				
				

			}	
		},
	}
</script>

<style>
@import './index.css';
</style>
