封装请求hook
This commit is contained in:
parent
f326656ed7
commit
050f90433c
27
src/common/constant.js
Normal file
27
src/common/constant.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
console.log('环境变量2',CURRENT_ENV);
|
||||||
|
// export const BASE_URL = CURRENT_ENV.includes('development') ? `https://test.zzfzyc.com/lymarket` : `https://www.zzfzyc.com/lymarket`
|
||||||
|
// export const BASE_URL = `http://192.168.0.75:50001/lymarket`
|
||||||
|
// export const BASE_URL = `http://192.168.0.89:50001/lymarket`
|
||||||
|
// export const BASE_URL = `http://10.0.0.5:50001/lymarket`
|
||||||
|
// export const BASE_URL = `http://192.168.0.89:40001/lymarket`
|
||||||
|
// export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞
|
||||||
|
// export const BASE_URL = `https://test.zzfzyc.com/lymarket` // 测试环境
|
||||||
|
export const BASE_URL = `http://192.168.1.30:40001/lymarket` // 发
|
||||||
|
// export const BASE_URL = `https://dev.zzfzyc.com/lymarket` // 开发环境
|
||||||
|
// export const BASE_URL = `https://www.zzfzyc.com/lymarket` // 正式环境
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞
|
||||||
|
|
||||||
|
// CDN
|
||||||
|
// 生成密钥
|
||||||
|
export const GET_UPLOAD_SIGN = `/upyun/getsign` // 请求签名 url
|
||||||
|
export const UPLOAD_CDN_URL = `https://v0.api.upyun.com/`
|
||||||
|
|
||||||
|
// 前缀
|
||||||
|
export const IMG_CND_Prefix = "http://test.cdn.zzfzyc.com/"
|
||||||
|
|
||||||
|
|
||||||
|
// 上传图片视频
|
||||||
|
export const CDN_UPLOAD_IMG = `${UPLOAD_CDN_URL || ''}`;
|
@ -75,7 +75,7 @@ export default memo(({
|
|||||||
onRefresherRefresh = {() => refresherRefresh()}
|
onRefresherRefresh = {() => refresherRefresh()}
|
||||||
onRefresherRestore = {() => refresherRestore()}
|
onRefresherRestore = {() => refresherRestore()}
|
||||||
onRefresherAbort = {() => refresherAbort()}
|
onRefresherAbort = {() => refresherAbort()}
|
||||||
refresherBackground ='#ccc'
|
refresherBackground ='#F8F8F8'
|
||||||
>
|
>
|
||||||
<View style={{paddingBottom:paddingBottom + 'rpx'}}>
|
<View style={{paddingBottom:paddingBottom + 'rpx'}}>
|
||||||
{children}
|
{children}
|
||||||
|
@ -112,7 +112,7 @@ export default ({show = false, onClose}: param) => {
|
|||||||
</View>
|
</View>
|
||||||
<View className={styles.con}>
|
<View className={styles.con}>
|
||||||
{loading&&<LoadingCard/>}
|
{loading&&<LoadingCard/>}
|
||||||
{!loading&&list.length > 0&&<InfiniteScroll selfonScrollToLower={() => {console.log('触底了')}} paddingBottom={100}>
|
{!loading&&list.length > 0&&<InfiniteScroll refresherTriggered={true} refresherEnabled={true} selfonScrollToLower={() => {console.log('触底了')}} paddingBottom={100}>
|
||||||
<View className={styles.product_list}>
|
<View className={styles.product_list}>
|
||||||
{list.map((item, index) => {
|
{list.map((item, index) => {
|
||||||
return <View key={index} className={styles.product_item}>
|
return <View key={index} className={styles.product_item}>
|
||||||
@ -124,7 +124,7 @@ export default ({show = false, onClose}: param) => {
|
|||||||
</View>
|
</View>
|
||||||
<View className={styles.des}>
|
<View className={styles.des}>
|
||||||
<View className={styles.title}>{item.title}</View>
|
<View className={styles.title}>{item.title}</View>
|
||||||
<View className={styles.subtitle}>0770# 21S单面平纹(食毛)</View>
|
<View className={styles.subtitle}>07703# 21S单面平纹(食毛)</View>
|
||||||
<View className={styles.tag}>剪板</View>
|
<View className={styles.tag}>剪板</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.count}>
|
<View className={styles.count}>
|
||||||
|
@ -16,10 +16,20 @@ type Params = {
|
|||||||
children?: ReactNode,
|
children?: ReactNode,
|
||||||
height?: string,
|
height?: string,
|
||||||
heightItem?: number,
|
heightItem?: number,
|
||||||
sideBarOnClick?: (ListProps) => void
|
sideBarOnClick?: (ListProps) => void,
|
||||||
|
refresherTriggered?: true|false,
|
||||||
|
selfOnRefresherRefresh?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo(({list = [], defaultValue = 0, height='100vh', sideBarOnClick, children, heightItem = 100}: Params) => {
|
export default memo(({list = [],
|
||||||
|
defaultValue = 0,
|
||||||
|
height='100vh',
|
||||||
|
sideBarOnClick,
|
||||||
|
children,
|
||||||
|
heightItem = 100,
|
||||||
|
refresherTriggered = false,
|
||||||
|
selfOnRefresherRefresh
|
||||||
|
}: Params) => {
|
||||||
|
|
||||||
let num_half = useRef(0)
|
let num_half = useRef(0)
|
||||||
|
|
||||||
@ -94,7 +104,7 @@ export default memo(({list = [], defaultValue = 0, height='100vh', sideBarOnClic
|
|||||||
<View className="common_safe_area_y"></View>
|
<View className="common_safe_area_y"></View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<View className={styles.sideBar_con}>
|
<View className={styles.sideBar_con}>
|
||||||
<InfiniteScroll selfonScrollToLower={() => onScrolltolower()}>
|
<InfiniteScroll selfonScrollToLower={() => onScrolltolower()} refresherTriggered={refresherTriggered} refresherEnabled={true} selfOnRefresherRefresh={() => selfOnRefresherRefresh?.()}>
|
||||||
{children}
|
{children}
|
||||||
</InfiniteScroll>
|
</InfiniteScroll>
|
||||||
</View>
|
</View>
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
navigationBarTitleText: '详情'
|
navigationBarTitleText: '详情',
|
||||||
|
enablePullDownRefresh: true,
|
||||||
|
backgroundTextStyle: 'dark'
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
import { Image, RichText, Swiper, SwiperItem, View } from '@tarojs/components'
|
import { Button, Image, RichText, Swiper, SwiperItem, View } from '@tarojs/components'
|
||||||
import Taro from '@tarojs/taro';
|
import Taro, { useShareAppMessage } from '@tarojs/taro';
|
||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
import DesSwiper from './components/swiper';
|
import DesSwiper from './components/swiper';
|
||||||
import OrderCount from './components/orderCount';
|
import OrderCount from './components/orderCount';
|
||||||
@ -8,6 +8,7 @@ import ShopCart from '@/components/shopCart';
|
|||||||
import Preview,{colorItem} from './components/preview';
|
import Preview,{colorItem} from './components/preview';
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
|
import useManualPullDownRefresh from '@/use/useManualPullDownRefresh';
|
||||||
type item = {title:string, img:string, url:string, id:number}
|
type item = {title:string, img:string, url:string, id:number}
|
||||||
|
|
||||||
type params = {
|
type params = {
|
||||||
@ -17,6 +18,9 @@ type params = {
|
|||||||
}
|
}
|
||||||
export default (props:params) => {
|
export default (props:params) => {
|
||||||
|
|
||||||
|
//页面下拉刷新
|
||||||
|
const res = useManualPullDownRefresh()
|
||||||
|
|
||||||
const list = [
|
const list = [
|
||||||
{
|
{
|
||||||
title:'数据',
|
title:'数据',
|
||||||
@ -80,6 +84,19 @@ export default (props:params) => {
|
|||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useShareAppMessage(res => {
|
||||||
|
if (res.from === 'button') {
|
||||||
|
// 来自页面内转发按钮
|
||||||
|
console.log(res.target)
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
title: '自定义转发标题',
|
||||||
|
path: '/page/user?id=123'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={styles.main}>
|
<View className={styles.main}>
|
||||||
<DesSwiper list={list}/>
|
<DesSwiper list={list}/>
|
||||||
@ -91,10 +108,12 @@ export default (props:params) => {
|
|||||||
<View className={styles.share}>
|
<View className={styles.share}>
|
||||||
<View className={classnames('iconfont icon-fenxiang', styles.miconfont)}></View>
|
<View className={classnames('iconfont icon-fenxiang', styles.miconfont)}></View>
|
||||||
<View className={styles.text}>分享</View>
|
<View className={styles.text}>分享</View>
|
||||||
|
<Button open-type="share">转发</Button>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.collect}>
|
<View className={styles.collect}>
|
||||||
<View className={classnames('iconfont icon-shoucang', styles.miconfont, collectStatus&&styles.collected)} onClick={() => changeCollect()}></View>
|
<View className={classnames('iconfont icon-shoucang', styles.miconfont, collectStatus&&styles.collected)} onClick={() => changeCollect()}></View>
|
||||||
<View className={styles.text}>收藏</View>
|
<View className={styles.text}>收藏</View>
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.des_data}>
|
<View className={styles.des_data}>
|
||||||
|
@ -35,7 +35,17 @@ export default () => {
|
|||||||
|
|
||||||
const [showShopCart, setShowShopCart] = useState(false)
|
const [showShopCart, setShowShopCart] = useState(false)
|
||||||
|
|
||||||
const res = useManualPullDownRefresh(() => {return '99999'})
|
//页面下拉刷新
|
||||||
|
const res = useManualPullDownRefresh()
|
||||||
|
|
||||||
|
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||||
|
const getData = () => {
|
||||||
|
setRefresherTriggeredStatus(true)
|
||||||
|
setTimeout(() => {
|
||||||
|
setRefresherTriggeredStatus(() => false)
|
||||||
|
console.log('12123')
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MoveBtn onClick={() => setShowShopCart(!showShopCart)}>
|
<MoveBtn onClick={() => setShowShopCart(!showShopCart)}>
|
||||||
@ -48,7 +58,7 @@ export default () => {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.products}>
|
<View className={styles.products}>
|
||||||
<SideBar list={tabs_list} height="100%" heightItem={150}>
|
<SideBar list={tabs_list} height="100%" heightItem={150} refresherTriggered={refresherTriggeredStatus} selfOnRefresherRefresh={() => getData()}>
|
||||||
<Product/>
|
<Product/>
|
||||||
</SideBar>
|
</SideBar>
|
||||||
</View>
|
</View>
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
navigationBarTitleText: '搜索'
|
navigationBarTitleText: '搜索',
|
||||||
|
enablePullDownRefresh: true,
|
||||||
|
backgroundTextStyle: 'dark'
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import Tabs from "@/components/tabs";
|
|||||||
import styles from './hightSearchList.module.scss'
|
import styles from './hightSearchList.module.scss'
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import Taro, { useReady } from "@tarojs/taro";
|
import Taro, { useReady } from "@tarojs/taro";
|
||||||
|
import useManualPullDownRefresh from "@/use/useManualPullDownRefresh";
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const [showFilter, setShowFilter] = useState(false)
|
const [showFilter, setShowFilter] = useState(false)
|
||||||
@ -55,6 +56,9 @@ export default () => {
|
|||||||
setBlueToothColor(`rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`)
|
setBlueToothColor(`rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`)
|
||||||
}
|
}
|
||||||
}, [state.deviceLab])
|
}, [state.deviceLab])
|
||||||
|
|
||||||
|
//页面下拉刷新
|
||||||
|
const res = useManualPullDownRefresh()
|
||||||
return (
|
return (
|
||||||
<View className={styles.main}>
|
<View className={styles.main}>
|
||||||
<View className={styles.search}>
|
<View className={styles.search}>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
export default {
|
export default {
|
||||||
navigationBarTitleText: '搜索'
|
navigationBarTitleText: '搜索',
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
navigationBarTitleText: '高级搜索'
|
navigationBarTitleText: '高级搜索',
|
||||||
|
enablePullDownRefresh: true,
|
||||||
|
backgroundTextStyle: 'dark'
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import SelectData from "./components/selectData";
|
|||||||
import { goLink } from "@/common/common";
|
import { goLink } from "@/common/common";
|
||||||
import styles from './searchList.module.scss'
|
import styles from './searchList.module.scss'
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
|
import useManualPullDownRefresh from "@/use/useManualPullDownRefresh";
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const [showFilter, setShowFilter] = useState(false)
|
const [showFilter, setShowFilter] = useState(false)
|
||||||
@ -30,6 +31,9 @@ export default () => {
|
|||||||
setScrollStatus(false)
|
setScrollStatus(false)
|
||||||
}
|
}
|
||||||
},[])
|
},[])
|
||||||
|
|
||||||
|
//页面下拉刷新
|
||||||
|
const res = useManualPullDownRefresh()
|
||||||
return (
|
return (
|
||||||
<View className={styles.main}>
|
<View className={styles.main}>
|
||||||
<View className={styles.search}>
|
<View className={styles.search}>
|
||||||
|
@ -1,54 +1,75 @@
|
|||||||
|
|
||||||
|
|
||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
import { useState } from 'react'
|
import { useRef, useState } from 'react'
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
/**
|
|
||||||
* 返回状态信息,根据 http 状态错
|
|
||||||
* @param {Number} status
|
|
||||||
* @returns
|
type Params = {
|
||||||
*/
|
code: string|null
|
||||||
const showStatus = (status) => {
|
success: true|false
|
||||||
let message = ''
|
data: any,
|
||||||
switch (status) {
|
msg: string,
|
||||||
case 400:
|
loading: true|false,
|
||||||
message = '请求错误(400)'
|
error: any,
|
||||||
break
|
query: any,
|
||||||
case 401:
|
filter: any,
|
||||||
message = '未授权,请重新登录(401)'
|
sort: any,
|
||||||
break
|
total: number,
|
||||||
case 403:
|
multiple: true|false, // 请求多次
|
||||||
message = '拒绝访问(403)'
|
count: number, // 第几次请求
|
||||||
break
|
token: string, // token
|
||||||
case 404:
|
page?: number,
|
||||||
message = '请求出错(404)'
|
pageSize?: number
|
||||||
break
|
}
|
||||||
case 408:
|
|
||||||
message = '请求超时(408)'
|
/**
|
||||||
break
|
* 返回状态信息,根据 http 状态错
|
||||||
case 500:
|
* @param {Number} status
|
||||||
message = '服务器错误(500)'
|
* @returns
|
||||||
break
|
*/
|
||||||
case 501:
|
const showStatus = (status) => {
|
||||||
message = '服务未实现(501)'
|
let message = ''
|
||||||
break
|
switch (status) {
|
||||||
case 502:
|
case 400:
|
||||||
message = '网络错误(502)'
|
message = '请求错误(400)'
|
||||||
break
|
break
|
||||||
case 503:
|
case 401:
|
||||||
message = '服务不可用(503)'
|
message = '未授权,请重新登录(401)'
|
||||||
break
|
break
|
||||||
case 504:
|
case 403:
|
||||||
message = '网络超时(504)'
|
message = '拒绝访问(403)'
|
||||||
break
|
break
|
||||||
case 505:
|
case 404:
|
||||||
message = 'HTTP版本不受支持(505)'
|
message = '请求出错(404)'
|
||||||
break
|
break
|
||||||
default:
|
case 408:
|
||||||
message = `连接出错(${status})!`
|
message = '请求超时(408)'
|
||||||
}
|
break
|
||||||
return `${message},请检查网络或联系管理员!`
|
case 500:
|
||||||
|
message = '服务器错误(500)'
|
||||||
|
break
|
||||||
|
case 501:
|
||||||
|
message = '服务未实现(501)'
|
||||||
|
break
|
||||||
|
case 502:
|
||||||
|
message = '网络错误(502)'
|
||||||
|
break
|
||||||
|
case 503:
|
||||||
|
message = '服务不可用(503)'
|
||||||
|
break
|
||||||
|
case 504:
|
||||||
|
message = '网络超时(504)'
|
||||||
|
break
|
||||||
|
case 505:
|
||||||
|
message = 'HTTP版本不受支持(505)'
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
message = `连接出错(${status})!`
|
||||||
}
|
}
|
||||||
|
return `${message},请检查网络或联系管理员!`
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,28 +90,25 @@ export const useRequest = (options = {
|
|||||||
pagination: false, // 是否分页
|
pagination: false, // 是否分页
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
let params:any = {
|
|
||||||
|
let params:Params = {
|
||||||
code: null, // 业务码
|
code: null, // 业务码
|
||||||
success: null, // 请求是否成功
|
success: false, // 请求是否成功
|
||||||
data: {},
|
data: {},
|
||||||
msg: '',
|
msg: '',
|
||||||
loading: null,
|
loading: false,
|
||||||
error: null,
|
error: null,
|
||||||
query: {},
|
query: {},
|
||||||
filter: null,
|
filter: null,
|
||||||
sort: null,
|
sort: '',
|
||||||
total: 0,
|
total: 0,
|
||||||
multiple: true, // 请求多次
|
multiple: true, // 请求多次
|
||||||
count: 0, // 第几次请求
|
count: 0, // 第几次请求
|
||||||
token: '', // token
|
token: '', // token
|
||||||
}
|
}
|
||||||
|
|
||||||
if(options.pagination) {
|
const stateRef = useRef({...params})
|
||||||
params.page = options.page
|
const [state, setState] = useState({...stateRef.current})
|
||||||
params.pageSize = options.pageSize
|
|
||||||
}
|
|
||||||
|
|
||||||
const [state, setState] = useState({...params})
|
|
||||||
|
|
||||||
// // 每页多少条记录
|
// // 每页多少条记录
|
||||||
// const handleSizeChange = (val) => {
|
// const handleSizeChange = (val) => {
|
||||||
@ -120,7 +138,7 @@ export const useRequest = (options = {
|
|||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
const handleSort = (val, orderby = "desc") => {
|
const handleSort = (val, orderby = "desc") => {
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
state.sort = orderby ? {
|
stateRef.current.sort = orderby ? {
|
||||||
sort_key: `${orderby == 'desc' ? '-' + val : val}`
|
sort_key: `${orderby == 'desc' ? '-' + val : val}`
|
||||||
} : null
|
} : null
|
||||||
}
|
}
|
||||||
@ -129,16 +147,16 @@ export const useRequest = (options = {
|
|||||||
|
|
||||||
// 请求函数
|
// 请求函数
|
||||||
const fetchData = async (sub_options) => {
|
const fetchData = async (sub_options) => {
|
||||||
state.loading = true
|
stateRef.current.loading = true
|
||||||
|
setState((e) => ({...e, loading:true}))
|
||||||
state.query = {
|
stateRef.current.query = {
|
||||||
...sub_options,
|
...sub_options,
|
||||||
...options.pagination && {
|
...options.pagination && {
|
||||||
page: state.page,
|
page: stateRef.current.page,
|
||||||
size: state.size,
|
size: stateRef.current.pageSize,
|
||||||
},
|
},
|
||||||
...state.filter,
|
...stateRef.current.filter,
|
||||||
...state.sort
|
...stateRef.current.sort
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let token = Taro.getStorageSync('token')
|
let token = Taro.getStorageSync('token')
|
||||||
@ -147,13 +165,13 @@ export const useRequest = (options = {
|
|||||||
...{
|
...{
|
||||||
header: {
|
header: {
|
||||||
"Platform": 3,
|
"Platform": 3,
|
||||||
"Authorization": token || state.token,
|
"Authorization": token || stateRef.current.token,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
...options.method?.toUpperCase() == 'GET' ? {
|
...options.method?.toUpperCase() == 'GET' ? {
|
||||||
data: state.query
|
data: stateRef.current.query
|
||||||
} : {
|
} : {
|
||||||
data: options.type?.toUpperCase() == 'FORMDATA' ? qs.stringify(state.query) : state.query
|
data: options.type?.toUpperCase() == 'FORMDATA' ? qs.stringify(stateRef.current.query) : stateRef.current.query
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const result = await Taro.request(q as any)
|
const result = await Taro.request(q as any)
|
||||||
@ -165,11 +183,11 @@ export const useRequest = (options = {
|
|||||||
} = result.data
|
} = result.data
|
||||||
console.log(code, msg, data, statusCode);
|
console.log(code, msg, data, statusCode);
|
||||||
if (statusCode === 200) {
|
if (statusCode === 200) {
|
||||||
state.success = (code === 0 ? true : false)
|
stateRef.current.success = (code === 0 ? true : false)
|
||||||
state.code = code
|
stateRef.current.code = code
|
||||||
state.msg = msg
|
stateRef.current.msg = msg
|
||||||
state.data = data
|
stateRef.current.data = data
|
||||||
state.total = data?.list ? data?.total : 0
|
stateRef.current.total = data?.list ? data?.total : 0
|
||||||
}else{
|
}else{
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: `错误:${showStatus(statusCode)}`
|
title: `错误:${showStatus(statusCode)}`
|
||||||
@ -183,22 +201,20 @@ export const useRequest = (options = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('出错', e);
|
stateRef.current.success = false
|
||||||
state.success = false
|
stateRef.current.error = true
|
||||||
state.error = true
|
stateRef.current.msg = e.errMsg
|
||||||
state.msg = e.errMsg
|
|
||||||
|
|
||||||
}
|
}
|
||||||
state.error = false
|
stateRef.current.error = false
|
||||||
state.loading = false
|
stateRef.current.loading = false
|
||||||
|
setState(() => stateRef.current)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// handleSizeChange,
|
|
||||||
// handleCurrentChange,
|
|
||||||
// handleFilterChange,
|
|
||||||
handleSort,
|
handleSort,
|
||||||
fetchData,
|
fetchData,
|
||||||
|
state,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user