cshenfu
2024-06-27 58aa6e282bb343503be3cb198948328ea3ed7b79
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
<template>
    <view class="flex-col page">
        <view class="flex-col group">
            <view class="flex-col section_1">
                <!-- #ifdef APP-PLUS -->
                <view class="status_bar">
                    <view class="top_view"></view>
                </view>
                <!-- #endif -->
                <view class="flex-col group_1">
                    <view class="flex-row group_2">
                        <text @click.stop="navigateTo('/pages/classification/index?from=bank', false)">
                            {{ cateName || '请选择分类' }}
                        </text>
                        <image src="/static/local/be16c30d7a4f4e3128756ccf42bfd428.png" class="image_1" />
                    </view>
                    <view class="flex-row equal-division">
                        <view class="flex-col equal-division-item">
                            <view class="text_4">
                                <u-count-to :start-val="0" :duration="1200" :end-val="rightVal"></u-count-to>
                                <text class="text_2">%</text>
                            </view>
                            <text class="text_5">综合正确率</text>
                        </view>
                        <view class="flex-col equal-division-item">
                            <u-count-to :start-val="0" :duration="1200" :end-val="todayNum" class="text_4"></u-count-to>
                            <text class="text_5">今日做题</text>
                        </view>
                        <view class="flex-col equal-division-item">
                            <u-count-to :start-val="0" :duration="1200" :end-val="totalNum" class="text_4"></u-count-to>
                            <text class="text_5">累计做题</text>
                        </view>
                    </view>
                </view>
            </view>
            <view class="flex-col group_4">
                <view class="grid">
                    <view class="grid-item flex-row" @tap="jumpPage('everyday')">
                        <view class="flex-col group_5">
                            <text class="text_8">每日一练</text>
                            <text class="text_10">每天练练,稳步提升</text>
                        </view>
                        <image src="/static/local/16403089502735192479.png" class="image_2" />
                    </view>
                    <view class="grid-item flex-row" @click="jumpPage('chapter')">
                        <view class="flex-col group_6">
                            <text class="text_8">章节练习</text>
                            <text class="text_10">针对训练,重点掌握</text>
                        </view>
                        <image src="/static/local/16403089825739296713.png" class="image_3" />
                    </view>
                    <!-- <view class="grid-item flex-row" @click="jumpPage('exam')">
                        <view class="flex-col group_7">
                            <text class="text_8">历年真题</text>
                            <text class="text_10">紧扣大纲,梳理考点</text>
                        </view>
                        <image src="/static/local/16403089825749858373.png" class="image_4" />
                    </view>
                    <view class="grid-item flex-row" @click="jumpPage('simulation')">
                        <view class="flex-col group_8">
                            <text class="text_8">模拟试题</text>
                            <text class="text_10">模拟试卷,试题精选</text>
                        </view>
                        <image src="/static/local/16403089825745633097.png" class="image_5" />
                    </view> -->
                </view>
                <!-- <view class="flex-row equal-division_1">
                    <view class="flex-col items-center equal-division-item_3" @tap="jumpToVip()">
                        <image src="/static/local/16403089825741983586.png" class="image_6" />
                        <text class="text_18">会员专享</text>
                    </view>
                    <view class="flex-col items-center equal-division-item_4" @tap="jumpToError()">
                        <image src="/static/local/16403089825754414817.png" class="image_7" />
                        <text class="text_19">错题集</text>
                    </view>
                    <view class="flex-col items-center equal-division-item_5" @tap="jumpToMyCollection()">
                        <image src="/static/local/879dc778630b12f70e93b25aee16735f.png" class="image_8" />
                        <text class="text_20">我的收藏</text>
                    </view>
                </view> -->
            </view>
        </view>
        <u-toast ref="uToast" />
    </view>
</template>
 
