ihzero 2024-04-23 23:19:52 +08:00
parent bef6694e80
commit b0d1127a6f
3 changed files with 80 additions and 62 deletions

View File

@ -1,23 +1,36 @@
<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>
<CuNavbar title="培训考试"></CuNavbar>
<uv-sticky bgColor="#fff">
<view class="flex items-center justify-between h-90rpx px-base">
<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>
</uv-sticky>
<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
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
v-for="(option, optionKey) in item.options"
:key="optionKey"
:label="option.text"
:name="optionKey"
/>
</u-radio-group>
</view>
</view>
@ -26,43 +39,43 @@
</view>
</template>
<script setup>
import { http } from '@/utils/request'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
import CuNavbar from '@/components/cu-navbar/index'
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 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 next = () => {
if (index < total) {
index.value++
}
const prev = () => {
if (index > 0) {
index.value--
}
}
const prev = () => {
if (index > 0) {
index.value--
}
}
const submit = () => {
http.post(`/train/examinations/${info.id}/answer`).then(res => {
})
}
</script>
const submit = () => {
http.post(`/train/examinations/${info.id}/answer`).then((res) => {})
}
</script>

View File

@ -5,11 +5,21 @@
<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
class="card-shadow space-y-10rpx bg-white rounded-19rpx p-base space-y-10rpx"
@click="detail(item)"
>
<view class="text-30rpx">{{ item.examination.name }}</view>
<view
class="flex items-center justify-between text-24rpx text-hex-999999"
>
<view class=""
>发布日期:
{{ timeFormat(item.examination.published_at) }}</view
>
<view class="">{{
item.mark != null ? item.mark : '未完成'
}}</view>
</view>
</view>
</template>
@ -20,22 +30,17 @@
</template>
<script setup>
import { ref } from 'vue'
import { http } from '@/utils/index'
import { http } from '@/utils/request'
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
)
import MescrollItem from '@/components/mescroll-api/one'
import { onPageScroll, onReachBottom, onLoad } from '@dcloudio/uni-app'
import useMescrollComp from '@/uni_modules/mescroll-uni/hooks/useMescrollComp.js'
import { timeFormat } from '@climblee/uv-ui/libs/function/index'
const { mescrollItem } = useMescrollComp(onPageScroll, onReachBottom)
const detail = (item) => {
uni.navigateTo({
url: `/pages/examination/detail?id=${item.id}`,
})
}
</script>
</script>

View File

@ -97,12 +97,12 @@ const opList = [
{
icon: "account",
title: "培训课件",
url: ""
url: "/pages/train-books/index"
},
{
icon: "twitte",
title: "培训考试",
url: ""
url: "/pages/examination/index"
}
]
}