diff --git a/src/api/manage.ts b/src/api/manage.ts index a9e3fd5..e5d4538 100644 --- a/src/api/manage.ts +++ b/src/api/manage.ts @@ -105,8 +105,8 @@ export const ManageApi = { return request(`/api/v1/department/${data.id}/courses?page=${data.page}&size=${data.size}`, "GET") }, /** 未添加课程 */ - optionalCur(dep_id: number) { - return request(`/api/v1//choose/${dep_id}/index`, "GET") + optionalCur(dep_id: number, page: number, pageSize: number) { + return request(`/api/v1/course/choose/${dep_id}/index`, "GET", {page, pageSize}) }, addCur(data: AddCurProps) { return request('/api/v1/course/user', "POST", data) diff --git a/src/api/user.ts b/src/api/user.ts index fd2a121..3ce5610 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -14,9 +14,9 @@ export interface LoginData { } interface CheckoutBody { - catch_key: string code: string phone_number: string + openid: string } interface CheckoutData { @@ -68,7 +68,7 @@ export const userApi = { }, /** 学习记录 */ record() { - return request<{course:HourHistory[],durations:Record}>(`/api/v1/category/history`, "GET") + return request<{ course: HourHistory[], durations: Record }>(`/api/v1/category/history`, "GET") }, courseRecord(course_id: string) { return request(`/api/v1/course/${course_id}/info`, "GET") @@ -87,5 +87,8 @@ export const userApi = { return request<{ data: Record }>(`/api/v1/statistics/statistics/${user_id}?start_time=${data.start_time}&end_time=${data.end_time}`, "GET") + }, + getCode(phone_number: number) { + return request('/api/v1/sms/send?phone_number='+phone_number, "GET") } } diff --git a/src/pages/business/test/test.tsx b/src/pages/business/test/test.tsx index c406d59..b4e92de 100644 --- a/src/pages/business/test/test.tsx +++ b/src/pages/business/test/test.tsx @@ -83,28 +83,25 @@ const Test = () => { return ( - {data?.fill.map((d, index) => )} - {data?.judge.map((d, index) => )} { - data?.multi.map((d, index) => ) } diff --git a/src/pages/business/videoInfo/components/course.tsx b/src/pages/business/videoInfo/components/course.tsx index b6d7d46..5a288fc 100644 --- a/src/pages/business/videoInfo/components/course.tsx +++ b/src/pages/business/videoInfo/components/course.tsx @@ -16,7 +16,7 @@ interface Props { id: number, courseId: number preview?: boolean - curEnd: () => void + curEnd: (test?:boolean) => void } @@ -44,6 +44,7 @@ const Course: FC = ({id, courseId, preview, curEnd}: Props) => { startRecording && curriculum.curEnd(courseId, id, {...startRecording, duration: data?.duration!}) //结束 if (testId) { Taro.navigateTo({url: `/pages/business/test/test?testId=${testId}`}) + curEnd(true) } else { curEnd() } diff --git a/src/pages/business/videoInfo/videoInfo.tsx b/src/pages/business/videoInfo/videoInfo.tsx index 5d5286f..9e49c01 100644 --- a/src/pages/business/videoInfo/videoInfo.tsx +++ b/src/pages/business/videoInfo/videoInfo.tsx @@ -26,9 +26,11 @@ const VideoInfo: FC = () => { } }, [playing, playId]) - const curEnd = () => { + const curEnd = (test?: boolean) => { setPlaying(false) - getData(false).then() + if (!test) { // 没有考题才会请求 + getData(false).then() + } } function setHors(is_complete: boolean, play_id: number) { @@ -76,6 +78,7 @@ const VideoInfo: FC = () => { const courseHourRecordsFinish = data?.learn_hour_records.find(d => d.id === playId)?.courseHourRecordsFinish if (typeof courseHourRecordsFinish === 'number') { if (courseHourRecordsFinish === 1) { + console.log(playing) if (!playing) { playNext() } diff --git a/src/pages/check/check.module.scss b/src/pages/check/check.module.scss index ee7cf5c..92c010f 100644 --- a/src/pages/check/check.module.scss +++ b/src/pages/check/check.module.scss @@ -1,39 +1,3 @@ -.container { - position: relative; -} - -.navbar, -.brand { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; -} - -.navbar { - position: relative; - line-height: 1; - font-size: 28px; -} - -.brand { - width: 140px; - height: 140px; - background: #fff; - border-radius: 20px; - margin: 250px auto 145px; - -image { - width: 100px; - height: 100px; -} -} - -.loginTips { - margin: 24px; - text-align: center; -} - .submit { display: flex; justify-content: center; @@ -41,28 +5,19 @@ image { gap: 12px; margin: 0 auto; -a { - - color: #fff; -} + a { + color: #fff; + } } - -.errorTips { - position: fixed; - top: 10%; - left: 24px; - right: 24px; - background: red; - color: white; - padding: 24px; - border-radius: 20px; +.formItem { display: flex; - align-items: center; - gap: 12px; + border-bottom: 1px solid #ededed; + padding: 30px 0; } -.bing { - height: 50vh; - padding: 50px 30px 0; +.image { + width: 50px; + vertical-align: top; + margin-right: 20px; } diff --git a/src/pages/check/check.tsx b/src/pages/check/check.tsx index 3d033f8..a558a36 100644 --- a/src/pages/check/check.tsx +++ b/src/pages/check/check.tsx @@ -1,25 +1,28 @@ -import {FC, useRef, useState} from "react"; +import {FC, useCallback, useEffect, useRef, useState} from "react"; import {Button, Form, Image, Input, View} from "@tarojs/components"; import {Profile} from "@/store"; import {userApi} from "@/api"; import Taro from "@tarojs/taro"; import {regexTel} from "@/utils/regu"; import styles from './check.module.scss' - -const uuid = () => { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { - const r = Math.random() * 16 | 0 - const v = c === 'x' ? r : (r & 0x3 | 0x8) - return v.toString(16) - }).replace(/-/g, '') -} +import code from '@/static/img/vCode.png' +import tel from '@/static/img/tel.png' const Bing: FC = () => { const form = useRef(null) const [loading, setLoading] = useState(false) + const [codeTime, setCodeTime] = useState(0) const {setUser, setToken, setCompany} = Profile.useContainer() - const [captchaKey, setCaptchaKey] = useState(uuid()) const openid = localStorage.getItem('openid') + const [phone_number, setPhone_number] = useState(undefined) + + useEffect(() => { + if (codeTime > 0) { + setTimeout(() => { + setCodeTime(codeTime - 1) + }, 1000) + } + }, [codeTime]) async function Submit(data) { setLoading(true) @@ -32,7 +35,6 @@ const Bing: FC = () => { try { const res = await userApi.checkout({ ...value, - catch_key: captchaKey, openid, }) if (res) { @@ -42,27 +44,53 @@ const Bing: FC = () => { Taro.switchTab({url: '/pages/index/index'}) } } catch (e) { - setCaptchaKey(uuid) } setLoading(false) } + const getCode = useCallback(async () => { + if (codeTime > 0) return; + if (!phone_number || !regexTel.exec(String(phone_number))) { + Taro.showToast({title: '手机号错误', icon: 'error'}) + setLoading(false) + return + } + + try { + await userApi.getCode(phone_number) + Taro.showToast({title: '请注意查收', icon: "none"}) + setCodeTime(60) + } catch (e) { + Taro.showToast({title: '获取短信验证码失败', icon: "error"}) + } + }, [codeTime, phone_number]) + return ( -
- - 手机号 - + + + + + + + setPhone_number(Number(e.detail.value))}/> - - 验证码 + + + + - - + + {codeTime > 0 ? `${codeTime}` : '获取验证码'} + diff --git a/src/pages/manage/addCur/addCur.tsx b/src/pages/manage/addCur/addCur.tsx index 0e5a50d..8023312 100644 --- a/src/pages/manage/addCur/addCur.tsx +++ b/src/pages/manage/addCur/addCur.tsx @@ -1,7 +1,7 @@ import {View} from "@tarojs/components"; import {getCurrentInstance} from "@tarojs/runtime"; import {ManageApi} from "@/api/manage"; -import React, {FC, useEffect, useState} from "react"; +import React, {FC, useCallback, useEffect, useState} from "react"; import Taro from "@tarojs/taro"; import VideoCover from "@/components/videoCover/videoCover"; import Empty from "@/components/empty/empty"; @@ -15,18 +15,19 @@ interface AddProps { const AddCur = () => { const {id} = getCurrentInstance()?.router?.params as { id: string } const [data, setData] = useState([]) + const [page] = useState(1) - async function getData() { + const getData = useCallback(async () => { try { - const res = await ManageApi.optionalCur(Number(id)) + const res = await ManageApi.optionalCur(Number(id), page, 10) if (res.length) { setData(res) } } catch (e) { } - } + }, [page]) useEffect(() => { getData() diff --git a/src/pages/manage/depAdmin/depAdmin.tsx b/src/pages/manage/depAdmin/depAdmin.tsx index f15061c..3e49426 100644 --- a/src/pages/manage/depAdmin/depAdmin.tsx +++ b/src/pages/manage/depAdmin/depAdmin.tsx @@ -119,7 +119,7 @@ const DepAdmin: FC = () => { useEffect(() => { getData() Taro.setNavigationBarTitle({ - title: decodeURI(router.params.name!) || '部门管理' + title: router.params.name ? decodeURI(router.params.name!) : '部门管理' }) }, []) diff --git a/src/static/img/tel.png b/src/static/img/tel.png new file mode 100644 index 0000000..19c6714 Binary files /dev/null and b/src/static/img/tel.png differ diff --git a/src/static/img/vCode.png b/src/static/img/vCode.png new file mode 100644 index 0000000..74d0359 Binary files /dev/null and b/src/static/img/vCode.png differ