<template>
    <view class="pageBg pad">
        <zeng-calen  :actDay="actDay" :chooseDayLack="chooseDayLack" @onDayClick='onDayClick' @changeMonth="changeMonth" :chooseDay="chooseDay"></zeng-calen>
		<view class="btnBg" style="margin: 20rpx 0;" @click="scanCodeClick">去签到/去签退</view>
		<view class="card" v-if="list.length">
			<view class="h1"><text class="active">签到记录</text></view>
			<view class="ul">
				<view class="li" v-for="(item,index) in list" :key="index">
					<view class="lab">{{ item.loginStatus==1? '签退成功':'签到成功'}}</view>
					<view class="date">{{item.signDate}}  <text style="margin-left: 10rpx;">{{ item.time }}</text></view>
				</view>
			</view>
		</view>
    </view>
</template>

<script>
	import zengCalen from '@/uni_modules/zeng-calen/components/zeng-calen/zeng-calen'
	import { scanCodeFn } from '@/config/utils.js'
	import { monthSignRecord, signDetail } from '@/config/api.js'
    export default {
		components: {zengCalen},
        data() {
            return {
                actDay: [], //用户选择的日期
                chooseDay: ["2024-01-29", "2024-01-27", "2024-01-19", "2024-01-10"], //已被投标的数据
                chooseDayLack: ["2024-01-29", ], //已被投标的数据
				list: [],
				signMonth: ''
            }
        },
        onLoad() {
			this.signMonth = this.$u.timeFormat(Date.now(), 'yyyy-mm')
			this.monthSignRecordFn()
        },
        methods: {
			// 按月查询签到天数
			async monthSignRecordFn() {
				const {data: res} = await monthSignRecord({signMonth: this.signMonth})
				this.chooseDay = res
				if(res&&res.length) {
					let day = res[res.length-1]
					this.actDay = [day]
					this.onDayClick(day)
				}
			},
			changeMonth(ym) {
				console.log(ym)
				this.signMonth = ym
				this.monthSignRecordFn(ym)
				this.list = []
			},
            // 展开日历
            async onDayClick(data) {
				this.actDay = [data]
				const {data: res} = await signDetail({signDate: data})
				this.list = res || []
				
            },
			// 扫码
			scanCodeClick() {
				scanCodeFn()
			}
        }
    }
</script>

<style lang="scss" scoped>
	.pageBg {
		padding-bottom: 30rpx;
	}
	.card {
		padding: 20rpx;
		.ul {
			.li {
				padding: 30rpx 0;
				border-bottom: 1px solid #f4f4f4;
				&:last-child {
					border: none;
				}
				.lab {
					font-size: 28rpx;
					color: #333;
				}
				.date {
					font-size: 24rpx;
					color: #999;
					margin-top: 16rpx;
				}
			}
		}
	}

</style>