Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
27fd8140
Commit
27fd8140
authored
Dec 10, 2020
by
zhangleyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:处理页面401和403的状况
parent
613f0595
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
29 deletions
+69
-29
src/common/js/axios.ts
+37
-18
src/modules/personalInfo/IdentificationModal.tsx
+1
-0
src/modules/root/App.tsx
+3
-2
src/modules/store-manage/CourseCatalogPage.tsx
+4
-1
src/modules/store-manage/modal/SecondCatalogAddOrEditModal.tsx
+24
-8
No files found.
src/common/js/axios.ts
View file @
27fd8140
...
...
@@ -2,7 +2,7 @@
* @Author: 吴文洁
* @Date: 2020-08-31 09:34:31
* @LastEditors: zhangleyuan
* @LastEditTime: 2020-12-22 15:2
3:36
* @LastEditTime: 2020-12-22 15:2
4:03
* @Description:
* @Copyright: 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -23,9 +23,13 @@ interface FetchParams {
interface
FetchOptions
{
requestType
:
string
// 请求类型 form为表单类型 json为json类型,默认json类型
}
interface
HeadersType
{
storeId
?:
any
,
storeUserId
?:
any
,
userId
?:
any
,
token
?:
any
}
class
Axios
{
static
post
(
method
:
string
,
url
:
string
,
...
...
@@ -34,15 +38,24 @@ class Axios {
):
Promise
<
any
>
{
const
_url
=
`
${
url
}
?storeId=
${
User
.
getStoreId
()}
&token=
${
User
.
getToken
()}
&storeUserId=
${
User
.
getStoreUserId
()}
&userId=
${
User
.
getUserId
()}
`
;
return
new
Promise
((
resolve
,
reject
)
=>
{
let
headerObject
:
HeadersType
=
{};
if
(
User
.
getStoreId
()){
headerObject
.
storeId
=
User
.
getStoreId
();
}
if
(
User
.
getStoreUserId
()){
headerObject
.
storeUserId
=
User
.
getStoreUserId
();
}
if
(
User
.
getUserId
()){
headerObject
.
userId
=
User
.
getUserId
();
}
if
(
User
.
getToken
()){
headerObject
.
token
=
User
.
getToken
();
}
const
instance
:
AxiosInstance
=
axios
.
create
({
timeout
:
TIME_OUT
,
responseType
:
'json'
,
headers
:
{
storeId
:
User
.
getStoreId
(),
storeUserId
:
User
.
getStoreUserId
(),
userId
:
User
.
getUserId
(),
token
:
User
.
getToken
(),
...
headerObject
,
product
:
"xmCloudClass"
,
'Content-Type'
:
options
.
requestType
===
'form'
?
'application/x-www-form-urlencoded'
:
'application/json; charset=UTF-8'
,
}
...
...
@@ -78,17 +91,23 @@ class Axios {
message
.
error
(
ResMessage
||
resultMsg
);
return
Promise
.
reject
(
response
.
data
);
},
(
error
):
AxiosPromise
=>
{
console
.
log
(
"error222"
,
error
)
// 403退出登录
if
(
error
.
message
.
indexOf
(
"403"
)){
window
.
RCHistory
.
replace
(
'/login'
);
const
requestStatus
=
error
.
request
.
status
switch
(
requestStatus
){
case
401
:
User
.
removeUserId
();
User
.
removeToken
();
message
.
error
(
'请登录'
);
window
.
RCHistory
.
replace
(
'/login'
);
break
;
case
403
:
message
.
error
(
'暂无查看权限'
);
window
.
RCHistory
.
replace
(
'/login'
);
return
Promise
.
reject
();
break
;
default
:
message
.
error
(
error
.
message
);
break
;
}
// if(error.request.status===403 || error.request.status===401){
// window.RCHistory.replace('/login');
// }else{
// }
message
.
error
(
error
.
message
)
return
Promise
.
reject
(
error
.
message
);
});
...
...
src/modules/personalInfo/IdentificationModal.tsx
View file @
27fd8140
...
...
@@ -103,6 +103,7 @@ function IdentificationModal(props: IdentificationModalProps) {
确认
</
Button
>
]
}
maskClosable=
{
false
}
>
<
div
className=
"desc"
>
为了你的账户安全,请验证身份。验证成功后进行下一步操作
</
div
>
...
...
src/modules/root/App.tsx
View file @
27fd8140
/*
* @Author: 吴文洁
* @Date: 2019-07-10 10:30:49
* @LastEditors:
wuf
an
* @LastEditTime: 2020-12-
09 16:50:18
* @LastEditors:
zhangleyu
an
* @LastEditTime: 2020-12-
22 15:24:20
* @Description:
*/
import
React
,
{
useContext
,
useEffect
,
useState
}
from
'react'
;
...
...
@@ -33,6 +33,7 @@ const App: React.FC = (props: any) => {
}
function
getStoreGroupAndStoreList
()
{
BaseService
.
getUserStore
({
userId
}).
then
((
res
)
=>
{
const
{
storeGroupVOS
=
[],
storeVOS
=
[]
}
=
res
.
result
;
...
...
src/modules/store-manage/CourseCatalogPage.tsx
View file @
27fd8140
...
...
@@ -36,6 +36,7 @@ function CourseCatalogPage() {
const
[
secondCatalogModalVisible
,
setSecondCatalogModalVisible
]
=
useState
(
false
);
const
[
secondCatalogModalType
,
setSecondCatalogModalType
]
=
useState
(
''
);
const
[
parentCatalogId
,
setParentCatalogId
]
=
useState
(
''
);
const
[
parentCatalogName
,
setParentCatalogName
]
=
useState
(
''
);
const
[
choosedItem
,
setChooseItem
]
=
useState
({});
useEffect
(()
=>
{
getCourseCatalogList
();
...
...
@@ -49,6 +50,7 @@ function CourseCatalogPage() {
function
addSecondCatalog
(
record
:
any
){
setChooseItem
({});
setParentCatalogId
(
record
.
id
);
setParentCatalogName
(
record
.
categoryName
);
setSecondCatalogModalVisible
(
true
);
setSecondCatalogModalType
(
'add'
);
}
...
...
@@ -150,6 +152,7 @@ function CourseCatalogPage() {
setCatalogModalVisible
(
true
);
}
else
{
setParentCatalogId
(
record
.
parentId
);
setParentCatalogName
(
record
.
parentName
);
setSecondCatalogModalType
(
'edit'
);
setSecondCatalogModalVisible
(
true
);
}
...
...
@@ -204,7 +207,7 @@ function CourseCatalogPage() {
catalogModalVisible
&&
<
CatalogAddOrEditModal
modalType=
{
catalogModalType
}
onClose=
{
()
=>
{
setCatalogModalVisible
(
false
)}
}
refreshCatalogList=
{
getCourseCatalogList
}
choosedItem=
{
choosedItem
}
/>
}
{
secondCatalogModalVisible
&&
<
SecondCatalogAddOrEditModal
modalType=
{
secondCatalogModalType
}
parentId=
{
parentCatalogId
}
onClose=
{
()
=>
{
setSecondCatalogModalVisible
(
false
)}
}
choosedItem=
{
choosedItem
}
refreshCatalogList=
{
getCourseCatalogList
}
/>
secondCatalogModalVisible
&&
<
SecondCatalogAddOrEditModal
modalType=
{
secondCatalogModalType
}
parentId=
{
parentCatalogId
}
parentName=
{
parentCatalogName
}
onClose=
{
()
=>
{
setSecondCatalogModalVisible
(
false
)}
}
choosedItem=
{
choosedItem
}
refreshCatalogList=
{
getCourseCatalogList
}
/>
}
</
div
>
</
div
>
...
...
src/modules/store-manage/modal/SecondCatalogAddOrEditModal.tsx
View file @
27fd8140
/*
* @Author: wufan
* @Date: 2020-11-27 16:21:49
* @LastEditors:
wuf
an
* @LastEditTime: 2020-12-
09 20:01:24
* @LastEditors:
zhangleyu
an
* @LastEditTime: 2020-12-
10 18:03:06
* @Description: Description
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -22,28 +22,43 @@ interface SecondCatalogAddOrEditModalProps {
parentId
:
string
;
choosedItem
:
any
;
refreshCatalogList
:
any
;
parentName
:
string
}
function
SecondCatalogAddOrEditModal
(
props
:
SecondCatalogAddOrEditModalProps
)
{
const
{
onClose
,
modalType
,
parentId
,
refreshCatalogList
,
choosedItem
}
=
props
;
const
{
onClose
,
modalType
,
parentId
,
refreshCatalogList
,
choosedItem
,
parentName
}
=
props
;
console
.
log
(
'choosedItem'
,
choosedItem
);
const
[
secondCatalogName
,
setSecondCatalogName
]
=
useState
(
choosedItem
.
categoryName
);
const
[
selectParentId
,
setSelectParentId
]
=
useState
(
parentId
);
const
[
optionList
,
setOptionList
]
=
useState
([]);
const
[
hasNext
,
setHasNext
]
=
useState
(
false
);
const
[
query
,
setQuery
]
=
useState
({
current
:
0
,
size
:
10
0
,
size
:
1
0
,
storeId
:
User
.
getStoreId
(),
});
useEffect
(()
=>
{
getOptionList
();
},[
query
]);
function
handleScroll
(
e
:
any
){
const
container
=
e
.
target
;
const
scrollToBottom
=
container
&&
container
.
scrollHeight
<=
container
.
clientHeight
+
container
.
scrollTop
;
if
(
scrollToBottom
&&
hasNext
)
{
let
_query
=
_
.
clone
(
query
);
_query
.
current
=
query
.
current
+
1
;
setQuery
(
_query
);
}
}
function
getOptionList
():
any
{
let
_query
=
_
.
clone
(
query
);
_query
.
current
=
query
.
current
+
1
;
StoreService
.
getCourseCatalogList
(
_query
).
then
((
res
:
any
)
=>
{
let
resultData
=
handleCatalogListData
(
res
.
result
.
records
)
setOptionList
(
resultData
);
let
resultData
=
handleCatalogListData
(
res
.
result
.
records
);
let
listData
:
any
=
[...
optionList
,...
resultData
]
setHasNext
(
res
.
result
.
hasNext
);
setOptionList
(
listData
);
});
}
function
handleCatalogListData
(
listData
:
any
){
...
...
@@ -53,7 +68,7 @@ function SecondCatalogAddOrEditModal(props: SecondCatalogAddOrEditModalProps) {
if
(
item
.
sonCategoryList
){
item
.
sonCategoryList
.
map
((
_item
:
any
,
_index
:
any
)
=>
{
_item
.
type
=
"child"
;
_item
.
key
=
_item
.
id
_item
.
key
=
"child"
+
_item
.
id
return
_item
});
}
...
...
@@ -142,7 +157,8 @@ function SecondCatalogAddOrEditModal(props: SecondCatalogAddOrEditModalProps) {
>
<
Select
style=
{
{
width
:
240
}
}
defaultValue=
{
parentId
}
defaultValue=
{
parentName
}
onPopupScroll=
{
handleScroll
}
onChange=
{
(
value
)
=>
{
setSelectParentId
(
String
(
value
))
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment