答案样式 && 空状态

main
king 1 year ago
parent 0054b7741d
commit d052aa82d0
  1. 22
      src/api/request.ts
  2. 2
      src/app.scss
  3. 21
      src/components/empty/empty.module.scss
  4. 19
      src/components/empty/empty.tsx
  5. 3
      src/components/topic/judge.tsx
  6. 3
      src/components/topic/multi.tsx
  7. 2
      src/components/topic/shortAnswer.tsx
  8. 10
      src/components/topic/topic.scss
  9. 1
      src/components/video/video.tsx
  10. 10
      src/pages/business/history/history.tsx
  11. 2
      src/pages/business/test/test.tsx
  12. 1
      src/pages/business/videoInfo/components/course.tsx
  13. 5
      src/pages/index/components/videoList.tsx
  14. 1
      src/pages/index/index.tsx
  15. 5
      src/pages/login/login.module.scss
  16. 9
      src/pages/login/login.tsx
  17. 5
      src/pages/manage/addCur/addCur.tsx
  18. 4
      src/pages/manage/curriculum/curriculum.tsx
  19. 2
      src/static/css/module.scss

@ -43,7 +43,12 @@ export const ERROR_STATUS: Record<number | string, string> = {
'INVALID_DATA': '服务器响应异常~',
'OVERSTEP': '请求越界~'
}
let isOverdue = false
const whitelist = [
'/api/v1/auth/login/code',
'/api/v1/auth/login/checkout',
'/api/v1/auth/login/wechat'
]
export function request<T = unknown>(
url: string,
@ -63,6 +68,13 @@ export function request<T = unknown>(
if (token) {
option.header ??= {}
option.header['Authorization'] = `Bearer ${token}`
} else {
/** 登录页面白名单 */
if (Taro.getCurrentInstance().router?.path === '/pages/login/login') {
if (!whitelist.includes(url)) {
return new Promise((_, reject) => reject())
}
}
}
if (method === 'GET' && data) {
let parameter = ''
@ -71,11 +83,10 @@ export function request<T = unknown>(
})
option.url += parameter
}
if (isOverdue) {
isOverdue = false
}
data && (option.data = data)
return new Promise<T>((resolve, reject) => {
Taro.request<T>({
...option,
success(res) {
@ -84,8 +95,6 @@ export function request<T = unknown>(
if (data?.code === 0 && res.statusCode === 200) {
resolve(data.data || [])
} else if (res.statusCode === 401) {
if (!isOverdue) {
isOverdue = true
Taro.showModal({
title: "登录过期,需重新登陆",
showCancel: false,
@ -93,7 +102,6 @@ export function request<T = unknown>(
confirm && Taro.reLaunch({url: '/pages/login/login'})
}
})
}
} else {
Taro.showToast({title: data.msg || ERROR_STATUS[res.statusCode] || '请求错误~', icon: 'error'})
reject(null)

@ -249,8 +249,6 @@
.bg-gray{ background-color: gray;}
.bg-transparent { background-color: transparent;}
/* 文字颜色 */
.text-white {color: #ffffff }
.text-primary {color: #007bff;}

@ -0,0 +1,21 @@
.empty {
width: 750rpx;
text-align: center;
color: #6c757d;
position: relative;
Image {
display: block;
margin: auto;
width: 400px;
margin-bottom: 10px;
}
View {
position: absolute;
left: 0;
right: 0;
bottom: 40px;
margin: auto;
}
}

@ -0,0 +1,19 @@
import {FC} from "react";
import {Image, View} from "@tarojs/components";
import emptyImg from '@/static/img/empty.png'
import styles from './empty.module.scss'
interface Props {
name: string
}
const Empty: FC<Props> = ({name}) => {
return (
<View className={styles.empty}>
<Image src={emptyImg} mode='widthFix'/>
<View>{name}</View>
</View>
)
}
export default Empty

@ -73,7 +73,8 @@ const Judge: FC<Props> = ({data, onAnswer, onUpAndDown, index, validate, frequen
{error && frequency == 0 && <View className='mt-3'>
<View className='font-weight mb-3'></View>
<View className='right_answer'>{data.right_answer ? '正确' : '错误'}</View>
<View className='font-weight my-3'></View>
<View>{data.analysis}</View>
</View>}
</View>

@ -88,7 +88,8 @@ const Multi: FC<Props> = ({data, onAnswer, onUpAndDown, index, validate, frequen
{error && frequency == 0 && <View className='mt-3'>
<View className='font-weight mb-3'></View>
<View className='right_answer'>{data.right_answer}</View>
<View className='font-weight my-3'></View>
<View>{data.analysis}</View>
</View>}
</View>

@ -63,7 +63,7 @@ const ShortAnswer: FC<Props> = ({data, onAnswer, onUpAndDown, index, validate, f
{frequency == 0 && <View className='mt-3'>
<View className='font-weight mb-3'></View>
<View className='font-weight my-3'></View>
<View>{data.analysis}</View>
</View>}

@ -1,10 +1,12 @@
.topic {
padding: 40rpx;
box-sizing: border-box;
background: #FFF;
.option {
display: block;
margin-bottom: 10px;
line-height: 2;
}
}
@ -23,3 +25,11 @@
width: 40%;
}
}
.right_answer{
font-weight: bold;
color: #FF9E5F;
line-height: 40rpx;
font-size: 32px;
}

@ -53,6 +53,7 @@ const HVideo: FC<HVideoOptions> = (opt: HVideoOptions) => {
return (
<Video
id={'myVideo'}
autoplay
style={{width: '100%', height: '100%'}}
poster={opt?.poster || ''}
src={opt.src}

@ -6,6 +6,7 @@ import Taro from "@tarojs/taro";
import {userApi} from "@/api";
import {useState} from "react";
import {formatMinute} from "@/utils/time";
import Empty from "@/components/empty/empty";
const History = () => {
const [data, setData] = useState<userRecord[]>([])
@ -25,18 +26,17 @@ const History = () => {
<CategoryTabs changeTabs={getData}/>
<View className='mt-3'>
{data.map(d => <View className={styles.category} onClick={() => jump(d.course_id, d.course.title)}>
{data.length ? data.map(d => <View className={styles.category}
onClick={() => jump(d.course_id, d.course.title)}>
<View className={styles.thumb}>
<Image src={d.course.thumb}/>
<View>{d.total_hour_count}/{d.finished_count}</View>
</View>
<View className={styles.text}>
<View>{d.course.title}</View>
<View>{formatMinute(d.duration)}</View>
<View>{formatMinute(d.duration)}</View>
</View>
</View>)}
<View className='text-center text-muted mt-3'>- -</View>
</View>) : <Empty name='无观看记录'/>}
</View>
</View>
)

@ -104,8 +104,10 @@ const Test = () => {
validate={validate}/>)
}
<View className='bg-white pb-3'>
<Button className='button' onClick={onSubmit}></Button>
</View>
</View>
)
}

@ -62,7 +62,6 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}: Props) => {
setShow(true)
}
async function getData() {
unique_ident.put()

@ -6,6 +6,7 @@ import VideoCover from "@/components/videoCover/videoCover";
import styles from '../index.module.scss'
import {formatMinute} from "@/utils/time";
import {userApi} from "@/api";
import Empty from "@/components/empty/empty";
interface Props {
categoryKey: CoursesKey
@ -114,7 +115,7 @@ export const VideoList: FC<Props> = ({categoryKey}) => {
}, [page])
return (
<View className={'py-2 flex justify-between flex-wrap ' + styles.videoListBox}>
{data?.[categoryKey]?.map(c =>
{data?.[categoryKey]?.length ? data?.[categoryKey]?.map(c =>
<VideoCover
thumb={c.thumb}
title={c.title}
@ -122,7 +123,7 @@ export const VideoList: FC<Props> = ({categoryKey}) => {
depId={c.id}
time={formatMinute(c.course_duration)}
content={rateOfLearning(c.id, c.class_hour)}
/>)}
/>) : <Empty name='暂无数据'/>}
</View>
)
}

@ -30,7 +30,6 @@ const Index: FC = () => {
{/*<Search/>*/}
<Tabs tabList={category} onChange={tabChange} current={categoryKey}/>
<VideoList categoryKey={categoryKey}/>
<View className='text-center text-muted my-3'>- -</View>
</View>
</Profile.Provider>
)

@ -39,10 +39,7 @@
justify-content: center;
align-items: center;
gap: 12px;
background: red;
color: #fff;
border-radius: 20px;
margin: 0 56px;
margin: 0 auto;
}

@ -1,6 +1,6 @@
import {FC, useEffect, useRef, useState} from "react";
import {Profile} from "@/store";
import {Button, CustomWrapper, Form, Image, Input, PageContainer, Text, View} from "@tarojs/components";
import {Button, Form, Image, Input, PageContainer, Text, View} from "@tarojs/components";
import Taro from "@tarojs/taro";
import styles from './login.module.scss'
import Loading from "@/components/loading";
@ -72,7 +72,8 @@ const Bing: FC<BingProps> = ({code, catch_key}: BingProps) => {
</View>
</View>
<Button className={styles.submit} style='margin:30px 0' formType='submit' disabled={loading}></Button>
<Button className={'button ' + styles.submit} style='margin:30px auto' formType='submit'
disabled={loading}></Button>
</Form>
</View>
)
@ -138,7 +139,7 @@ const Login = () => {
<View className={styles.loginTips}>
<Text>使</Text>
</View>
<Button className={styles.submit} onClick={login} disabled={isLoading}>
<Button className={'button ' + styles.submit} onClick={login} disabled={isLoading}>
{isLoading ? <Loading/> : null}
<Text></Text>
</Button>
@ -148,11 +149,9 @@ const Login = () => {
const Index: FC = () => {
return (
<CustomWrapper>
<Profile.Provider>
<Login/>
</Profile.Provider>
</CustomWrapper>
)
}
export default Index

@ -6,6 +6,7 @@ import Tabs, {TabList} from "@/components/tabs/tabs";
import {Category, publicApi} from "@/api/public";
import Taro from "@tarojs/taro";
import VideoCover from "@/components/videoCover/videoCover";
import Empty from "@/components/empty/empty";
interface AddProps {
cur_id: number,
@ -117,10 +118,8 @@ const AddCur = () => {
/>
))}
</View>
: null
: <Empty name='无更多课程'/>
}
<View className='text-center mt-3'>- -</View>
</CustomWrapper>
)
}

@ -4,6 +4,7 @@ import VideoCover from "@/components/videoCover/videoCover";
import styles from './curriculum.module.scss'
import {ManageApi} from "@/api/manage";
import Taro from "@tarojs/taro";
import Empty from "@/components/empty/empty";
const Curriculum = () => {
@ -56,9 +57,8 @@ const Curriculum = () => {
content={d.title}/>
))}
</View>
: null
: <Empty name='无购买课程'/>
}
<View className='text-center mt-3'>- -</View>
</CustomWrapper>
)
}

@ -1,6 +1,7 @@
page {
background-color: #efeff7;
font-family: PingFang SC-Bold, PingFang SC;
-webkit-overflow-scrolling: touch
}
.input {
@ -11,7 +12,6 @@ page {
}
.form {
.item {
margin-bottom: 10px;
display: flex;

Loading…
Cancel
Save