答题样式

main
king 1 year ago
parent 088ab69f32
commit c3b564fb77
  1. 4
      src/components/button/MyButton.tsx
  2. 3
      src/components/button/myButton.module.scss
  3. 2
      src/components/custom-page-container/custom-page-container.module.scss
  4. 19
      src/components/topic/judge.tsx
  5. 25
      src/components/topic/multi.tsx
  6. 16
      src/components/topic/shortAnswer.tsx
  7. 39
      src/components/topic/topic.scss
  8. 21
      src/pages/business/videoInfo/components/course.tsx
  9. 1
      src/static/css/module.scss

@ -6,6 +6,7 @@ import {ButtonProps} from "@tarojs/components/types/Button";
interface Props extends ButtonProps { interface Props extends ButtonProps {
fillet?: boolean fillet?: boolean
loading?: boolean loading?: boolean
width?: number
} }
const MyButton: FC<Props> = (props) => { const MyButton: FC<Props> = (props) => {
@ -24,6 +25,9 @@ const MyButton: FC<Props> = (props) => {
if (props.fillet) { if (props.fillet) {
style.borderRadius = '100px' style.borderRadius = '100px'
} }
if (props.width) {
style.width = props.width + "px"
}
return style return style
} }

@ -7,4 +7,7 @@
border: none !important; border: none !important;
outline: none !important; outline: none !important;
position: sticky; position: sticky;
margin: 0;
padding: 0;
box-sizing: border-box;
} }

@ -1,5 +1,6 @@
.customPageContainer { .customPageContainer {
position: fixed; position: fixed;
z-index: 99999;
top: 0; top: 0;
right: 0; right: 0;
left: 0; left: 0;
@ -24,4 +25,5 @@
position: absolute; position: absolute;
padding: 0 30px env(safe-area-inset-bottom); padding: 0 30px env(safe-area-inset-bottom);
box-sizing: border-box; box-sizing: border-box;
overflow: hidden;
} }

