<template>
    <view class="visitor">
        <view class="visits-time">{{ accDateTime }}</view>
        <template>
            <visits-cell
                @handlerVisits="handlerVisits"
                :visits-info="visitsInfo"
                v-for="visitsInfo in visitsList"
                :key="visitsInfo.userID"
            />
        </template>
    </view>
</template>

<script>
import VisitsCell from '../components/visits-cell.vue'
export default {
    components: {
        VisitsCell
    },
    data() {
        return {
            visitsList: [],
            accDateTime: '',
            spId: ''
        }
    },
    async onLoad(options) {
        this.spId = options.spId
        const { data } = await this.SellerService.getVisitesClubList({
            spId: options.spId,
            accDateTime: options.accDateTime
        })
        this.visitsList = data
        this.accDateTime = data[0].accessDate
		console.log('options', options, 'visitsList', data)
    },
    onReachBottom() {
    },
    onPullDownRefresh() {
    	//下拉刷新
    	this.getVisitesClubList()
    	uni.stopPullDownRefresh()
    },
    methods: {
        handlerVisits($event) {
            this.$api.navigateTo(
                '/pages/seller/notice/service/visits_details?spId=' +
                    this.spId +
                    '&clubId=' +
                    $event.clubId +
                    '&accessTime=' +
                    $event.accessTime.substr(0, 10)
            )
        },
		async getVisitesClubList() {
			const { data } = await this.SellerService.getVisitesClubList({
			    spId: options.spId,
			    accDateTime: options.accDateTime
			})
			this.visitsList = data
			console.log('visitsList', this.visitsList)
		}
    }
}
</script>

<style lang="scss">
page {
    background-color: #f7f7f7;
}
.visitor {
    .visits-time {
        font-size: 32rpx;
        font-weight: bold;
        color: #333333;
        padding: 40rpx 0 24rpx 16rpx;
    }
}
</style>
