<template>
	<view >
		<myNav title="佣金明细"></myNav>
		<view class="padding">
			<view class="top grid col-1 padding align-center text-white">
				<view class="">
					<view class="">{{i18n.mine.share.total}}(USDT)</view>
					<view class="margin-top text-bold text-xl">{{usdt || 0}}</view>
					<!-- <view class="margin-top-sm">≈ {{usdt_cny || 0}} CNY</view> -->
				</view>
			</view>
		</view>
		
		<view class="flex justify-between align-center text-gray padding-lr text-xs font-30">
			<view class="flex-sub">
				{{i18n.mine.share.miaoshu}}
			</view>
			<view class="flex-sub text-center">
				{{i18n.mine.share.yongjin}}
			</view>
			<view class="flex-twice text-right">
				{{i18n.mine.share.time}}
			</view>
		</view>
		<view class="flex justify-between padding-lr padding-tb-xs align-center" v-for="(item,index) in list">
			<view class="flex-sub">
				{{item.description}}
			</view>
			<view class="flex-sub text-center">
				{{item.price}}
			</view>
			<view class="flex-twice text-right">
				{{item.createtime}}
			</view>
		</view>
		<p class="text-center margin-t-20 text-gray" v-if="list.length == 0">{{i18n.mine.share.no}}</p>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageNum:0,
				list:[],
				pages:"",
				data:"",
				usdt_cny:'',
				usdt:'',
			}
		},
		onShow:function(){
			this.reList()
			this.getInfo()
		},
		onReachBottom:function(){
			this.getList()
		},
		computed: {
			i18n() {
				return this.$t('message');
			},
		},
		methods: {
			//时间戳转换
			formatDate(date) {
				var date = new Date(date);
				var YY = date.getFullYear() + '-';
				var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
				var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
				var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ":";
				var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
				return YY + MM + DD + " " + hh + mm + ss;
				// return MM + DD + " " + hh + mm;
			},
			getInfo(){
				this.http('api/user/my_commission', {
					pageSize:20,
					pageNum:1,
				}).then(res => {
					if(res.code == 1){
						this.usdt = res.data.usdt
						this.usdt_cny = res.data.usdt_cny
					}
				})
			},
			reList(){
				this.pageNum = 0
				this.list = []
				this.pages = ""
				this.getList()
			},
			getList(){
				if(this.pages <= this.pageNum && this.pages!==""){
					return
				}
				this.http('api/user/my_commission', {
					pageSize:20,
					pageNum:this.pageNum+1,
				}).then(res => {
					if(res.code == 1){
						this.list = this.list.concat(res.data.data.data)
						this.pages = res.data.data.last_page
						if(res.data.data.data.length==0){
							console.log("??????????")
						}else{
							this.pageNum++
						}
					}
				})
			},
		}
	}
</script>

<style>
	page{
		background-color: #FFFFFF;
	}
	.top{
		background-size: 100% 100%;
		width: 100%;
		height: 250rpx;
	}
</style>
