diff --git a/src/api/curriculum.ts b/src/api/curriculum.ts index b035d20..c53fa3c 100644 --- a/src/api/curriculum.ts +++ b/src/api/curriculum.ts @@ -23,6 +23,12 @@ export interface HourPlayData { extension: string /** 地址 */ url: string + hourExamQuestions: { + count: Record + data: Record + } + /** 断点 */ + timeList: number[] } export interface Course { @@ -32,6 +38,12 @@ export interface Course { stats: CueStats } +interface AnswerRecord { + is_pass: boolean + user_id: number + question_position: number +} + export const curriculum = { use() { return request('/api/v1/user/all', 'GET') @@ -60,7 +72,10 @@ export const curriculum = { curEnd(courseId: number, id: number, duration: number) { return request(`/api/v1/course/${courseId}/hour/${id}/record`, "POST", {duration}) }, - categoryCur(categoryId:number,companyId:number){ - return request(`/api/v1/category/${categoryId}/${companyId}`,"GET") + categoryCur(categoryId: number, companyId: number, type: string) { + return request(`/api/v1/category/${categoryId}/${companyId}/${type}`, "GET") + }, + answerRecord(id: number, data: AnswerRecord) { + return request<{ time: number }>(`/api/v1/test/video/record/${id}`, "POST", data) } } diff --git a/src/api/manage.ts b/src/api/manage.ts index a538f40..b84a4fd 100644 --- a/src/api/manage.ts +++ b/src/api/manage.ts @@ -1,7 +1,7 @@ import {request} from "@/api/request"; export interface Student { - company_id:number + company_id: number avatar: string dep_ids: number[] email: string @@ -64,6 +64,7 @@ export interface CurLearningRecord { total: number } + export const ManageApi = { /** 添加学员 */ addUser(data: Student) { @@ -111,5 +112,9 @@ export const ManageApi = { }, buy(data_list: number[]) { return request(`/api/v1/course/buy?data_list=${data_list}`, "POST") + }, + /** 学员学习记录 */ + userRecord(curId: number) { + return request(`/api/v1/course/${curId}/user/index?page=1&size=10000`, "GET") } } diff --git a/src/api/user.ts b/src/api/user.ts index 6fd92f0..5603c23 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -56,7 +56,7 @@ export const userApi = { code(catch_key: string) { return request<{ code: Code }>(`/api/v1/auth/login/code`, "POST", {openid: catch_key}) }, - learningRecord(courseId = 0) { - return request(`/api/v1/user/record/course`, "GET", {courseId}) + learningRecord(courseId?: number) { + return request(`/api/v1/user/record/course`, "GET", courseId ? {courseId} : {}) } } diff --git a/src/app.config.ts b/src/app.config.ts index 27f2da6..9243d8f 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -12,8 +12,18 @@ export default defineAppConfig({ }, tabBar: { list: [ - {text: '课题', pagePath: 'pages/index/index'}, - {text: "我的", pagePath: 'pages/my/my'} + { + text: '课题', + pagePath: 'pages/index/index', + iconPath: "static/tabs/home-unselect.png", + selectedIconPath: "static/tabs/home-selected.png", + }, + { + text: "我的", + pagePath: 'pages/my/my', + iconPath: "static/tabs/mine-unselect.png", + selectedIconPath: "static/tabs/mine-selected.png", + } ] }, preloadRule: { diff --git a/src/app.tsx b/src/app.tsx index 795eebb..b350ed5 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,4 +1,3 @@ -import {useEffect} from 'react' import Taro, {useDidShow, useDidHide} from '@tarojs/taro' import './app.scss' import {CustomWrapper} from "@tarojs/components"; @@ -32,13 +31,14 @@ function updateApp() { function App(props) { // 可以使用所有的 React Hooks - useEffect(() => { + + Taro.useLaunch(()=>{ updateApp() const token = JSON.parse(Taro.getStorageSync('profile') || '{}')?.token if (!token) { - Taro.switchTab({url: '/pages/login/login'}) + Taro.reLaunch({url: '/pages/login/login'}) } - }, []) + }) Taro.getSystemInfo({ diff --git a/src/components/video/type.ts b/src/components/video/type.ts index 6c17fe6..82fe90b 100644 --- a/src/components/video/type.ts +++ b/src/components/video/type.ts @@ -1,9 +1,3 @@ -interface Breakpoint { - id: number - /** 秒 */ - time: number -} - export interface HVideoOptions { /** 视频时长s */ duration: number @@ -14,10 +8,12 @@ export interface HVideoOptions { /** 视频封面 */ poster?: string /** 视频断点 */ - breakpoint: Breakpoint[] + breakpoint: number[] /** 进入断点 */ onBreakpoint: (id: number) => void /** 视频播放结束 */ onEnded: () => void + + setTime: (fn:(time:number)=>void) => void } diff --git a/src/components/video/video.tsx b/src/components/video/video.tsx index e678e79..2a27c7a 100644 --- a/src/components/video/video.tsx +++ b/src/components/video/video.tsx @@ -8,12 +8,12 @@ const deviation: number = 0.5 const HVideo: FC = (opt: HVideoOptions) => { const {user} = Profile.useContainer() - const video = Taro.createVideoContext('video') + const video = Taro.createVideoContext('myVideo') const [currentTime, setCurrentTime] = useState(0) function onTimeUpdate(event: BaseEventOrig) { if (opt.preview) return; - if (user?.role_type === 2) return; + // if (user?.role_type === 2) return; const time = event.detail.currentTime /** 前进回退 */ if (currentTime + deviation < time) { @@ -24,16 +24,22 @@ const HVideo: FC = (opt: HVideoOptions) => { /** 判断是否进入断点 */ opt.breakpoint.forEach(d => { - if (time < d.time + deviation && time > d.time - deviation) { - opt.onBreakpoint(d.id) + if (time < d + deviation && time > d - deviation) { video.pause() - video.seek(d.time - deviation) + video.seek(d - deviation) + opt.onBreakpoint(d) return } }) } + opt.setTime((time: number) => { + video.stop() + video.seek(time) + }) + function onEnded() { + if (opt.preview) return; if (user?.role_type === 2) return; if (currentTime + 1 > opt.duration) { opt.onEnded() @@ -44,18 +50,16 @@ const HVideo: FC = (opt: HVideoOptions) => { } return ( - <> -