<script>
    var that; // 当前页面对象
    var vk; // vk依赖
    export default {
        data() {
            return {
                // 当前分类信息
                cateId: '',
                cateName: '',
                // 题目信息
                totalNum: 0,
                todayNum: 0,
                rightVal: 0
            }
        },
        // 监听 - 页面每次【加载时】执行(如:前进)
        onLoad(options = {}) {
            that = this;
            vk = that.vk;
            that.init(options)
        },
        // 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
        onReady() {},
        // 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
        onShow() {
            let bankCate = vk.getStorageSync('bank_cate')
            if (bankCate) {
                this.cateId = bankCate.id
                this.cateName = bankCate.name
            }
            
            that.totalNum = 0
            that.todayNum = 0
            that.rightVal = 0
            
            that.getInfo()
        },
        // 监听 - 页面每次【隐藏时】执行(如:返回)
        onHide() {},
        // 函数
        methods: {
            // 页面数据初始化函数
            init(options) {
                uni.$on('bankUpdate', function(data) {})
            },
            getInfo() {
                if (!uni.vk.callFunctionUtil.checkToken()) return
                let cateInfo = vk.getStorageSync('bank_cate');
 
                vk.callFunction({
                    url: 'client/quest-bank/kh/getMyInfo',
                    data: {
                        need_user_info: true,
                        cate_id: cateInfo ? cateInfo.id : null
                    },
                    success: function(res) {
                        that.totalNum = res.data.length
                        let right = 0
                        let { todayStart, todayEnd } = vk.pubfn.getCommonTime(new Date())
                        res.data.map(v => {
                            if (v.is_right == 1) right++
                            if (v._add_time > todayStart && v._add_time < todayEnd) that.todayNum++
                        })
                        if (that.totalNum == 0) return that.rightVal = 0
                        if (right == 0) return that.rightVal = 0
                        that.rightVal = Number((right / that.totalNum * 100).toFixed(0))
                    }
                })
            },
            // 检测是否存在分类
            jumpPage(url) {
                if (this.checkLogin()) return
                if (this.cateName == '') {
                    this.$refs.uToast.show({
                        title: '请选择分类',
                        type: 'warning',
                        duration: 1000
                    })
                    return
                }
                switch (url) {
                    case 'chapter':
                        uni.navigateTo({
                            url: `/pages/question-bank/chapter-test?cateName=${this.cateName}&cateId=${this.cateId}`
                        });
                        return
                    case 'simulation':
                        uni.navigateTo({
                            url: `/pages/question-bank/simulation?cateName=${this.cateName}&cateId=${this.cateId}`
                        });
                        return
                    case 'exam':
                        uni.navigateTo({
                            url: `/pages/question-bank/real-exam?cateName=${this.cateName}&cateId=${this.cateId}`
                        });
                        return
                    case 'everyday':
                        uni.navigateTo({
                            url: `/pages/question-bank/everyday-practice?cateName=${this.cateName}&cateId=${this.cateId}`
                        });
                        return
                }
            },
            // 跳转我的收藏
            jumpToMyCollection() {
                if (this.checkLogin()) return
                uni.navigateTo({
                    url: '/pages/question-bank/question-collection'
                });
            },
            // 跳转错题集
            jumpToError() {
                if (this.checkLogin()) return
                uni.navigateTo({
                    url: '/pages/question-bank/error-question'
                });
            },
            // 跳转会员专享
            jumpToVip() {
                if (this.checkLogin()) return
                uni.navigateTo({
                    url: `/pages/question-bank/vip?&cateId=${this.cateId}`
                });
            },
            // 验证登录
            checkLogin() {
                if (!uni.vk.callFunctionUtil.checkToken()) {
                    vk.toast('请先前往登录', 'none')
                    setTimeout(() => { vk.navigateTo('/pages/login/index/index') }, 600)
                    return true
                }
            }
        },
        onUnload() {
            uni.$off('bankUpdate')
        }
    }
