Skip to content

Commit

Permalink
Merge pull request #45 from HXTIA/fix_mvp_24-6-1
Browse files Browse the repository at this point in the history
feat: 请求拼接collegeId
  • Loading branch information
HardenSG authored May 31, 2024
2 parents f2b6078 + 21cf36f commit 07c8e0a
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 41 deletions.
3 changes: 2 additions & 1 deletion src/pages/Detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const Index: FC = () => {
}),
{ auto: true },
)
const imgs = useMemo(() => data?.pictureLinks?.split(',').map((v) => v) || [], [data])
const imgs = useMemo(() => data?.pictureLinks?.split(',').filter((v) => !!v) || [], [data])

const [isShowPoster, setIsShowPoster] = useState(false)
// const updateTaskStatus = useCallback(() => {
// if (data!.status > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@ import Frame from './frame'

const url = requestUrlCreator({
rootPath: 'WX_STU',
absolutePath: '/apply',
absolutePath: '/verificationCode',
}) /** TODO: 替换真实接口 */
const Index: FC<{ setView: React.Dispatch<React.SetStateAction<TComponents>> }> = ({ setView }) => {
const [ipt, setIpt] = useState('')
const apply = useCallback(async () => {
if (!ipt.length) return
/** 替换真实接口 */
const result = await Post({
url,
data: {
code: ipt,
},
url: url + `?code=${ipt}`,
silent: true,
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
height: 100rpx;
padding: 0 30rpx 0 20rpx;
box-sizing: border-box;
background-color: aqua;
background-color: rgb(206, 213, 213);

&_left {
display: flex;
width: 100%;
flex-direction: column;
justify-content: center;

Expand All @@ -42,6 +43,10 @@
.time {
font-size: 25rpx;
}

.right {
text-align: end;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
import React, { FC, memo, useEffect, useState } from 'react'
import { Button, View } from '@tarojs/components'
import { timeFormat } from 'src/utils'
import { Get, requestUrlCreator, timeFormat } from 'src/utils'
import './feedback.modules.scss'
import { TComponents } from '..'
import Frame from './frame'

const enumO = {
0: '申请中',
1: '已完成',
}

const url = requestUrlCreator({
rootPath: 'WX_STU',
absolutePath: '/getStudentCode',
})
const List = memo(({ children }: any) => {
const [data, setData] = useState<any[]>()
useEffect(() => {
/** TODO: 模拟请求 */
new Promise((resolve) => {
setTimeout(() => {
resolve([
{
id: 1,
name: 'xbhsjabxhjasbhjxa',
time: Date.now(),
status: 0,
},
{
id: 2,
name: 'xsjabxhjasbxhjasbxhj',
time: Date.now(),
status: 1,
},
])
}, 0)
}).then((res: any[]) => {
setData(res)
Get({
url,
silent: true,
}).then(({ isSuccess, handleException, data: lists }) => {
if (!isSuccess) {
handleException()
} else {
setData(lists as any)
}
})
}, [])
return data && data.map((d) => children(d))
Expand All @@ -43,19 +32,20 @@ const Index: FC<{ setView: React.Dispatch<React.SetStateAction<TComponents>> }>
<Frame targetView='apply' setView={setView}>
<View className='feedback_wrapper'>
<View key='button' className='back-btn'>
返回申请
🔙 返回继续申请
</View>
<View className='list_wrapper'>
<List>
{({ name, time, status }) => (
{({ code, createdAt }) => (
<View className='list'>
<View className='list_left'>
<View className='name'>{name}</View>
<View className='time'>{timeFormat(time)}</View>
</View>
<View className='list_right'>
<View className='status'>{enumO[status]}</View>
<View className='name'>{code}</View>
<View className='time right'>申请时间:{timeFormat(createdAt)}</View>
</View>
{/* <View className='list_right'>
<View className='publisher'>创建人</View>
<View className='publisher'>{studentId}</View>
</View> */}
</View>
)}
</List>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/main/Manage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Index = () => {
<ViewComponent setCurrentTab={setTab} />
</View>
</View>
<Watermark opacity={0.7} fullPage gapX={30} gapY={30} content='HXTIA' />
<Watermark opacity={0.7} fullPage gapX={20} gapY={20} content='华信' />
</View>
)
}
Expand Down
6 changes: 5 additions & 1 deletion src/utils/request/business.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ export const request = <T, U extends string | TGeneralObject>(
return new Promise(async (resolve) => {
let resInstance
try {
const _params = Object.assign({}, params, { data: {
...(params.data ?? {}) as any,
collegeId: getStorage('userInfo')?.collegeId ?? -1
} })
const result = await baseRequest<T, U>({
...baseExtraConfig,
...params,
..._params,
header: {
WXToken: getStorage('userInfo')?.token,
...params.header,
Expand Down
2 changes: 2 additions & 0 deletions src/utils/request/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const enum STATUS_CODE {
NO_LOGIN = 60001,
/** 服务器异常 */
SERVER_FAIL = 500,
/** 不存在的授权码 */
NO_CODE_EXIST = 600010
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/utils/request/exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,25 @@ const handle_system_error_exception = (resWrap: ResultWrap<any>) => {
})
}

/** 处理没有授权码 */
const handle_no_exist_code_error_exception = () => {
showToast({
title: '错误的授权码',
icon: 'none',
duration: 3000,
})
}

export default {
handle_no_login_error_exception,
handle_system_error_exception,
handle_no_exist_code_error_exception
}

/** 响应码对应的异常处理 */
export const EXCEPTION_HANDLE = {
[STATUS_CODE.FAIL]: 'pass_error',
[STATUS_CODE.NO_LOGIN]: 'no_login_error',
[STATUS_CODE.SERVER_FAIL]: 'server_error',
[STATUS_CODE.NO_CODE_EXIST]: 'no_exist_code_error'
}

0 comments on commit 07c8e0a

Please sign in to comment.