parent
bfbf611931
commit
eeed36b787
@ -1,2 +1,3 @@ |
||||
#TARO_APP_API=http://192.168.1.19:9898 |
||||
TARO_APP_API=https://yjx.dev.yaojiankang.top |
||||
#TARO_APP_API=https://playedu.yaojiankang.top |
||||
|
@ -0,0 +1,25 @@ |
||||
.topic { |
||||
padding: 40rpx; |
||||
box-sizing: border-box; |
||||
|
||||
.option { |
||||
display: block; |
||||
margin-bottom: 10px; |
||||
} |
||||
} |
||||
|
||||
.statistics { |
||||
padding: 40px 20px; |
||||
display: flex; |
||||
justify-content: space-around; |
||||
} |
||||
|
||||
.upAndDown { |
||||
display: flex; |
||||
justify-content: space-around; |
||||
margin-top: 30px; |
||||
|
||||
button { |
||||
width: 40%; |
||||
} |
||||
} |
@ -1,3 +0,0 @@ |
||||
export default definePageConfig({ |
||||
navigationBarTitleText: '更多课程' |
||||
}) |
@ -1,50 +0,0 @@ |
||||
import {View} from "@tarojs/components"; |
||||
import {Profile} from '@/store' |
||||
import {FC, useEffect, useState} from "react"; |
||||
import {getCurrentInstance} from "@tarojs/runtime"; |
||||
import {curriculum} from "@/api"; |
||||
import VideoCover from "@/components/videoCover/videoCover"; |
||||
|
||||
const Index: FC = () => { |
||||
const {company} = Profile.useContainer() |
||||
const {categoryId,type} = getCurrentInstance()?.router?.params as { categoryId: number,type:string } |
||||
const [data, setData] = useState<Curriculum[]>([]) |
||||
|
||||
async function getData() { |
||||
try { |
||||
const res = await curriculum.categoryCur(categoryId!, company?.id!,type) |
||||
setData(res) |
||||
} catch (e) { |
||||
} |
||||
} |
||||
|
||||
|
||||
useEffect(() => { |
||||
getData() |
||||
}, []) |
||||
return ( |
||||
<> |
||||
<View className='flex flex-wrap px-1'> |
||||
{data.map(d => <VideoCover |
||||
thumb={d.thumb} |
||||
title={d.title} |
||||
id={d.id} |
||||
depId={d.id} |
||||
/>) |
||||
} |
||||
</View> |
||||
<View className='text-center text-muted'>- 暂无更多 -</View> |
||||
</> |
||||
) |
||||
} |
||||
|
||||
|
||||
const CategoryCur = () => { |
||||
return ( |
||||
<Profile.Provider> |
||||
<Index/> |
||||
</Profile.Provider> |
||||
) |
||||
} |
||||
|
||||
export default CategoryCur |
@ -0,0 +1,3 @@ |
||||
export default definePageConfig({ |
||||
navigationBarTitleText: '考卷' |
||||
}) |
@ -0,0 +1,116 @@ |
||||
import {Button, View} from "@tarojs/components"; |
||||
import {getCurrentInstance} from "@tarojs/runtime"; |
||||
import {curriculum} from "@/api"; |
||||
import {FC, useEffect, useState} from "react"; |
||||
import ShortAnswer from "@/components/topic/shortAnswer"; |
||||
import Judge from "@/components/topic/judge"; |
||||
import Multi from "@/components/topic/multi"; |
||||
import {Profile} from '@/store' |
||||
import Taro from "@tarojs/taro"; |
||||
|
||||
const record: boolean[] = [] |
||||
const Test = () => { |
||||
const {testId} = getCurrentInstance()?.router?.params as { testId: string } |
||||
const [validate, setValidate] = useState(false) |
||||
const [answers, setAnswers] = useState<boolean[]>([]) |
||||
const [data, setData] = useState<Record<string, Multi[]> | null>(null) |
||||
const [hourId, setHourId] = useState<number>(0) |
||||
const {user} = Profile.useContainer() |
||||
|
||||
async function getData() { |
||||
const res = await curriculum.getText(testId) |
||||
setHourId((res.hour_test as any).hour_id) |
||||
setData(res) |
||||
} |
||||
|
||||
function init() { |
||||
record.splice(0, record.length) |
||||
setValidate(false) |
||||
setAnswers([]) |
||||
} |
||||
|
||||
function onAnswer(answer: boolean) { |
||||
record.push(answer) |
||||
setAnswers(record) |
||||
} |
||||
|
||||
useEffect(() => { |
||||
if (answers.length) { |
||||
|
||||
const isPass = answers.every(d => d) |
||||
curriculum.recordText(hourId, { |
||||
is_pass: isPass, |
||||
test_id: Number(testId), |
||||
test_info: answers.join(','), |
||||
user_id: user?.id!, |
||||
test_score: 0 |
||||
}).then() |
||||
curriculum.putRecordText(hourId,isPass).then() |
||||
if (isPass) { |
||||
Taro.showModal({ |
||||
title: '考卷已完成', |
||||
showCancel: false, |
||||
success() { |
||||
Taro.navigateBack() |
||||
} |
||||
}) |
||||
} else { |
||||
Taro.showModal({ |
||||
title: '未及格,请再次作答', |
||||
showCancel: false, |
||||
content: '加油!', |
||||
success() { |
||||
init() |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
}, [answers]) |
||||
|
||||
function onSubmit() { |
||||
setValidate(true) |
||||
} |
||||
|
||||
useEffect(() => { |
||||
getData() |
||||
}, []) |
||||
|
||||
|
||||
return ( |
||||
<View> |
||||
{data?.fill.map((d, index) => <ShortAnswer |
||||
data={d} |
||||
index={index} |
||||
onAnswer={onAnswer} |
||||
validate={validate} |
||||
/>)} |
||||
|
||||
{data?.judge.map((d, index) => <Judge |
||||
data={d} |
||||
index={index} |
||||
onAnswer={onAnswer} |
||||
validate={validate} |
||||
/>)} |
||||
|
||||
{ |
||||
data?.multi.map((d, index) => <Multi |
||||
data={d} |
||||
onAnswer={onAnswer} |
||||
index={index} |
||||
validate={validate}/>) |
||||
} |
||||
|
||||
<Button className='button' onClick={onSubmit}>交卷</Button> |
||||
</View> |
||||
) |
||||
} |
||||
|
||||
const TestProfile: FC = () => { |
||||
return ( |
||||
<Profile.Provider> |
||||
<Test/> |
||||
</Profile.Provider> |
||||
) |
||||
} |
||||
|
||||
export default TestProfile |
@ -1,3 +0,0 @@ |
||||
export default definePageConfig({ |
||||
navigationBarTitleText: '课程管理', |
||||
}) |
@ -1,10 +0,0 @@ |
||||
import {FC} from "react"; |
||||
import {View} from "@tarojs/components"; |
||||
|
||||
const CurAdmin: FC = () => { |
||||
return ( |
||||
<View>sd</View> |
||||
) |
||||
} |
||||
|
||||
export default CurAdmin |
@ -1,48 +0,0 @@ |
||||
.user { |
||||
.header { |
||||
border-bottom: 1px solid #ddd; |
||||
|
||||
.lock { |
||||
padding: 4px 20px; |
||||
border-radius: 5px; |
||||
color: #fff; |
||||
margin-right: 20px; |
||||
} |
||||
|
||||
Text { |
||||
color: #6e6e6e; |
||||
} |
||||
|
||||
.del { |
||||
color: red; |
||||
} |
||||
} |
||||
|
||||
.info { |
||||
Image { |
||||
width: 150px; |
||||
height: 150px; |
||||
background: #ddd; |
||||
border-radius: 50%; |
||||
} |
||||
} |
||||
} |
||||
|
||||
.add { |
||||
margin: 20px; |
||||
border-radius: 10px; |
||||
background: linear-gradient(to right, #8284f7, #5a93f9); |
||||
color: #fff; |
||||
position: fixed; |
||||
width: 710rpx; |
||||
bottom: 20px; |
||||
} |
||||
|
||||
.operation { |
||||
border-top: 1px solid #ddd; |
||||
|
||||
View { |
||||
width: 50%; |
||||
text-align: center; |
||||
} |
||||
} |
@ -1,3 +0,0 @@ |
||||
export default definePageConfig({ |
||||
navigationBarTitleText: '学员管理', |
||||
}) |
@ -1,150 +0,0 @@ |
||||
import {Button, CustomWrapper, Image, Text, View} from "@tarojs/components"; |
||||
import {curriculum} from "@/api"; |
||||
import {FC, useState} from "react"; |
||||
import Taro, {useDidShow} from "@tarojs/taro"; |
||||
import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs"; |
||||
import './student.scss' |
||||
import {Profile} from '@/store' |
||||
import {ManageApi} from "@/api/manage"; |
||||
|
||||
interface RoleTypeProps { |
||||
id: number |
||||
role_type: number |
||||
getData: () => Promise<void> |
||||
} |
||||
|
||||
interface DelProps { |
||||
onClick: () => void |
||||
id: number |
||||
} |
||||
|
||||
const Del: FC<DelProps> = ({onClick, id}: DelProps) => { |
||||
const {user} = Profile.useContainer() |
||||
return ( |
||||
<> |
||||
{user?.id !== id && <View className='del' onClick={onClick}>删除</View>} |
||||
</> |
||||
) |
||||
} |
||||
|
||||
const RoleType: FC<RoleTypeProps> = ({id, role_type, getData}: RoleTypeProps) => { |
||||
const {user} = Profile.useContainer() |
||||
|
||||
function setRoleType() { |
||||
if (role_type === 2) { |
||||
Taro.showModal({title: "禁止修改超级管理员"}) |
||||
return |
||||
} |
||||
const type = role_type === 0 ? 1 : 0 |
||||
Taro.showModal({ |
||||
title: "设置为" + ['学员', '管理员'][type], |
||||
async success({confirm}) { |
||||
if (confirm) { |
||||
try { |
||||
Taro.showLoading() |
||||
await ManageApi.setRoleType(id, {auth_id: user?.id!, role_type: type}) |
||||
Taro.hideLoading() |
||||
Taro.showToast({title: "设置成功"}) |
||||
await getData() |
||||
} catch (e) { |
||||
} |
||||
} |
||||
} |
||||
}) |
||||
} |
||||
|
||||
return (user?.role_type === 2 ? |
||||
<View onClick={setRoleType}>{['设置管理员', '设置学员', '超级管理员'][role_type]}</View> |
||||
: null) |
||||
} |
||||
|
||||
const studentAdmin = () => { |
||||
const [list, setList] = useState<TabList[]>([]) |
||||
const [user, setUser] = useState<ManageUsers[]>([]) |
||||
|
||||
async function getData() { |
||||
Taro.showLoading() |
||||
const res = await curriculum.use() |
||||
if (res) { |
||||
setList(res.map(d => ({title: d.name, value: d}))) |
||||
setUser(res[0].users) |
||||
} |
||||
Taro.hideLoading() |
||||
} |
||||
|
||||
useDidShow(getData) |
||||
|
||||
|
||||
function listClick(data: OnChangOpt) { |
||||
setUser((data.tab?.value as Manage).users) |
||||
} |
||||
|
||||
function jumCollege(id: number, name: string) { |
||||
Taro.navigateTo({url: `/pages/manage/college/college?id=${id}&name=${name}`}) |
||||
} |
||||
|
||||
function changeStudent(id?: number) { |
||||
Taro.navigateTo({url: "/pages/manage/addStudent/addStudent" + (id ? `?id=${id}` : '')}) |
||||
} |
||||
|
||||
function del(id: number) { |
||||
Taro.showModal({ |
||||
title: '是否确认删除', |
||||
async success({confirm}) { |
||||
if (confirm) { |
||||
await ManageApi.del(id) |
||||
Taro.showToast({title: '删除成功'}) |
||||
await getData() |
||||
} |
||||
} |
||||
}) |
||||
} |
||||
|
||||
|
||||
return ( |
||||
<CustomWrapper> |
||||
<Profile.Provider> |
||||
<View className='bg-white mb-3'> |
||||
<Tabs tabList={list} onChange={listClick}/> |
||||
</View> |
||||
{user.length ? user.map((d) => ( |
||||
<View className='bg-white user'> |
||||
<View className='flex mt-3 header p-2 justify-between'> |
||||
<View className='flex'> |
||||
<View className='lock' |
||||
style={`background:${['#73c057', '#c94f4f'][d.is_lock]}`}>{['正常', '警用'][d.is_lock]}</View> |
||||
<Text>学员编号 {d.id}</Text> |
||||
</View> |
||||
{d.role_type === 0 && <Del id={d.id} onClick={() => del(d.id)}/>} |
||||
</View> |
||||
<View className='p-2 flex info justify-between'> |
||||
<View> |
||||
<View className='font-weight my-3'>{d.name}</View> |
||||
<View className='flex mb-3'> |
||||
<View style='width:60px' className='text-muted'>类型</View> |
||||
<View>{['学员', '管理员', '超级管理员'][d.role_type]}</View> |
||||
</View> |
||||
<View className='flex mb-3'> |
||||
<View style='width:60px' className='text-muted'>手机号</View> |
||||
<View>{d.phone_number}</View> |
||||
</View> |
||||
</View> |
||||
<Image src={d.avatar} mode='widthFix'/> |
||||
</View> |
||||
<View className='flex justify-between p-2 operation'> |
||||
<View onClick={() => changeStudent(d.id)}>修改</View> |
||||
<View onClick={() => jumCollege(d.id, d.name)}>学习记录</View> |
||||
<RoleType id={d.id} role_type={d.role_type} getData={getData}/> |
||||
</View> |
||||
</View> |
||||
)) |
||||
: <View className='text-center'>暂无数据</View>} |
||||
|
||||
<View className='py-8'/> |
||||
|
||||
<Button className='add' onClick={() => changeStudent()}>新建学员</Button> |
||||
</Profile.Provider> |
||||
</CustomWrapper> |
||||
) |
||||
} |
||||
export default studentAdmin |
Loading…
Reference in new issue