<template>
    <view class="courseWrapper">
        <view v-if="courseList.length">
            <view class="courseItem" v-for="course in courseList" :key="course.courseId">
                <view class="courseName">{{ course.courseName }}</view>
                <view class="courseTime">{{ course.courseTime }}</view>
                <view class="courseSource" @click="courseDialog">课程资料</view>
                <view class="signInfo" :style="{ background: course.status ? '#28D17C' : '#FBA02A' }">{{
                    course.status ? '已签到' : '未签到'
                }}</view>
            </view>
        </view>
        <view class="mycourseWrapper" v-else> 暂未配置课程 </view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            courseList: [],
        }
    },
    onLoad(options) {
        console.log('进入course')
        const classId = options.id
        const className = options.name
        console.log(options)
        uni.setNavigationBarTitle({ title: className })
        this.getCourseList(classId)
    },
    methods: {
        async getCourseList(classId) {
            this.http.quickGet(`/course/myCourse/class/${classId}`, true).then((res) => {
                console.log(res)
                this.courseList = res.data.rows
            })
        },
        courseDialog() {
			const url = 'https://www.bjkeyware.com'
            uni.showModal({
                title: '请去PC端下载资料',
                content: 'PC端网址:'+url,
                showCancel: false,
                confirmText: '复制网址',
                success: function (res) {
                    if (res.confirm) {
                        uni.setClipboardData({
                            data: url,
                            success: function () {
                                uni.showToast({
                                    title: '复制成功',
                                })
                            },
                            fail: function () {
                                uni.showToast({
                                    title: '复制失败',
                                })
                            },
                        })
                        console.log('用户点击确定')
                    }
                },
            })
        },
    },
}
</script>

<style scoped>
.courseWrapper {
}
.mycourseWrapper {
    text-align: center;
    line-height: 300rpx;
}
.courseItem {
    position: relative;
    margin: 25rpx;
    width: 700rpx;
    height: 210rpx;
    margin-bottom: 0;
    padding: 30rpx;
    background: #ffffff;
    border-radius: 10rpx;
    font-family: PingFang SC;
    font-weight: 500;
    font-size: 24rpx;
    line-height: 50rpx;
}
.courseName {
    /* width: 369rpx; */
    /* height: 29rpx; */
    font-weight: bold;
    font-size: 30rpx;
    color: #000000;
}
.courseTime {
    color: #4d4d4d;
}
.courseSource {
    color: #2853e4;
}
.signInfo {
    width: 110rpx;
    /* height: 40rpx; */
    line-height: 40rpx;
    border-radius: 20rpx;
    text-align: center;
    color: #fff;
    position: absolute;
    top: 85rpx;
    right: 25rpx;
}
</style>