</script>
<style lang="scss" scoped>
    .page {
        height: calc(100vh);
        /* #ifdef H5 */
        height: calc(100vh - 102rpx);
        /* #endif */
        background: #F5F5F5;
    }
 
    .group {
        flex: 1 1 auto;
        overflow-y: auto;
 
        .section_1 {
            padding-bottom: 142rpx;
            background-image: url('/static/local/16403089590017478445.png');
            background-position: 0px 0px;
            background-size: 100% 100%;
            background-repeat: no-repeat;
 
            .group_1 {
                margin-top: 24rpx;
                padding: 0 11rpx;
                height: 226rpx;
 
                .group_2 {
                    padding: 0 9rpx;
                    color: rgb(51, 51, 51);
                    font-size: 34rpx;
                    line-height: 41rpx;
                    white-space: nowrap;
 
                    .image_1 {
                        margin: 24rpx 0 0 6rpx;
                        width: 12rpx;
                        height: 12rpx;
                    }
                }
 
                .equal-division-item {
                    margin-top: 60rpx;
                    padding: 10rpx 21rpx;
                    flex: 1 1 242rpx;
                    justify-content: center;
 
                    .text_4 {
                        text-align: center;
                        color: rgb(51, 51, 51);
                        font-size: 46rpx;
                        white-space: nowrap;
                        font-weight: 600;
                        display: inline-block !important;
 
                        .text_2 {
                            font-size: 28rpx;
                            font-weight: 400;
                            margin-left: 6rpx;
                        }
                    }
 
                    .text_5 {
                        margin-top: 29rpx;
                        align-self: center;
                        color: rgb(51, 51, 51);
                        font-size: 24rpx;
                        line-height: 29rpx;
                        white-space: nowrap;
                    }
                }
            }
        }
    }
 
    .group_4 {
        margin-top: -88rpx;
        padding: 0 20rpx;
        position: relative;
 
        .grid {
            height: 348rpx;
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            grid-row-gap: 26rpx;
            grid-column-gap: 24rpx;
 
            .grid-item {
                padding: 40rpx 20rpx 38rpx;
                background-color: rgb(255, 255, 255);
                border-radius: 12rpx;
 
                .group_5 {
                    flex: 1 1 auto;
                }
 
                .image_2 {
                    margin-left: 19rpx;
                    margin-right: 3rpx;
                    align-self: center;
                    width: 61rpx;
                    height: 63rpx;
                }
 
                .group_6 {
                    flex: 1 1 auto;
                }
 
                .image_3 {
                    margin: 8rpx 0 10rpx 17rpx;
                    width: 64rpx;
                    height: 66rpx;
                }
 
                .group_7 {
                    flex: 1 1 auto;
                }
 
                .image_4 {
                    margin-left: 22rpx;
                    margin-right: 7rpx;
                    align-self: center;
                    width: 55rpx;
                    height: 64rpx;
                }
 
                .group_8 {
                    flex: 1 1 auto;
                }
 
                .image_5 {
                    margin-left: 18rpx;
                    margin-right: 3rpx;
                    align-self: center;
                    width: 62rpx;
                    height: 54rpx;
                }
 
                .text_8 {
                    color: rgb(51, 51, 51);
                    font-size: 30rpx;
                    line-height: 36rpx;
                    white-space: nowrap;
                }
 
                .text_10 {
                    margin-top: 20rpx;
                    color: rgb(153, 153, 153);
                    font-size: 24rpx;
                    line-height: 29rpx;
                    white-space: nowrap;
                }
            }
        }
 
        .equal-division_1 {
            margin-top: 24rpx;
            padding: 29rpx 0 26rpx;
            color: rgb(51, 51, 51);
            font-size: 28rpx;
            line-height: 34rpx;
            white-space: nowrap;
            background-color: rgb(255, 255, 255);
            border-radius: 12rpx;
 
            .equal-division-item_3 {
                padding: 14rpx 0 11rpx;
                flex: 1 1 237rpx;
 
                .image_6 {
                    width: 62rpx;
                    height: 51rpx;
                }
 
                .text_18 {
                    margin-top: 29rpx;
                }
            }
 
            .equal-division-item_4 {
                padding: 12rpx 0 11rpx;
                flex: 1 1 237rpx;
 
                .image_7 {
                    width: 55rpx;
                    height: 55rpx;
                }
 
                .text_19 {
                    margin-top: 27rpx;
                }
            }
 
            .equal-division-item_5 {
                padding: 9rpx 0 11rpx;
                flex: 1 1 237rpx;
 
                .image_8 {
                    width: 61rpx;
                    height: 61rpx;
                }
 
                .text_20 {
                    margin-top: 25rpx;
                }
            }
        }
    }
</style>