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
<template>
    <view class="page_bg">
        <view class="section_1" @tap="show = true">
            <text>{{cateName || '请选择分类'}}</text>
            <u-icon name="arrow-down-fill"></u-icon>
        </view>
        <z-paging ref="paging" class="z-paging" v-model="practiceList" @query="getListByChapter"
            :empty-view-fixed="false" :hide-loading-more-when-no-more-by-limit="5">
            <view class="group_item" v-for="item in practiceList" :key="item._id">
                <view class="title">{{item.title}}</view>
                <view class="number">共{{item.questions.length}}题</view>
                <view class="btns">
                    <block v-if="item.questions.length != item.history.length">
                        <view class="btn r_btn" @tap="starDoing(item)">开始做题</view>
                    </block>
                    <block v-else>
                        <view class="btn" @tap="checkAnswer(item)">查看解析</view>
                        <view class="btn r_btn" @tap="starDoing(item)">重新做题</view>
                    </block>
                </view>
            </view>
        </z-paging>
        <!-- 分类弹框 -->
        <u-popup v-model="show" mode="bottom" height="70%" :closeable="true">
            <view class="pop_bg">
                <view class="title">分类筛选</view>
                <view class="main">
                    <scroll-view scroll-y scroll-with-animation class="left_scroll">
                        <view v-for="(item,index) in treeDataF" :key="index" class="u-tab-item"
                            :class="index == leftSelect ? 'u-tab-item-active' : ''" @click="leftSelect = index">
                            <text class="u-line-1">{{item.name}}</text>
                        </view>
                    </scroll-view>
                    <block v-for="(item,index) in treeDataF" :key="index">
                        <scroll-view scroll-y class="right_scroll" v-if="leftSelect == index">
                            <view class="page-view">
                                <view class="thumb-box" v-for="son in item.children" :key="son.id" @tap="screen(son)">
                                    {{son.name}}
                                </view>
                            </view>
                        </scroll-view>
                    </block>
                </view>
            </view>
        </u-popup>
        <u-modal v-model="modalShow" content="当前题库没有更多题目..."></u-modal>
    </view>
</template>
 
<script>
    var that; // 当前页面对象
    var vk; // vk依赖
    export default {
        data() {
            // 页面数据变量
            return {
                cateName: '',
                cateId: '',
                treeDataF: [],
                practiceList: [],
 
                collHeadStyle: { padding: '28rpx 20rpx' },
                itemStyle: { borderBottom: '2rpx solid #f9f9f9' },
                show: false,
                leftSelect: 0, // 左侧分类选中项
                modalShow: false
            }
        },
        // 监听 - 页面每次【加载时】执行(如:前进)
        onLoad(options = {}) {
            that = this;
            vk = that.vk;
            that.init(options)
        },
        // 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
        onReady() {},
        // 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
        onShow() {},
        // 监听 - 页面每次【隐藏时】执行(如:返回)
        onHide() {},
        // 函数
        methods: {
            init(options) {
                that.cateId = options.cateId
                that.cateName = options.cateName
                that.getCategories()
            },
            // 请求分类数据
            getCategories() {
                vk.callFunction({
                    url: 'client/course/pub/categories',
                    success(data) {
                        let tree = vk.pubfn.arrayToTree(data.rows, {
                            id: "_id",
                            parent_id: "parent_id",
                            children: "children"
                        });
                        that.treeDataF = tree
                    }
                })
            },
            // 请求模拟试题数据
            getListByChapter(pageIndex, pageSize) {
                vk.callFunction({
                    url: 'client/quest-bank/kh/simulation/getSimulationList',
                    title: '请求中...',
                    data: {
                        cateId: that.cateId,
                        cateName: that.cateName,
                        need_user_info: true
                    },
                    success(data) {
                        if (data.msg == 'bank-no-questions') that.modalShow = true
                        that.$refs.paging.complete(data.rows)
                    }
                })
            },
            // 筛选完成
            screen(son) {
                this.show = false
                this.$nextTick(() => {
                    this.cateId = son._id
                    this.cateName = this.treeDataF[this.leftSelect].name + son.name
                    that.$refs.paging.reload();
                })
            },
            // 做题模式选择页面
            starDoing(item) {
                uni.navigateTo({
                    url: `/pages/question-bank/chooseExamType?from=simulation&id=${item._id}`
                });
            },
            // 练习模式解析开启
            checkAnswer(item) {
                uni.navigateTo({
                    url: `/pages/question-bank/practice-page?pageTitle=模拟试题&id=${item._id}&check=true`
                });
            }
        },
    }
</script>
 
<style lang="scss" scoped>
    .page_bg {
        height: 100vh;
        background-color: #F5F5F5;
        position: relative;
    }
 
    .section_1 {
        padding: 16rpx 20rpx 14rpx 21rpx;
        color: rgb(51, 51, 51);
        font-size: 28rpx;
        line-height: 34rpx;
        white-space: nowrap;
        background-color: rgb(253, 211, 3);
        box-shadow: 0px 3rpx 6rpx 0px rgba(255, 150, 12, 0.32);
        border-radius: 32rpx;
        position: absolute;
        top: 14rpx;
        left: 30rpx;
 
        .u-icon {
            margin-left: 6rpx;
        }
    }
 
    .z-paging {
        margin-top: 90rpx;
        background-color: #FFFFFF;
 
        .group_item {
            font-size: 24rpx;
            color: #333333;
            border-bottom: 2rpx solid #F0F0F0;
            padding: 32rpx 30rpx;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
 
            .title {
                width: 100%;
                margin-bottom: 32rpx;
                font-size: 28rpx;
                font-weight: bold;
            }
 
            .number {
                flex: 1;
                color: #999999;
            }
 
            .btns {
                display: flex;
                align-items: center;
 
                .btn {
                    padding: 9rpx 27rpx;
                    border-radius: 30rpx;
                    border: 1rpx solid #333333;
                    background: #FFFFFF;
                    margin-left: 12rpx;
                    font-size: 20rpx;
                }
 
                .r_btn {
                    background: #333333;
                    color: #FFFFFF;
                }
            }
        }
    }
 
    .pop_bg {
        padding: 30rpx;
        box-sizing: border-box;
        height: 100%;
 
        .title {
            text-align: center;
            font-size: 30rpx;
            font-weight: bold;
        }
 
        .main {
            height: calc(100% - 50rpx);
            margin-top: 10rpx;
            overflow: hidden;
            display: flex;
 
            .left_scroll {
                height: 100%;
                width: 30%;
 
                .u-tab-item {
                    height: 110rpx;
                    background: #f6f6f6;
                    box-sizing: border-box;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    font-size: 24rpx;
                    color: #444;
                    font-weight: 400;
                    line-height: 1;
                }
 
                .u-tab-item-active {
                    position: relative;
                    color: #000;
                    font-size: 26rpx;
                    font-weight: 600;
                    background-color: #FFFFFF;
                }
 
                .u-tab-item-active::before {
                    content: "";
                    position: absolute;
                    border-left: 4px solid #FF960C;
                    height: 32rpx;
                    left: 0;
                    top: 39rpx;
                }
            }
 
            .right_scroll {
                width: 70%;
                padding: 30rpx 0 0 20rpx;
 
                .page-view {
                    display: flex;
                    justify-content: space-between;
                    flex-wrap: wrap;
 
                    .thumb-box {
                        background: #F5F5F5;
                        border-radius: 6px;
                        width: 47%;
                        padding: 21rpx 0;
                        text-align: center;
                        margin-bottom: 30rpx;
                    }
                }
            }
        }
    }
</style>