- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡 - 药品百科: 搜索 + 分类筛选 + 20种药品静态数据 - 惠教中心: 4条药品使用指南课程 - 我的: 家庭成员信息管理 - 自定义TabBar + navigation-bar组件 - SVG药品分类插图
51 lines
2.0 KiB
Plaintext
51 lines
2.0 KiB
Plaintext
<!--components/my-quiz/my-quiz.wxml-->
|
|
<view class="quiz-container">
|
|
<block wx:for="{{renderQuestions}}" wx:key="id" wx:for-item="q" wx:for-index="qi">
|
|
<view class="question-card">
|
|
<view class="question-title">
|
|
<text class="tag">{{qi + 1}}.</text>
|
|
<text class="tag" wx:if="{{q.type == 2}}">[ 多选题 ]</text>
|
|
<text class="tag" wx:else>[ 单选题 ]</text>
|
|
{{q.question}}
|
|
</view>
|
|
<view class="options">
|
|
<!-- 单选题使用 radio-group -->
|
|
<radio-group
|
|
wx:if="{{q.type == 1}}"
|
|
bindchange="handleRadioChange"
|
|
data-question-id="{{q.id}}"
|
|
value="{{getSelectedAnswer(q.id, 0)}}"
|
|
>
|
|
<block wx:for="{{q.options}}" wx:key="key" wx:for-item="op" wx:if="{{op.value}}">
|
|
<label class="option-item {{isCorrect(q.id, op.key) ? 'correct' : isWrong(q.id, op.key) ? 'wrong' : ''}} {{getSelectedAnswer(q.id, 0) === op.key ? 'selected' : ''}}">
|
|
<radio
|
|
value="{{op.key}}"
|
|
checked="{{getSelectedAnswer(q.id, 0) === op.key}}"
|
|
/>
|
|
<text>{{op.key}}. {{op.value}}</text>
|
|
</label>
|
|
</block>
|
|
</radio-group>
|
|
|
|
<!-- 多选题使用 checkbox-group -->
|
|
<checkbox-group
|
|
wx:if="{{q.type == 2}}"
|
|
bindchange="handleCheckboxChange"
|
|
data-question-id="{{q.id}}"
|
|
value="{{selectedAnswers[q.id] || []}}"
|
|
>
|
|
<block wx:for="{{q.options}}" wx:key="key" wx:for-item="op" wx:if="{{op.value}}">
|
|
<label class="option-item {{isCorrect(q.id, op.key) ? 'correct' : isWrong(q.id, op.key) ? 'wrong' : ''}} {{isSelected(q.id, op.key) ? 'selected' : ''}}">
|
|
<checkbox
|
|
value="{{op.key}}"
|
|
checked="{{isSelected(q.id, op.key)}}"
|
|
/>
|
|
<text>{{op.key}}. {{op.value}}</text>
|
|
</label>
|
|
</block>
|
|
</checkbox-group>
|
|
</view>
|
|
</view>
|
|
</block>
|
|
</view>
|