商城测试版v8_1

This commit is contained in:
2022-07-30 17:11:42 +08:00
parent e2b0b0c52b
commit 09e34ecabe
39 changed files with 3360 additions and 3274 deletions
+26 -26
View File
@@ -1,33 +1,33 @@
import { useDispatch } from 'react-redux'
import {SET_SHOPCOUNT, CLEAR_SHOPCOUNT} from '@/constants/common'
import {DataParam} from '@/reducers/commonData'
import { SET_SHOPCOUNT, CLEAR_SHOPCOUNT } from '@/constants/common'
import { DataParam } from '@/reducers/commonData'
import { useCallback, useState } from 'react'
import { GetShoppingCartApi } from '@/api/shopCart'
import { useSelector } from '@/reducers/hooks'
export default () => {
const commonData = useSelector(state => state.commonData)
const dispatch = useDispatch()
const setShopCount = (shopCount: number) => {
dispatch({type:SET_SHOPCOUNT, data:{shopCount}})
}
const commonData = useSelector((state) => state.commonData)
const dispatch = useDispatch()
const removeShopCount = () => {
dispatch({type:CLEAR_SHOPCOUNT})
}
const setShopCount = (shopCount: number) => {
dispatch({ type: SET_SHOPCOUNT, data: { shopCount } })
}
const {fetchData: fetchDataShopCount} = GetShoppingCartApi()
const getShopCount = async () => {
//获取购物车数据数量
const {data} = await fetchDataShopCount()
let color_list = data.color_list||[]
setShopCount(color_list.length)
}
return {
setShopCount,
removeShopCount,
getShopCount,
commonData
}
}
const removeShopCount = () => {
dispatch({ type: CLEAR_SHOPCOUNT })
}
const { fetchData: fetchDataShopCount } = GetShoppingCartApi()
const getShopCount = async () => {
//获取购物车数据数量
const { data } = await fetchDataShopCount()
let color_list = data.color_list || []
setShopCount(color_list.length)
}
return {
setShopCount,
removeShopCount,
getShopCount,
commonData,
}
}