考试结果页面

develop
panliang 2024-04-23 20:29:34 +08:00
parent a09cb3df3d
commit c74ba3ca82
3 changed files with 126 additions and 0 deletions

View File

@ -192,6 +192,23 @@
}
}
]
},
{
"root": "pages/examination",
"pages": [
{
"path": "index",
"style": {
"navigationBarTitleText": "培训考试"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "培训考试"
}
}
]
}
],
"globalStyle": {

View File

@ -0,0 +1,68 @@
<template>
<view>
<view class="items-center justify-between">
<view>{{ index }}/{{ total }}</view>
<view>
<view v-if="index > 0" @click="prev"></view>
<view v-if="index < total" @click="next"></view>
<view v-if="index >= total" @click="submit"></view>
</view>
</view>
<view class="content">
<template v-for="(item, key) in list" :key="key">
<view v-show="key == index" class="item">
<view class="title">({{ item.cate_name }}){{ item.title }}</view>
<view class="options">
<u-checkbox-group v-if="item.cate == 1">
<u-checkbox v-for="(option, optionKey) in item.options" :key="optionKey" :label="option.text" :name="optionKey" />
</u-checkbox-group>
<u-radio-group v-if="item.cate == 2">
<u-radio v-for="(option, optionKey) in item.options" :key="optionKey" :label="option.text" :name="optionKey" />
</u-radio-group>
</view>
</view>
</template>
</view>
</view>
</template>
<script setup>
import { http } from '@/utils/request'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
const info = ref({})
//
const list = ref([])
//
const total = ref(0)
//
const index = ref(0)
//
const readonly = ref(true)
onLoad((options) => {
http.get(`/train/examinations/${options.id}`).then(res => {
if (res.finished_at) {
readonly = false
}
info.value = res
list.value = res.content
total.value = res.content.length
})
})
const next = () => {
if (index < total) {
index.value++
}
}
const prev = () => {
if (index > 0) {
index.value--
}
}
const submit = () => {
http.post(`/train/examinations/${info.id}/answer`).then(res => {
})
}
</script>

View File

@ -0,0 +1,41 @@
<template>
<view>
<CuNavbar title="培训考试"></CuNavbar>
<MescrollItem :top="88" :i="0" apiUrl="/train/examinations">
<template v-slot="{ list }">
<view class="space-y-15rpx p-base">
<template v-for="item in list" :key="item.id">
<view class="card-shadow bg-white rounded-19rpx p-base space-y-10rpx" @click="detail(item)">
<view class="text-30rpx">{{ item.name }}</view>
<view class="flex items-center justify-between">
<view class="text-30rpx">发布日期: {{ item.examination.published_at }}</view>
<view class="text-30rpx">{{ item.mark == null ? item.mark : '未完成' }}</view>
</view>
</view>
</template>
</view>
</template>
</MescrollItem>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { http } from '@/utils/index'
import CuNavbar from '@/components/cu-navbar/index'
import useMescrollMore from '@/uni_modules/mescroll-uni/hooks/useMescrollMore.js'
import MescrollItem from '@/components/mescroll-api/more.vue'
const mescrollItem = ref('')
const { getMescroll, scrollToLastY } = useMescrollMore(
mescrollItem,
onPageScroll,
onReachBottom
)
const detail = (item) => {
uni.navigateTo({
url: `/pages/examination/detail?id=${item.id}`,
})
}
</script>