<template>
    <view v-if="pageShow">
        <!-- 使用标题栏 -->
        <status-nav :statusBackw="true" :statusTitle="true" :title-val="titleName+'收益'" :tabcolor="'#ffffff'"></status-nav>
        <view :style="{paddingTop:statusHNH+'px'}">
            <view class="disba padding20 borbot" style="font-size: 30rpx;">
                <view>商品内容</view>
                <view>{{titleName}}收益</view>
            </view>
            <view v-if="dataArr.length!=0" class="disba padding20 borbot fon28" v-for="(item,index) in dataArr" :key="index">
                <view>
                    <view class="clips1">{{item.title}}</view>
                    <view class="fon24 color9 margin-s10">{{item.time}}</view>
                </view>
                <view class="colorf78">{{item.price}}</view>
            </view>
			<view v-if="dataArr.length==0" class="zanwu">暂无更多{{titleName}}收益记录</view>
        </view>
        <backTop :showTop="showTop" @backTop="backTop"></backTop>
    </view>
</template>

<script>
    import backTop from '@/components/backTop.vue';
    export default {
        components:{
            backTop
        },
        data() {
            return {
                dataArr:[],
                titleName:'',
                whereCome:'',
                showTop:false,
				page:1,
				size:50,
				statusHNH:uni.getStorageSync('statusHNH'),
				pageShow:false
            }
        },
        onLoad(options) {
            this.whereCome = options.index
            if(this.whereCome==0) {
				this.titleName = '直卖'
				this.checkZhiList()//查询直卖收益列表
			}
            if(this.whereCome==1) {
				this.titleName = '分红'
				this.checkFenList()//查询分红收益
			}
        },
		onShow() {
			this.$toolAll.tools.guoq()
		},
        onPageScroll(e) {
            e.scrollTop > 360 ? this.showTop = true : this.showTop = false
        },
        methods: {
			checkFenList(){//分红收益明细列表
				this.$requst.post('user/bonus-income-list',{page:this.page,size:this.size}).then(res=>{
					// console.log('分红收益记录：',res);
					if(res.code==0){
						this.pageShow = true
						if(res.data.list.length!=0){
							res.data.list.forEach(item=>{
								let fenObj = {
									title:item.income_text,
									time:item.created_at,
									price:item.income/100
								}
								this.dataArr.push(fenObj)
							})
						}
					}
				},error=>{})
			},
			checkZhiList(){
				this.$requst.post('user/sale-income-list',{page:this.page,size:this.size}).then(res=>{
					// console.log('直卖收益记录：',res);
					if(res.code==0){
						this.pageShow = true
						if(res.data.list.length!=0){
							res.data.list.forEach(item=>{
								let zhiObj = {
									title:item.income_text,
									time:item.created_at,
									price:item.income/100
								}
								this.dataArr.push(zhiObj)
							})
						}
					}
				},error=>{})
			},
            backTop(){
                uni.pageScrollTo({
                    scrollTop: 0,
                    duration: 300
                });
            },
        }
    }
</script>

<style>
page{background-color: #FFFFFF;}
</style>
