🐞 fix(购物车蒙版问题修复):
This commit is contained in:
@@ -56,13 +56,14 @@ export interface StateType {
|
||||
}
|
||||
sale_mode?: saleModeType
|
||||
checkList?: { [key in number]: boolean }
|
||||
recommendSubmitStatus?: boolean
|
||||
recommendId?: number
|
||||
|
||||
}
|
||||
|
||||
export interface ActionsMap {
|
||||
setInitData: StateType
|
||||
updateProduct: StateType
|
||||
setRecommendSubmit: StateType
|
||||
setRecommendId: StateType
|
||||
}
|
||||
|
||||
export type Actions = {
|
||||
@@ -83,7 +84,6 @@ function createCtx<A extends {} | null>() {
|
||||
}
|
||||
export const [useCurrenShop, CurrentProvider] = createCtx<params>()
|
||||
|
||||
// https://dev.to/elisealcala/react-context-with-usereducer-and-typescript-4obm
|
||||
export default (props: PropsType) => {
|
||||
const initialState = {
|
||||
list: [],
|
||||
@@ -94,7 +94,8 @@ export default (props: PropsType) => {
|
||||
length_number: 0,
|
||||
price_number: 0,
|
||||
},
|
||||
recommendSubmitStatus: false,
|
||||
recommendId: 0,
|
||||
|
||||
}
|
||||
function reducer(state: StateType, action: Actions) {
|
||||
switch (action.type) {
|
||||
@@ -102,8 +103,8 @@ export default (props: PropsType) => {
|
||||
return onInitData(state, action)
|
||||
case 'updateProduct':
|
||||
return onUpdateData(state, action)
|
||||
case 'setRecommendSubmit':
|
||||
return { ...state, recommendSubmitStatus: action.data.recommendSubmitStatus }
|
||||
case 'setRecommendId':
|
||||
return { ...state, recommendId: action.data.recommendId }
|
||||
default:
|
||||
return state
|
||||
}
|
||||
@@ -126,7 +127,7 @@ const onInitData = (state: StateType, action: Actions) => {
|
||||
citem.checked = false
|
||||
})
|
||||
})
|
||||
return { ...state, list: data.list, sale_mode: data.sale_mode, recommendSubmitStatus: data.recommendSubmitStatus, statistics }
|
||||
return { ...state, list: data.list, sale_mode: data.sale_mode, recommendId: data.recommendId, statistics }
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
|
||||
Reference in New Issue
Block a user