商城测试版v7

This commit is contained in:
2022-07-22 20:46:40 +08:00
parent c646bac0a4
commit c4684c11b8
19 changed files with 142 additions and 130 deletions
+6 -5
View File
@@ -35,7 +35,8 @@ type option = {
page?: number,
pageSize?: number,
pagination?: true|false,
base_url?: string
base_url?: string,
apiMsgStatus?: true|false
}
/**
@@ -101,8 +102,10 @@ export const useRequest = (options:option = {
page: 1,
pageSize: 24,
pagination: false, // 是否分页
base_url: ''
base_url: '',
apiMsgStatus: true //是否直接弹出后端错误
}) => {
options.url = `${options.base_url||BASE_URL}${options.url}`
let params:Params = {
code: null, // 业务码
@@ -127,7 +130,6 @@ export const useRequest = (options:option = {
// 请求函数
const fetchData = async (sub_options?:any) => {
stateRef.current.loading = true
setState((e) => ({...e, loading:true}))
stateRef.current.query = {
@@ -170,7 +172,7 @@ export const useRequest = (options:option = {
stateRef.current.data = data
stateRef.current.total = data?.list ? data?.total : 0
if(code !== 0) {
Taro.showToast({
options.apiMsgStatus !== false &&Taro.showToast({
title: `${msg}`,
icon: 'none'
})
@@ -183,7 +185,6 @@ export const useRequest = (options:option = {
removeSessionKey()
removeUserInfo()
login()
//todo 登录数据刷新次数问题
} else {
Taro.showToast({
title: `错误:${showStatus(statusCode)}`,