From 6201f78c9382e05feb8fdb622d299505a39b3ec4 Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Tue, 8 Aug 2023 18:12:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E7=9F=AD=E4=BF=A1=E7=99=BB?= =?UTF-8?q?=E5=BD=95=EF=BC=8C=20=E5=AD=A6=E4=B9=A0=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/manage.ts | 4 +- src/api/user.ts | 7 +- src/pages/business/test/test.tsx | 9 +-- .../business/videoInfo/components/course.tsx | 3 +- src/pages/business/videoInfo/videoInfo.tsx | 7 +- src/pages/check/check.module.scss | 65 +++------------- src/pages/check/check.tsx | 72 ++++++++++++------ src/pages/manage/addCur/addCur.tsx | 9 ++- src/pages/manage/depAdmin/depAdmin.tsx | 2 +- src/static/img/tel.png | Bin 0 -> 2324 bytes src/static/img/vCode.png | Bin 0 -> 3760 bytes 11 files changed, 83 insertions(+), 95 deletions(-) create mode 100644 src/static/img/tel.png create mode 100644 src/static/img/vCode.png 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 0000000000000000000000000000000000000000..19c67147be1e4065f30808cd77a0678a7904a556 GIT binary patch literal 2324 zcmeHJ**Dt>6sD6H(F#FJiScVhC&5gjEwvRPmSAjE28}9dwY5~KooM5XK_wKYmRjbdGnU3yRhl9xTCp~hnf?RwGN&(nxc58fyZ3v!=ic+(R2L^(Ss7Is z2?+^Vf*syXjD7!vw3Im4{#;ii2FVCFTT6+$VK`4hLVB2h$GOM&uH1i`rf#ibBl1cW z0QA{uPwYgxTIBb6?a4p(-0FA23TPl@N=qai_fb8tuB#j5=x1HNRMPu)uAHuRlaUPD;q?}L-%pAXT#O7pw5c^qE*51nS}Zvm{!Nza^%)xow%c4n5h-hO@7(< zN;`Ou%#ru0bp;VFK}h_*dJ;ON_S$zjYx`XpA34h9PvWm;yMnf&Z|-2@=hkZkO_LXR z>2A=*ooC786xqNi{JdF4Kc1+ii9c zRREaV^eFc_`c*`9q*4W*Z9;D7BS7tT;-Je396ODwk(u9Vzet9|I_j=p1y5kdPp6bZ z);vpD%(4%(-wrYxCXHb(E zsvqLu;0eR`qpzrxX0si;MYQzY2NY~4N;`9U zZYx3#1HH3>MHGc>oY4Q)`^qY@zJX}I`%z9xT><&Vj$k_KFiQhkSwn|rRvMyl$2Mz( zHCs$|2uf#KNQ=yU%h`D6iZ}HQd>g_yrT|+|x&RT;%Rds*q||2P_0o5RoNht^95C+) z62#_(CMXv z4s@TYgfYYBdu@r47YhUlR&Y%SN2gyNIFh4sF-ZT7Q2}5dZgl!~PC#=stZtrrju*02M{M1DNXTDbRqTLT-`#nJUh>k6;{KC6n17CRY zuyxZ$nN%P|+A~r!!rL6J5)>b6-PWc|4*JuzL|kM#XRtmup(Br6q?r`I8=Ax@v!-70 zsVQ=7e+K>iWhodFdny3iJ?OdI^gzMS0_5$a@tD=1s*NfZ0B^}FF#BT4Y(%mGE6 yqb0z>YLmqUu`e5GJJ*Ok-o2cEzwir)JCigFm&XG#3gX0Xjs(Hl314UFNBJ8M4&<-^ literal 0 HcmV?d00001 diff --git a/src/static/img/vCode.png b/src/static/img/vCode.png new file mode 100644 index 0000000000000000000000000000000000000000..74d0359f27adb2b13f0cbdb5d0f843b2b80e026a GIT binary patch literal 3760 zcmeH~`8yQu`o|w*ZEVxXlEjS0l6ClGE6ZStF(EW##+Id2NJyDT#9&6pHkSAZM_Kv| z*=6U0DO;AxQX&+}zLTYV=Um_O>p6eH`Qdr)`?`O5U-x}K&-=Pw^h;J|f>22)06-9D zjIMQMD+NjA~-iNmy3RbZfDos>T`*5 zP>^UL5a$+s8erN2O!}iw?E-cnoH`fnkg5nUN*ZUPj~4)N!ppzb=80FvYY6P z{@~FXvKhp!UXdGG>kTS$Ii$XP3%IT@+GMI$k(C5GFO2dxb_lBnJR9do^zl#x6>-af zH7&bYG(+=xqYt|qIZHJmIC2WE2moAB;fv~=o!drQgAc?+m!ZhPbsJ@8GGJKYZSc~$ zL$yt2R0mmlvKRz`n{o10fyCq6`KpO$h$EtaY;z~4(PQ})=!)fO*IWs9FARU)@;SOs z=I};~K}pcg);5=LMZ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