Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
best-code
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
等吃饭
best-code
Commits
cc82f5a5
Commit
cc82f5a5
authored
Mar 20, 2023
by
Friends233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页store
parent
4a9d56e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
5 deletions
+42
-5
custom.js
src/store/custom.js
+22
-0
constants.js
src/utils/constants.js
+2
-1
utils.js
src/utils/utils.js
+18
-4
No files found.
src/store/custom.js
0 → 100644
View file @
cc82f5a5
import
API
from
"@src/api"
import
{
addLoading
}
from
"@src/utils/utils"
export
default
{
/** 首页数据 */
homeInfo
:{},
/** 设置首页数据 */
setHomeInfo
(
data
){
this
.
homeInfo
=
data
},
/** 获取首页数据 */
async
getHomeInfo
(){
addLoading
(
async
()
=>
{
const
res
=
await
API
.
homeInfo
()
if
(
res
&&
res
.
success
)
{
this
.
setHomeInfo
(
res
.
data
)
}
})
}
}
\ No newline at end of file
src/utils/constants.js
View file @
cc82f5a5
/*
/*
* @Author: super
* @Author: super
* @Date: 2021-01-20 14:08:27
* @Date: 2021-01-20 14:08:27
* @LastEditTime: 2023-0
2-01 15:35:57
* @LastEditTime: 2023-0
3-20 11:26:25
* @LastEditors: Please set LastEditors
* @LastEditors: Please set LastEditors
* @Description:
* @Description:
*/
*/
...
@@ -16,6 +16,7 @@ export const MODAL_INDEX = {
...
@@ -16,6 +16,7 @@ export const MODAL_INDEX = {
*/
*/
export
function
ERROR_MESSAGE
(
errorCode
)
{
export
function
ERROR_MESSAGE
(
errorCode
)
{
let
message
=
""
;
let
message
=
""
;
errorCode
=
Number
(
errorCode
)
switch
(
errorCode
)
{
switch
(
errorCode
)
{
// case 999101:
// case 999101:
// message = "登录已过期";
// message = "登录已过期";
...
...
src/utils/utils.js
View file @
cc82f5a5
/*
/*
* @Author: all
* @Author: all
* @Date: 2021-11-01 09:30:00
* @Date: 2021-11-01 09:30:00
* @LastEditTime: 202
1-11-02 18:30:00
* @LastEditTime: 202
3-03-20 11:25:59
* @LastEditors:
all
* @LastEditors:
Please set LastEditors
* @Description:
* @Description:
*/
*/
import
{
Toast
}
from
"@spark/ui"
;
import
{
hideLoading
,
showLoading
,
Toast
}
from
"@spark/ui"
;
import
{
ERROR_MESSAGE
}
from
"./constants"
import
{
ERROR_MESSAGE
}
from
"./constants"
import
{
useRef
,
useEffect
,
useCallback
}
from
"react"
;
import
{
useRef
,
useEffect
,
useCallback
}
from
"react"
;
...
@@ -37,7 +37,7 @@ export {
...
@@ -37,7 +37,7 @@ export {
*/
*/
/** */
/** */
function
showToast
(
errCode
,
message
)
{
function
showToast
(
errCode
,
message
)
{
Toast
(
ERROR_MESSAGE
[
errCode
]
||
message
||
"网络异常,请稍后再试~"
,
2000
,
{
hideOthers
:
true
});
Toast
(
ERROR_MESSAGE
(
errCode
)
||
message
||
"网络异常,请稍后再试~"
,
2000
,
{
hideOthers
:
true
});
}
}
/**
/**
...
@@ -379,4 +379,18 @@ const onCtrScroll = (flag = true) => {
...
@@ -379,4 +379,18 @@ const onCtrScroll = (flag = true) => {
}
else
{
// 开启滚动
}
else
{
// 开启滚动
document
.
body
.
removeEventListener
(
'touchmove'
,
bodyScroll
,
{
passive
:
false
});
document
.
body
.
removeEventListener
(
'touchmove'
,
bodyScroll
,
{
passive
:
false
});
}
}
}
/** 添加一个loading */
export
const
addLoading
=
async
(
fn
)
=>
{
let
res
=
null
try
{
showLoading
()
res
=
await
fn
()
}
catch
(
err
)
{
showToast
(
err
.
code
,
err
.
message
)
}
finally
{
hideLoading
()
}
return
Promise
.
resolve
(
res
)
}
}
\ No newline at end of file
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