assessment.vue 4.34 KB
<template>
    <view class="content">
        <u-navbar back-icon-color="#FFFFFF" :background="background" title-color="#fff" :border-bottom="false"></u-navbar>
        <view class="title">考试规则</view>
        <view class="test">
            <view class="slogan">
                这是一场严肃的考试,请认真查看 规则,预祝您顺利通过考试!
            </view>
            <view class="text">
                <text class="left">考试科目:</text><text style="color: #007aff">{{ title }}</text>
            </view>
            <view class="text">
                <text class="left">合格条件:</text><text>{{ score }}</text>
            </view>
            <view class="text">
                <text class="left">考试时间:</text><text>{{ time }}</text>
            </view>
            <view class="text">
                <text class="left">题目来源:</text><text>{{ ruleDisc }}</text>
            </view>
            <button @click="getUserExamId()">开始考试</button>
        </view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            title: "",
            score: "",
            time: "",
            ruleDisc: "",
            examId: null,
            exam: null,
            userExamId: null
        };
    },
    onLoad(param) {
		getApp().trackPage('学习开始考试页')
        this.examId = param.examId;
        // this.getUserExamInfo();
    },
    onShow() {
        this.getExamResult();
    },
    onUnload() {
        uni.switchTab({
            url: '/pages/index/learn'
        });
    },
    methods: {
        //申请考试获取userExamId
        getUserExamId: function () {
            let examId = this.examId;
            let userExamId = this.userExamId;
            let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
            let length = routes.length
            if(length > 8){
                uni.showToast({
                    icon: "none",
                    title: "打开页面过多,请返回后再操作",
                });
                return;
            }
            console.log(length);
            wx.navigateTo({
                url: "/pages/learn/answer?examId=" + examId + "&userExamId=" + userExamId,
            });
        },
        getExamResult() {
            let examId = this.examId;
            this.$u.api.getExamResult(examId)
            .then((res) => {
                uni.hideLoading();
                if (res.code == 200) {
                    if (res.data.ruleDisc) {
                        var str = res.data.ruleDisc;
                        this.userExamId = res.data.id;
                        
                        let strArr = str.split("(")[0].split(",");
                        this.title = strArr[0];
                        this.score = strArr[1];
                        this.time = strArr[2];
                        this.ruleDisc = strArr[3];
                    }
                }
            })
            .catch((err) => {
                uni.hideLoading();
                uni.showToast({
                    icon: "none",
                    title: "获取考试信息失败",
                });
            });
        },
    },
};
</script>

<style>
.content {
    width: 750rpx;
    height: 100vh;
    overflow: auto;
    background-color: #f4f5f7;
    background-image: linear-gradient(to top, #f4f5f7 0%, #2272ff 50%);
    background-size: 750rpx 600rpx;
    background-repeat: no-repeat;
}

.title {
    padding: 30rpx 30rpx 46rpx;
    line-height: 40rpx;
    font-size: 40rpx;
    color: #fff;
}

.test {
    margin: 0 30rpx;
    overflow: hidden;
    border-radius: 12rpx;
    padding-bottom: 60rpx;
    background-image: url(../../static/photo/examination.png);
    background-repeat: no-repeat;
    background-size: 66%;
    background-color: #fff;
    background-position: right bottom;
    min-height: 800rpx;
}
.slogan {
    font-size: 40rpx;
    font-weight: bold;
    color: #333333;
    line-height: 68rpx;
    padding: 50rpx 58rpx 46rpx 30rpx;
}

.left {
    margin-right: 8rpx;
    margin-left: 30rpx;
    color: #666666;
    font-size: 28rpx;
}

.text {
    margin: 30rpx 0;
}

button {
    width: 600rpx;
    height: 104rpx;
    background: #2272ff;
    font-size: 32rpx;
    font-weight: 600;
    color: #ffffff;
    margin-top: 237rpx;
    border-radius: 26px;
    line-height: 104rpx;
}
</style>