From 33abea6a4961a00d2677904cc10d9d609242554a Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Tue, 18 Jul 2023 13:43:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E7=9A=84=E5=92=8C=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/curriculum.ts | 1 + src/api/manage.ts | 8 -- src/api/public.ts | 1 + src/app.config.ts | 1 - .../business/userInfo/userInfo.module.scss | 6 +- src/pages/business/userInfo/userInfo.tsx | 6 +- .../videoInfo/components/ContainDeps.tsx | 75 ------------- .../videoInfo/components/catalogue.tsx | 13 ++- src/pages/business/videoInfo/videoInfo.scss | 1 + src/pages/business/videoInfo/videoInfo.tsx | 4 +- src/pages/index/index.tsx | 7 +- .../studentRecord/studentRecord.config.ts | 4 - .../manage/studentRecord/studentRecord.tsx | 102 ------------------ src/pages/my/components/header/time.tsx | 11 +- src/pages/my/my.tsx | 1 - src/static/css/module.scss | 7 +- 16 files changed, 35 insertions(+), 213 deletions(-) delete mode 100644 src/pages/business/videoInfo/components/ContainDeps.tsx delete mode 100644 src/pages/manage/studentRecord/studentRecord.config.ts delete mode 100644 src/pages/manage/studentRecord/studentRecord.tsx diff --git a/src/api/curriculum.ts b/src/api/curriculum.ts index 5de9b2a..5845db6 100644 --- a/src/api/curriculum.ts +++ b/src/api/curriculum.ts @@ -44,6 +44,7 @@ export const curriculum = { courseDep(id: number, depId: number | null) { return request(`/api/v1/course/${id}${depId ? `/dep/${depId}` : ''}`, "GET") }, + /** 播放 */ hourPlay(courseId: number, id: number) { return request(`/api/v1/course/${courseId}/hour/${id}/play`, "GET") }, diff --git a/src/api/manage.ts b/src/api/manage.ts index 98ad4e8..a538f40 100644 --- a/src/api/manage.ts +++ b/src/api/manage.ts @@ -111,13 +111,5 @@ export const ManageApi = { }, buy(data_list: number[]) { return request(`/api/v1/course/buy?data_list=${data_list}`, "POST") - }, - /** 课程绑定部门 */ - bingDep(dep_id: number) { - return request(`/api/v1/course/all/bind/${dep_id}`, "GET") - }, - /** 课程学员学习记录 */ - curLearningRecord(cur_id: number | string,data:{page:number,size:number}) { - return request(`/api/v1/course/${cur_id}/user/index`, "GET", data) } } diff --git a/src/api/public.ts b/src/api/public.ts index 3f0d902..a34bd51 100644 --- a/src/api/public.ts +++ b/src/api/public.ts @@ -33,6 +33,7 @@ export type Cur = Category & { export const publicApi = { + /** 分类 */ category() { return request('/api/v1/category/all', "GET") }, diff --git a/src/app.config.ts b/src/app.config.ts index 4319755..6601020 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -45,7 +45,6 @@ export default defineAppConfig({ 'addStudent/addStudent', 'depCur/depCur', 'addCur/addCur', - 'studentRecord/studentRecord', ] } ] diff --git a/src/pages/business/userInfo/userInfo.module.scss b/src/pages/business/userInfo/userInfo.module.scss index 4c9efa6..a3c2aae 100644 --- a/src/pages/business/userInfo/userInfo.module.scss +++ b/src/pages/business/userInfo/userInfo.module.scss @@ -15,8 +15,12 @@ background: #45D4A8; border-radius: 40rpx; color: #fff; + font-size: 32rpx; +} + + +.buttonFixed{ position: fixed; bottom:100px; left: 30rpx; - font-size: 32rpx; } diff --git a/src/pages/business/userInfo/userInfo.tsx b/src/pages/business/userInfo/userInfo.tsx index 9a15da5..17487e6 100644 --- a/src/pages/business/userInfo/userInfo.tsx +++ b/src/pages/business/userInfo/userInfo.tsx @@ -48,20 +48,20 @@ const List = () => { - 修改昵称{name} + 修改昵称 setName(event.detail.value)} value={name} /> - 限制4-20个字符,可由中英文、数字、“_”、“-”组成 + 限制4-20个字符,可由中英文、数字、“_”、“-”组成 - + ) } diff --git a/src/pages/business/videoInfo/components/ContainDeps.tsx b/src/pages/business/videoInfo/components/ContainDeps.tsx deleted file mode 100644 index 7698965..0000000 --- a/src/pages/business/videoInfo/components/ContainDeps.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import {FC, useState} from "react"; -import {View} from "@tarojs/components"; -import {ManageApi} from "@/api/manage"; -import {Profile} from '@/store' -import PopPut from "@/components/popPut/popPut"; -import Taro from "@tarojs/taro"; - - -interface Props { - cur_id: number - name?: string -} - -const Dep: FC = ({cur_id}: Props) => { - const [bindDep, setBindDep] = useState([]) - - async function getBind() { - try { - const res = await ManageApi.bingDep(cur_id) - setBindDep(res.department) - } catch (e) { - } - } - - function jump(item: Department) { - Taro.showModal({ - title: "是否查看" + item.name, - success({confirm}) { - confirm && Taro.navigateTo({url: `/pages/manage/depCur/depCur?id=${item.id}`}) - } - }) - } - - Taro.useDidShow(() => { - getBind() - }) - - return (<> - {bindDep && - 课程已分配部门 - {bindDep && bindDep.map(d => ( - jump(d)}/> - ))} - - } - ) -} - -const StudentRecord: FC = ({cur_id, name}: Props) => { - function jump() { - Taro.navigateTo({url: `/pages/manage/studentRecord/studentRecord?cur_id=${cur_id}&name=${name}`}) - } - - return ( - - - - ) -} - -const ContainDeps: FC = ({cur_id,name}: Props) => { - const {user} = Profile.useContainer() - - return ( - <> - {user?.role_type !== 0 ? - - - - - : null} - - ) -} -export default ContainDeps diff --git a/src/pages/business/videoInfo/components/catalogue.tsx b/src/pages/business/videoInfo/components/catalogue.tsx index bead96d..48d5d62 100644 --- a/src/pages/business/videoInfo/components/catalogue.tsx +++ b/src/pages/business/videoInfo/components/catalogue.tsx @@ -13,16 +13,19 @@ interface Props { const Catalogue: FC = ({data}: Props) => { const {user} = Profile.useContainer() - const [current, setCurrent] = useState(1) + const [current, setCurrent] = useState(0) const [tabList, setTabList] = useState([ {title: '介绍', value: 0}, {title: '目录', value: 1}, - {title: '评价', value: 2}, + // {title: '评价', value: 2}, ]) useEffect(() => { if (user?.role_type && user?.role_type > 0) { - setTabList([...tabList, {title: '学员管理', value: 3}]) + setTabList([ + ...tabList, + // {title: '部门进度', value: 3} + ]) } }, []) @@ -41,7 +44,7 @@ const Catalogue: FC = ({data}: Props) => { function complete(id: number): boolean { - return !!data?.learn_hour_records[id]?.is_finished + return !!data?.learn_hour_records?.[id]?.is_finished } @@ -56,7 +59,7 @@ const Catalogue: FC = ({data}: Props) => { {current === 0 && {data?.course.short_desc}} {current === 1 && - 课程目录 + 课程目录 {data?.chapters.length ? Object.values(data?.chapters || {}).map((d, index) => <> diff --git a/src/pages/business/videoInfo/videoInfo.scss b/src/pages/business/videoInfo/videoInfo.scss index 3a7cb31..cf2f3c2 100644 --- a/src/pages/business/videoInfo/videoInfo.scss +++ b/src/pages/business/videoInfo/videoInfo.scss @@ -21,6 +21,7 @@ .short_desc { color: #606563; line-height: 1.75; + word-break: break-word; } } diff --git a/src/pages/business/videoInfo/videoInfo.tsx b/src/pages/business/videoInfo/videoInfo.tsx index 178178f..e599c07 100644 --- a/src/pages/business/videoInfo/videoInfo.tsx +++ b/src/pages/business/videoInfo/videoInfo.tsx @@ -26,11 +26,9 @@ const VideoInfo: FC = () => { - {/**/} - - {data?.is_required ? '必修' : '选秀'} + {data?.is_required ? '必修' : '选修'} {data?.course.class_hour}课时 {data?.course.title} diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index fe77303..83f4c39 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -10,6 +10,7 @@ import {CoursesKey} from "@/api/public"; const Index: FC = () => { + const globalData = Taro.getApp().globalData const category: TabList[] = [ {title: "必修", value: 'is_required'}, {title: "选修", value: 'is_not_required'}, @@ -22,8 +23,12 @@ const Index: FC = () => { setCategoryId(data.tab?.value as CoursesKey) } + // Taro.showActionSheet({ + // alertText: '212', + // itemColor:'red', + // itemList:['删除'] + // }) - const globalData = Taro.getApp().globalData return ( diff --git a/src/pages/manage/studentRecord/studentRecord.config.ts b/src/pages/manage/studentRecord/studentRecord.config.ts deleted file mode 100644 index 678bcd3..0000000 --- a/src/pages/manage/studentRecord/studentRecord.config.ts +++ /dev/null @@ -1,4 +0,0 @@ -export default definePageConfig({ - navigationBarTitleText: '学员学习记录', - onReachBottomDistance:30 -}) diff --git a/src/pages/manage/studentRecord/studentRecord.tsx b/src/pages/manage/studentRecord/studentRecord.tsx deleted file mode 100644 index 5a4931d..0000000 --- a/src/pages/manage/studentRecord/studentRecord.tsx +++ /dev/null @@ -1,102 +0,0 @@ -import {CustomWrapper, Image, Text, View} from "@tarojs/components"; -import {FC, useEffect, useState} from "react"; -import {getCurrentInstance} from "@tarojs/runtime"; -import Taro, {useReachBottom} from "@tarojs/taro"; -import {CurLearningRecord, ManageApi} from "@/api/manage"; -import '@/pages/manage/studentAdmin/student.scss' - -const StudentRecord: FC = () => { - const [page, setPage] = useState(1) - const {cur_id, name} = getCurrentInstance()?.router?.params as { cur_id: string, name: string } - const [data, setData] = useState(null) - const [total, setTotal] = useState(0) - - async function getData() { - try { - const res = await ManageApi.curLearningRecord(cur_id, {page, size: 10}) - if (!data) { - setData(res) - } else { - const oldData: CurLearningRecord = JSON.parse(JSON.stringify(data)) - oldData.data.push(...res.data) - oldData.departments = res.departments - Object.entries(res.user_dep_ids).forEach(([key, value]) => { - oldData.user_dep_ids[key] = value - }) - Object.entries(res.user_course_records).forEach(([key, value]) => { - oldData.user_course_records[key] = value - }) - Object.entries(res.user_course_hour_user_first_at).forEach(([key, value]) => { - oldData.user_course_hour_user_first_at[key] = value - }) - setData(oldData) - } - setTotal(res.total) - } catch (e) { - } - } - - function getDep(user_id: number): string { - const cur_ids = data?.user_dep_ids[user_id] - if (cur_ids) { - return cur_ids.map(d => data?.departments[d]).join('、') - } - return '' - } - - useReachBottom(() => { - if (data && data.data.length < total) { - setPage(page + 1) - } - }) - - - useEffect(() => { - getData() - }, [page]) - Taro.setNavigationBarTitle({title: name}) - - return ( - - {data?.data.map(d => ( - - - - 学员编号 {d.id} - - - - - {d.name} - - 类型 - {['学员', '管理员', '超级管理员'][d.role_type]} - - - 手机号 - {d.phone_number} - - - 邮箱 - {d.email} - - - 部门 - {getDep(d.id)} - - - 学习进度 - {data?.user_course_records[d.id]?.finished_count || 0}/{data?.course.class_hour} - - - - - - - - ))} - - ) -} - -export default StudentRecord diff --git a/src/pages/my/components/header/time.tsx b/src/pages/my/components/header/time.tsx index aee3ff4..98ed001 100644 --- a/src/pages/my/components/header/time.tsx +++ b/src/pages/my/components/header/time.tsx @@ -4,7 +4,7 @@ import curriculum1 from '@/static/img/curriculum1.png' import curriculum2 from '@/static/img/curriculum2.png' import Taro from "@tarojs/taro"; import {curriculum} from "@/api"; -import {useState} from "react"; +import {FC, useState} from "react"; import {formatMinute} from "@/utils/time"; import time1 from "@/static/img/time1.png"; import time2 from "@/static/img/time2.png"; @@ -17,7 +17,7 @@ interface List { src: string } -const Time = () => { +const Time:FC = () => { const [list, setList] = useState([ {title: '今日时长', time: '00:00', src: time1}, {title: '累计时长', time: '00:00', src: time2}, @@ -39,8 +39,7 @@ const Time = () => { 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) setList(oldList) - } catch (e) { - } + } catch (e) {} }) @@ -51,8 +50,8 @@ const Time = () => { return ( - {d.title} - {d.time} + {d.title} + {d.time} diff --git a/src/pages/my/my.tsx b/src/pages/my/my.tsx index 3e3f16b..65241a1 100644 --- a/src/pages/my/my.tsx +++ b/src/pages/my/my.tsx @@ -15,7 +15,6 @@ const My: FC = () => {
-