我的学习记录

v2
king 1 year ago committed by xing
parent 7b0c91dfcd
commit 2029037d7a
  1. 18
      src/api/curriculum.ts
  2. 4
      src/api/home.ts
  3. 8
      src/pages/home/components/feature_recommended.tsx
  4. 18
      src/pages/my/components/header/time.tsx

@ -34,10 +34,18 @@ export interface HourPlayData {
}
export interface Course {
courses: Curriculum[]
learn_course_records: unknown
user_course_hour_count: unknown
stats: CueStats
/** 完成 */
finished_count: number;
/** 未完成 */
not_finished_count: number
/** 选修课时数量 */
not_required_count: number
/** 必修课时数量 */
required_count: number
/** 今天 */
today_learn_time: number
/** 累计 */
total_learn_time: number
}
interface AnswerRecord {
@ -87,7 +95,7 @@ export const curriculum = {
},
/** 课程进度 */
course() {
return request<Course>(`/api/v1/user/courses`, "GET")
return request<Course>(`/api/v1/user/all/course/info`, "GET")
},
/** 课程结束 */
curEnd(courseId: number, id: number, data: CurEndParam) {

@ -59,5 +59,9 @@ export const HomeApi = {
},
skillList(categoryId: number, page: number, page_size: number) {
return request<{ data: Kill[], total: number }>('/home/v1/skill/index', "GET", {categoryId, page, page_size})
},
/** 疾病知识 */
illness(page: number, page_size: number) {
return request('/home/v1/article/illness_list', "GET", {page, page_size})
}
}

@ -93,8 +93,14 @@ const FeatureRecommended: FC = () => {
return []
}
/** 疾病 */
async function getIllness() {
const res = await HomeApi.illness(1, 3)
console.log(res)
}
useEffect(() => {
Promise.all([getBrand(), getHealth(), getKill()]).then(([brand, health, kill]) => {
Promise.all([getBrand(), getHealth(), getKill(), getIllness()]).then(([brand, health, kill]) => {
const oldData: Data[] = JSON.parse(JSON.stringify(data))
oldData[0].data = brand
oldData[1].data = health

@ -22,8 +22,8 @@ const Time: FC = () => {
const [list, setList] = useState<List[]>([
{title: '今日时长', time: '00:00', src: time1},
{title: '累计时长', time: '00:00', src: time2},
{title: '必修课', time: '0/0', src: curriculum1, type: 1},
{title: '选修课', time: '0/0', src: curriculum2, type: 2},
{title: '必修课', time: '0', src: curriculum1, type: 1},
{title: '选修课', time: '0', src: curriculum2, type: 2},
{title: '已完成', time: '0', src: over, type: 3},
{title: '未完成', time: '0', src: incomplete, type: 4},
])
@ -31,14 +31,14 @@ const Time: FC = () => {
Taro.useDidShow(async () => {
try {
const {stats} = await curriculum.course()
const res = await curriculum.course()
const oldList: List[] = JSON.parse(JSON.stringify(list))
oldList[0].time = formatMinute(stats.today_learn_duration)
oldList[1].time = formatMinute(stats.learn_duration)
oldList[2].time = stats.required_course_count
oldList[3].time = stats.nun_required_course_count
oldList[4].time = stats.required_finished_course_count + stats.nun_required_finished_course_count
oldList[5].time = stats.total_course_count - (stats.required_finished_course_count + stats.nun_required_finished_course_count)
oldList[0].time = formatMinute(res.today_learn_time)
oldList[1].time = formatMinute(res.total_learn_time)
oldList[2].time = res.required_count
oldList[3].time = res.not_required_count
oldList[4].time = res.finished_count
oldList[5].time = res.not_finished_count
setList(oldList)
} catch (e) {
}

Loading…
Cancel
Save