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

  </view>
  <view class="noRes" v-show="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">
			<image src="../../../../static/color/bg_er@3x(4).png" mode="aspectFit" class="recordTou"></image>
  	    <view class="num">
		
  	    	<view class="rec">
				<view class="Nop1">
					{{item.nickname}}
				</view>
				<view class="Nop2">
					{{item.addTime}}
				</view>
  	    		
  	    	</view>
  	    </view>
  	</view>
  	<view class="time">
			 	{{item.mobile}}
  	</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{
				test:0,
			  promotionRecord:[],
			  qie:0,
			  level:1,
			  pageSize:3,
			totalElements:'',
			  levelCon:[
				  {
					  id:1,
					  text:'level1'
				  },
				  {
				  					  id:2,
				  					  text:'level2'
				  },
			  ],
				}
			},
		
		onLoad() {
			
	this.getBounsRecord();
			
		
	
		},
		onReachBottom() {
			this.pageSize += 3;
			if(this.pageSize>this.totalElements){
				return;
			}
			
			this.getBounsRecord()
			
		},
		methods:{
		qiehuan(i){
			this.qie=i;
			this.level=i+1;
			this.getBounsRecord();
		},
			getBounsRecord(){
				uni.request({
							url: '/start/api/summary/promotionRecords',
							data: {
							"ticket": uni.getStorageSync('logInfo').data,
							"level":this.level,
							"pageNumber": 1,
							"pageSize": this.pageSize,
							},
							header: {
								'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' //自定义请求头信息
							},
							method: 'POST', //请求方式  或GET，必须为大写
							success: (res) => {
								this.totalElements=res.data.data.totalElements;
				if(res.data.data.content){
					this.promotionRecord=res.data.data.content;
					for(var i=0;i<this.promotionRecord.length;i++){
						this.promotionRecord[i].addTime=index.formatyymmddhhmmss(this.promotionRecord[i].addTime);
					}
					this.test=this.promotionRecord.length;
					console.log(res.data)
				}else{
					console.log(123123)
				}	
							},
							fail: (res) => {
								console.log(res.data);
							}
						});
			}	
		},
	}
</script>

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