✨ feat:首页大概

This commit is contained in:
Haiyi
2022-08-24 17:58:37 +08:00
parent 9bb3690a63
commit c30960b7ec
6 changed files with 178 additions and 14 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ import { useDispatch } from 'react-redux'
import { SET_SHOPCOUNT, CLEAR_SHOPCOUNT } from '@/constants/common'
import { DataParam } from '@/reducers/commonData'
import { useCallback, useState } from 'react'
import { GetShoppingCartApi } from '@/api/shopCart'
// import { GetShoppingCartApi } from '@/api/shopCart'
import { useSelector } from '@/reducers/hooks'
export default () => {
const commonData = useSelector((state) => state.commonData)
@@ -16,10 +16,10 @@ export default () => {
dispatch({ type: CLEAR_SHOPCOUNT })
}
const { fetchData: fetchDataShopCount } = GetShoppingCartApi()
// const { fetchData: fetchDataShopCount } = GetShoppingCartApi()
const getShopCount = async () => {
//获取购物车数据数量
const { data } = await fetchDataShopCount()
// const { data } = await fetchDataShopCount()
let color_list = data.color_list || []
setShopCount(color_list.length)
}
+6 -6
View File
@@ -145,18 +145,18 @@ export const useRequest = (
...options,
...{
header: {
Platform: 6,
Platform: 3,
Appid: WX_APPID,
Authorization: token || stateRef.current.token,
},
},
...(options.method?.toUpperCase() == 'GET'
? {
data: stateRef.current.query,
}
data: stateRef.current.query,
}
: {
data: options.type?.toUpperCase() == 'FORMDATA' ? qs.stringify(stateRef.current.query) : stateRef.current.query,
}),
data: options.type?.toUpperCase() == 'FORMDATA' ? qs.stringify(stateRef.current.query) : stateRef.current.query,
}),
}
const result = await Taro.request(q as any)
const { statusCode } = result
@@ -178,7 +178,7 @@ export const useRequest = (
} else {
if (statusCode === 401) {
removeToken()
removeSessionKey()
// removeSessionKey()
removeUserInfo()
login()
} else {
+1 -1
View File
@@ -26,7 +26,7 @@ export default () => {
const q = {
url: BASE_URL + '/v1/mall/login',
header: {
"Platform": 6,
"Platform": 3,
"Appid": WX_APPID,
},
method: 'post',