@ -1,6 +1,7 @@
import {FC, useEffect, useState} from "react"; import {FC, useEffect, useState} from "react";
import {Button, Radio, RadioGroup, Text, View} from "@tarojs/components"; import { Radio, RadioGroup, Text, View} from "@tarojs/components";
import './topic.scss' import './topic.scss'
import MyButton from "@/components/button/MyButton";
interface Props { interface Props {
data: ShareSubject data: ShareSubject
@ -35,17 +36,7 @@ const Judge: FC<Props> = ({data, onAnswer, onUpAndDown, index, validate, frequen
<View className='topic'> <View className='topic'>
<View className='mb-3'> <View className='mb-3'>
<Text style={{ <Text className='topicType'></Text>
display: 'inline-block',
verticalAlign: 'middle',
fontSize: '20rpx',
height: '34rpx',
background: '#45D4A8',
borderRadius: '8rpx',
color: '#fff',
padding: '0 2px',
marginRight: '8px'
}}></Text>
<Text>{data.question}</Text> <Text>{data.question}</Text>
</View> </View>
@ -68,8 +59,8 @@ const Judge: FC<Props> = ({data, onAnswer, onUpAndDown, index, validate, frequen
</RadioGroup> </RadioGroup>
{onUpAndDown && <View className='upAndDown'> {onUpAndDown && <View className='upAndDown'>
{index > 0 && <Button className='button' onClick={() => onUpAndDown(index - 1)}></Button>} {index > 0 && <MyButton size='mini' width={150} onClick={() => onUpAndDown(index - 1)}></MyButton>}
{!end && <Button className='button' onClick={() => onUpAndDown(index + 1)}></Button>} {!end && <MyButton size='mini' width={150} onClick={() => onUpAndDown(index + 1)}></MyButton>}
</View>} </View>}

@ -1,6 +1,7 @@
import {FC, useEffect, useState} from "react"; import {FC, useEffect, useState} from "react";
import {Button, Checkbox, CheckboxGroup, Radio, RadioGroup, Text, View} from "@tarojs/components"; import {Checkbox, CheckboxGroup, Radio, RadioGroup, Text, View} from "@tarojs/components";
import './topic.scss' import './topic.scss'
import MyButton from "@/components/button/MyButton";
interface Props { interface Props {
data: Multi data: Multi
@ -45,46 +46,38 @@ const Multi: FC<Props> = ({data, onAnswer, onUpAndDown, index, validate, frequen
return ( return (
<View className='topic'> <View className='topic'>
<View className='mb-3'> <View className='mb-3'>
<Text style={{ <Text className={'topicType'}>{data.type ? "多选题" : '单选题'}</Text>
display: 'inline-block',
verticalAlign: 'middle',
fontSize: '20rpx',
height: '34rpx',
background: '#45D4A8',
borderRadius: '8rpx',
color: '#fff',
padding: '0 2px',
marginRight: '8px'
}}>{data.type ? "多选题" : '单选题'}</Text>
<Text>{data.question}</Text> <Text>{data.question}</Text>
</View> </View>
<View> <View>
{data.type ? <CheckboxGroup onChange={onChange}> {data.type ? <CheckboxGroup onChange={onChange}>
{answers.map(d => <Checkbox {answers.map(d => <Checkbox
key={d.value}
value={d.value} value={d.value}
className='option' className='option'
disabled={validate} disabled={validate}
> >
{d.title} <Text className='title'>{d.value}{d.title}</Text>
</Checkbox>)} </Checkbox>)}
</CheckboxGroup> </CheckboxGroup>
: <RadioGroup onChange={onChange}> : <RadioGroup onChange={onChange}>
{answers.map(d => <Radio {answers.map(d => <Radio
key={d.value}
value={d.value} value={d.value}
className='option' className='option'
color={validate ? rightKey.includes(d.value) ? '#45d4a8' : 'red' : '#45d4a8'} color={validate ? rightKey.includes(d.value) ? '#45d4a8' : 'red' : '#45d4a8'}
disabled={validate ? !rightAnswer.includes(d.value) : false} disabled={validate ? !rightAnswer.includes(d.value) : false}
> >
{d.title} <Text className='title'>{d.value}{d.title}</Text>
</Radio>)} </Radio>)}
</RadioGroup> </RadioGroup>
} }
</View> </View>
{onUpAndDown && <View className='upAndDown'> {onUpAndDown && <View className='upAndDown'>
{index > 0 && <Button className='button' onClick={() => onUpAndDown?.(index - 1)}></Button>} {index > 0 && <MyButton size='mini' width={150} onClick={() => onUpAndDown?.(index - 1)}></MyButton>}
{!end && <Button onClick={() => onUpAndDown?.(index + 1)} className='button'>{end}</Button>} {!end && <MyButton size='mini' width={150} onClick={() => onUpAndDown?.(index + 1)}></MyButton>}
</View>} </View>}

@ -35,26 +35,18 @@ const ShortAnswer: FC<Props> = ({data, onAnswer, onUpAndDown, index, validate, f
return ( return (
<View className='topic'> <View className='topic'>
<View className='mb-3'> <View className='mb-3'>
<Text style={{ <Text className='topicType'></Text>
display: 'inline-block',
verticalAlign: 'middle',
fontSize: '20rpx',
height: '34rpx',
background: '#45D4A8',
borderRadius: '8rpx',
color: '#fff',
padding: '0 2px',
marginRight: '8px'
}}></Text>
<Text>{data.question}</Text> <Text>{data.question}</Text>
</View> </View>
<Textarea <Textarea
placeholder='请输入答案' placeholder='请输入答案'
adjustPosition adjustPosition
autoHeight
className='Textarea' className='Textarea'
onBlur={onBlur} onBlur={onBlur}
maxlength={255}
onInput={(e) => setValue((e.target as HTMLTextAreaElement).value)}/> onInput={(e) => setValue((e.target as HTMLTextAreaElement).value)}/>
<View>3</View> <View className='text-muted mt-2'>3</View>
{onUpAndDown && <View className='upAndDown'> {onUpAndDown && <View className='upAndDown'>
{index > 0 && <Button className='button' onClick={() => onUpAndDown?.(index - 1)}></Button>} {index > 0 && <Button className='button' onClick={() => onUpAndDown?.(index - 1)}></Button>}

@ -1,40 +1,45 @@
.topic { .topic {
padding: 40rpx; padding: 30rpx 0;
box-sizing: border-box; box-sizing: border-box;
background: #FFF; background: #FFF;
box-sizing: border-box;
.topicType {
display: inline-block;
background: #45D4A8;
border-radius: 5rpx;
color: #fff;
padding: 0 10rpx;
font-size: 30rpx;
margin-right: 20rpx;
}
.option { .option,
.weui-cells_checkbox {
display: block; display: block;
margin-bottom: 10px; margin-bottom: 10px;
line-height: 2; line-height: 2;
.title {
margin-left: 15rpx;
}
} }
} }
.statistics { .statistics {
border-top: 1px solid #F5F8F7; border-top: 1px solid #F5F8F7;
padding: 30px; padding: 30rpx 0;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
margin-bottom: env(safe-area-inset-bottom);
.button {
border-radius: 100px;
height: 76px;
width: 304rpx;
margin: 0;
}
} }
.upAndDown { .upAndDown {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
margin-top: 30px; position: absolute;
bottom: 20rpx;
button { width: 100%;
width: 40%;
border-radius: 100px;
}
} }

@ -1,4 +1,4 @@
import {Button, ScrollView, Swiper, SwiperItem, View} from "@tarojs/components"; import {ScrollView, Swiper, SwiperItem, View} from "@tarojs/components";
import {FC, useEffect, useState} from "react"; import {FC, useEffect, useState} from "react";
import HVideo from "@/components/video/video"; import HVideo from "@/components/video/video";
import {CurEndParam, curriculum, HourPlayData} from "@/api"; import {CurEndParam, curriculum, HourPlayData} from "@/api";
@ -9,6 +9,7 @@ import Judge from "@/components/topic/judge";
import ShortAnswer from "@/components/topic/shortAnswer"; import ShortAnswer from "@/components/topic/shortAnswer";
import unique_ident from "@/hooks/unique_ident"; import unique_ident from "@/hooks/unique_ident";
import CustomPageContainer from "@/components/custom-page-container/custom-page-container"; import CustomPageContainer from "@/components/custom-page-container/custom-page-container";
import MyButton from "@/components/button/MyButton";
interface Props { interface Props {
id: number, id: number,
@ -158,7 +159,7 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}: Props) => {
seek(time) seek(time)
init() init()
} else { } else {
Taro.showToast({title: '错误', icon: 'error'}) Taro.showToast({title: '答案错误', icon: 'error', duration: 3000})
} }
}, [newRecord]) }, [newRecord])
@ -187,14 +188,16 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}: Props) => {
onAfterLeave={again} onAfterLeave={again}
> >
<Swiper <Swiper
style={{height: "70vh"}} style={{height: "60vh"}}
snapToEdge snapToEdge
current={index} current={index}
onChange={(e) => { onChange={(e) => {
setIndex((e.target as any).current) if ((e.target as any)?.current) {
setIndex((e.target as any).current)
}
}}> }}>
{examAll?.[time]?.map((d, index) => {examAll?.[time]?.map((d, index) =>
<SwiperItem> <SwiperItem key={d.id}>
<ScrollView style='height:70vh' scrollY> <ScrollView style='height:70vh' scrollY>
{d.question_type === 1 && {d.question_type === 1 &&
<Multi <Multi
@ -231,12 +234,12 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}: Props) => {
)} )}
</Swiper> </Swiper>
<View className='statistics'> <View className='statistics'>
<View>{frequency}</View> <View>{frequency}</View>
<View>{index + 1}/{examAll?.[time]?.length}</View> <View>{index + 1}/{examAll?.[time]?.length}</View>
{!validate && <Button className='button' onClick={() => setValidate(true)}></Button>} {!validate && <MyButton width={150} fillet onClick={() => setValidate(true)}></MyButton>}
{frequency > 0 && validate && <Button className='button' onClick={onceMore}></Button>} {frequency > 0 && validate && <MyButton width={150} fillet onClick={onceMore}></MyButton>}
{frequency === 0 && validate && <Button className='button' onClick={again}></Button>} {frequency === 0 && validate && <MyButton width={150} fillet onClick={again}></MyButton>}
</View> </View>
</CustomPageContainer> </CustomPageContainer>
</View> </View>

@ -66,6 +66,7 @@ body {
padding: 10px; padding: 10px;
box-sizing: border-box; box-sizing: border-box;
border: 1px solid #ddd; border: 1px solid #ddd;
height: 200px;
} }
.button { .button {

Loading…
Cancel
Save