订单列表对接
This commit is contained in:
+8
-2
@@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
import Taro, { useRouter } from '@tarojs/taro'
|
||||
import { useRef, useState } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import {BASE_URL, WX_APPID} from '@/common/constant'
|
||||
import useUserInfo from "./useUserInfo"
|
||||
import qs from 'qs';
|
||||
@@ -122,10 +122,15 @@ export const useRequest = (options:option = {
|
||||
const stateRef = useRef({...params})
|
||||
const [state, setState] = useState({...stateRef.current})
|
||||
const {removeToken, removeSessionKey} = useUserInfo()
|
||||
|
||||
useEffect(() => {
|
||||
console.log('变化::', state.loading)
|
||||
}, [state.loading])
|
||||
// 请求函数
|
||||
const fetchData = async (sub_options?:any) => {
|
||||
stateRef.current.loading = true
|
||||
setState((e) => ({...e, loading:true}))
|
||||
console.log('tf:::', stateRef.current.loading)
|
||||
stateRef.current.query = {
|
||||
...sub_options,
|
||||
...options.pagination && {
|
||||
@@ -153,6 +158,7 @@ export const useRequest = (options:option = {
|
||||
}
|
||||
}
|
||||
const result = await Taro.request(q as any)
|
||||
|
||||
const { statusCode } = result
|
||||
const {
|
||||
code,
|
||||
@@ -189,7 +195,7 @@ export const useRequest = (options:option = {
|
||||
}
|
||||
stateRef.current.error = false
|
||||
stateRef.current.loading = false
|
||||
setState(() => stateRef.current)
|
||||
setState(() => ({...stateRef.current}))
|
||||
return stateRef.current
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user