shuishen
2022-02-26 c765784d2d2d4db55bfcb629cc3f6ec0b57dddcc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<template>
    <view>
        <view class="subTitle">
            考试信息
        </view>
        <view class="examContent">
            <view>考试名称:<text>{{examItem.name}}</text> </view>
            <view>考试总分:<text>{{examItem.examScore}}</text>分</view>
            <view v-if="examItem.examTime>0">考试时长:<text>{{examItem.examTime}}</text>分钟</view>
            <view v-else>考试时长:<text>不限时长</text></view>
        </view>
        <view class="subTitle">考试须知</view>
        <view class="tipsArea">
            <ul>
                <li>1、答题时要注意“剩余时间”提示,当剩余时间为0时,系统将自动交卷。</li>
                <li>2、答题完成后,点击“我要交卷”按钮进行交卷,否则考试无效。</li>
                <li>3、如果你准备好了,就点击“进入考场”吧,预祝取得好的成绩。</li>
            </ul>
        </view>
        <view class="btnArea">
            <!-- checkFace==1 不需要人脸识别,checkFace==2 需要人脸识别 -->
            <u-button v-if="needCheckFace==2 && !passFace " class="btnClass" type="primary" :ripple="true"
                shape="circle" @click="checkFace">开始人脸识别</u-button>
            <u-button v-if="needCheckFace==1 || passFace" class="btnClass" type="success" :ripple="true" shape="circle"
                @click="enterExam">进入考试</u-button>
            <u-button class="btnClass" type="error" :ripple="true" shape="circle" @click="exitExam">退出考试</u-button>
        </view>
        <u-toast ref="uToast" />
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                examItem: {},
                examNote: `
                1、答题时要注意“剩余时间”提示,当剩余时间为0时,系统将自动交卷。
                2、答题完成后,点击“我要交卷”按钮进行交卷,否则考试无效。
                3、如果你准备好了,就点击“进入考场”吧,预祝取得好的成绩。`,
                passFace: false,
 
            }
        },
        methods: {
            enterExam() {
                // 进入考试
                // uni.navigateTo({
                //     url: '/pages/exam/examTextPage'
                // })
 
                this.$u.route('/pages/exam/examTextPage', {
                    id: this.examItem.id,
                    examType: 'exam',
                })
 
            },
            exitExam() {
                // 退出考试
                uni.navigateBack({
                    delta: 1
                })
            },
            checkFace() {
                var that = this
                this.$api.uploadImg2('face')
                    .then(res => {
                        console.log('faceRes', res)
                        if (res.data.indexOf('操作成功') >= 0) {
                            this.passFace = true
                        }
                    })
            },
        },
        computed: {
            needCheckFace: function() {
                // checkFace==1 不需要人脸识别,checkFace==2 需要人脸识别
                // H5 平台不需要检测人脸
                // #ifdef  H5 
                return 1
                // #endif
 
                // #ifdef APP-PLUS || MP-WEIXIN
                return this.examItem.checkFace
                // #endif
            }
        },
        onLoad(options) {
            // 页面跳转 传递对象 传对象
            options = {
                id: '360198198812130014',
                name: '测试考试',
                examScore: 100,
                examTime: 90,
                checkFace: 1
            }
            this.examItem = options
            console.log("考试信息:", this.examItem);
 
        }
    }
</script>
 
<style lang="scss">
    page {
        font-size: 31rpx;
 
        ul li {
            list-style: none;
        }
    }
 
    .tipsArea {
        padding: 0 40rpx;
        margin-left: -30rpx;
    }
 
    .subTitle {
        font-size: $uni-font-size-title;
        font-weight: bold;
        color: #103289;
        text-align: center;
        margin: 40rpx auto 20rpx auto;
    }
 
    .examContent {
        line-height: 50rpx;
        margin-left: 180rpx;
 
        text {
            font-weight: bold;
        }
    }
 
    ol {
        // padding: 80rpx;
        // background-color: #0077AA;
        margin: 0 30rpx;
        line-height: 50rpx;
    }
 
    .btnArea {
        display: flex;
        margin-top: 50rpx;
 
        .btnClass {
            width: 300rpx;
        }
    }
</style>