🐞 fix(ID1001599): 【内部小程序】-购物车提交订单后,预估金额没有更新
【【内部小程序】-购物车提交订单后,预估金额没有更新】 https://www.tapd.cn/53459131/bugtrace/bugs/view/1153459131001001599
This commit is contained in:
parent
fab0652997
commit
488fc66481
@ -417,8 +417,7 @@ const SearchPage = () => {
|
|||||||
return (
|
return (
|
||||||
<View className={styles.main}>
|
<View className={styles.main}>
|
||||||
<View className={styles.topBox}>
|
<View className={styles.topBox}>
|
||||||
<Search placeholder="请输入搜索布料" defaultValue={defaultvalue} showBtn={false} changeOnSearch={getSearchData} >
|
<Search placeholder="请输入搜索布料" defaultValue={defaultvalue} showBtn clickOnSearch={onSearch} changeOnSearch={getSearchData} >
|
||||||
<View className={styles.cancelFont} onClick={onSearch}>搜索</View>
|
|
||||||
</Search>
|
</Search>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.line}></View>
|
<View className={styles.line}></View>
|
||||||
|
|||||||
@ -473,17 +473,7 @@ const withStateSlice = (comp, slice: (state: ShoppingStateContextValue, props: P
|
|||||||
console.log('itemData 有变化')
|
console.log('itemData 有变化')
|
||||||
needMemo = false
|
needMemo = false
|
||||||
}
|
}
|
||||||
if (prevProps.itemData.purchaser_name === '皮特织业') {
|
|
||||||
console.log('------withStateSlice props-------')
|
|
||||||
console.log('withStateSlice props prevProps', prevProps)
|
|
||||||
console.log('withStateSlice props prevProps comparison itemData', prevProps.itemData === nextProps.itemData)
|
|
||||||
console.log('withStateSlice props nextProps', nextProps)
|
|
||||||
console.log('withStateSlice props prevProps comparison multipleSelection', prevProps.state.multipleSelection === nextProps.state.multipleSelection)
|
|
||||||
console.log('withStateSlice props prevProps comparison currentCheckedPurchaserId', prevProps.state.currentCheckedPurchaserId === nextProps.state.currentCheckedPurchaserId)
|
|
||||||
console.log('withStateSlice props prevProps comparison Observer', prevProps.state.Observer === nextProps.state.Observer)
|
|
||||||
console.log('withStateSlice props prevProps comparison state', prevProps.state === nextProps.state)
|
|
||||||
console.log('------withStateSlice props-------')
|
|
||||||
}
|
|
||||||
if (prevProps.state.Observer !== nextProps.state.Observer) {
|
if (prevProps.state.Observer !== nextProps.state.Observer) {
|
||||||
console.log('Observer 有变化')
|
console.log('Observer 有变化')
|
||||||
needMemo = false
|
needMemo = false
|
||||||
@ -496,6 +486,18 @@ const withStateSlice = (comp, slice: (state: ShoppingStateContextValue, props: P
|
|||||||
console.log('currentCheckedPurchaserId 有变化')
|
console.log('currentCheckedPurchaserId 有变化')
|
||||||
needMemo = false
|
needMemo = false
|
||||||
}
|
}
|
||||||
|
if (prevProps.itemData.purchaser_name === '孜然烤鱿鱼') {
|
||||||
|
console.log('更新 孜然烤鱿鱼', !needMemo)
|
||||||
|
console.log('------withStateSlice props-------')
|
||||||
|
console.log('withStateSlice props prevProps', prevProps)
|
||||||
|
console.log('withStateSlice props prevProps comparison itemData', prevProps.itemData === nextProps.itemData)
|
||||||
|
console.log('withStateSlice props nextProps', nextProps)
|
||||||
|
console.log('withStateSlice props prevProps comparison multipleSelection', prevProps.state.multipleSelection === nextProps.state.multipleSelection)
|
||||||
|
console.log('withStateSlice props prevProps comparison currentCheckedPurchaserId', prevProps.state.currentCheckedPurchaserId === nextProps.state.currentCheckedPurchaserId)
|
||||||
|
console.log('withStateSlice props prevProps comparison Observer', prevProps.state.Observer === nextProps.state.Observer)
|
||||||
|
console.log('withStateSlice props prevProps comparison state', prevProps.state === nextProps.state)
|
||||||
|
console.log('------withStateSlice props-------')
|
||||||
|
}
|
||||||
return needMemo
|
return needMemo
|
||||||
})
|
})
|
||||||
const Wrapper = (props: PropsType, ref) => {
|
const Wrapper = (props: PropsType, ref) => {
|
||||||
|
|||||||
@ -77,7 +77,7 @@ export interface ShoppingDispatchContextValue {
|
|||||||
[ShoppingDispatchType.UPDATE_CURRENT_CHECKED_SALEMODE]: (saleMode: ShoppingStateContextValue['currentCheckedSaleMode']) => void
|
[ShoppingDispatchType.UPDATE_CURRENT_CHECKED_SALEMODE]: (saleMode: ShoppingStateContextValue['currentCheckedSaleMode']) => void
|
||||||
[ShoppingDispatchType.UPDATE_COLOR_STORE]: (colorStore: React.SetStateAction<ColorStore>) => void
|
[ShoppingDispatchType.UPDATE_COLOR_STORE]: (colorStore: React.SetStateAction<ColorStore>) => void
|
||||||
[ShoppingDispatchType.UPDATE_SELECTED_AMOUNT]: (amount: React.SetStateAction<ShoppingStateContextValue['selectedAmount']>) => void
|
[ShoppingDispatchType.UPDATE_SELECTED_AMOUNT]: (amount: React.SetStateAction<ShoppingStateContextValue['selectedAmount']>) => void
|
||||||
[ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX]: (amount: React.SetStateAction<ShoppingStateContextValue['selectedAmount']>) => void
|
[ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX]: (amount: React.SetStateAction<GoodsMeta>) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ShoppingAction {
|
export interface ShoppingAction {
|
||||||
|
|||||||
@ -40,26 +40,75 @@ const ShoppingCartContainer: FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const listHeightRef = useRef('auto')
|
const listHeightRef = useRef('auto')
|
||||||
// 强制刷新
|
|
||||||
const [, setForceUpdate] = useState({})
|
|
||||||
|
|
||||||
const { fetchData, state } = ShoppingCartListApi()
|
const { fetchData, state } = ShoppingCartListApi()
|
||||||
|
|
||||||
const [searchOptions, setSearchOptions] = useState<SearchOptions>({})
|
const [searchOptions, setSearchOptions] = useState<SearchOptions>({})
|
||||||
|
const clearMultiSelection = () => {
|
||||||
|
console.log('clearMultiSelection', shoppingCartData?.list)
|
||||||
|
const target = shoppingCartData?.list?.find(item => item.purchaser_id === currentCheckedPurchaserId)
|
||||||
|
console.log('BackEndSaleModeListFieldMap', BackEndSaleModeListFieldMap[currentCheckedSaleMode], target)
|
||||||
|
const newGoodsKind = Object.fromEntries(
|
||||||
|
target?.[BackEndSaleModeListFieldMap[currentCheckedSaleMode]].map(item => [
|
||||||
|
item?.id,
|
||||||
|
{
|
||||||
|
id: item?.id,
|
||||||
|
estimate_amount: item.estimate_amount,
|
||||||
|
product_code: item.product_code,
|
||||||
|
product_color_code: item.product_color_code,
|
||||||
|
sale_mode: item.sale_mode,
|
||||||
|
count: currentCheckedSaleMode === EnumSaleMode.Bulk ? item.roll : Number(formatMeterDiv(item.length)),
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
const prevMultipleSelection = colorStore?.[currentCheckedPurchaserId]?.multipleSelection
|
||||||
|
console.log('clearMultiSelection', prevMultipleSelection)
|
||||||
|
const nextMultipleSelection = prevMultipleSelection
|
||||||
|
? Object.fromEntries(
|
||||||
|
Object.values(prevMultipleSelection).filter(value => !Object.keys(newGoodsKind).includes(String(value.id)))
|
||||||
|
.map(value => [
|
||||||
|
value.id,
|
||||||
|
{
|
||||||
|
id: value.id,
|
||||||
|
estimate_amount: value.estimate_amount,
|
||||||
|
product_code: value.product_code,
|
||||||
|
product_color_code: value.product_color_code,
|
||||||
|
sale_mode: value.sale_mode,
|
||||||
|
count: value.count,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
))
|
||||||
|
: {}
|
||||||
|
console.log('nextMultipleSelection', nextMultipleSelection)
|
||||||
|
// 清空多选
|
||||||
|
dispatch({
|
||||||
|
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
|
||||||
|
data: {
|
||||||
|
purchaserId: currentCheckedPurchaserId,
|
||||||
|
goodsKind: newGoodsKind,
|
||||||
|
multipleSelection: nextMultipleSelection,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
useDidShow(() => {
|
const getData = async() => {
|
||||||
|
await fetchData(getFilterData(searchOptions))
|
||||||
|
clearMultiSelection()
|
||||||
|
}
|
||||||
|
|
||||||
|
useDidShow(async() => {
|
||||||
// 第二次进入该页面时触发
|
// 第二次进入该页面时触发
|
||||||
if (!isFirst.current) {
|
if (!isFirst.current) {
|
||||||
|
console.log('重新刷新')
|
||||||
// 重新刷新
|
// 重新刷新
|
||||||
// setShoppingCartData({ list: [], total: 0 })
|
getData()
|
||||||
fetchData(getFilterData(searchOptions))
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('useEffect fetchData', getFilterData(searchOptions))
|
console.log('useEffect fetchData', getFilterData(searchOptions))
|
||||||
if (!isFirst.current) {
|
if (!isFirst.current) {
|
||||||
fetchData(getFilterData(searchOptions))
|
getData()
|
||||||
}
|
}
|
||||||
}, [searchOptions])
|
}, [searchOptions])
|
||||||
|
|
||||||
@ -92,21 +141,6 @@ const ShoppingCartContainer: FC = () => {
|
|||||||
console.log('useLayoutEffect')
|
console.log('useLayoutEffect')
|
||||||
await fetchData(getFilterData(searchOptions))
|
await fetchData(getFilterData(searchOptions))
|
||||||
isFirst.current = false
|
isFirst.current = false
|
||||||
// const query = Taro.createSelectorQuery()
|
|
||||||
// console.log('query', query)
|
|
||||||
// query.select('#shoppingContainer').boundingClientRect()
|
|
||||||
// query.select('#topBar').boundingClientRect()
|
|
||||||
// query.select('#bottomBar').boundingClientRect()
|
|
||||||
// query.exec((res) => {
|
|
||||||
// console.log('res==>', res)
|
|
||||||
// const containerHeight = res[0].height
|
|
||||||
// const topBarHeight = res[1].height
|
|
||||||
// const bottomBarHeight = res[2].height
|
|
||||||
// const listHeight = containerHeight - topBarHeight - bottomBarHeight
|
|
||||||
// listHeightRef.current = `${listHeight}px`
|
|
||||||
// // 强制刷新
|
|
||||||
// setForceUpdate({})
|
|
||||||
// })
|
|
||||||
})()
|
})()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
@ -233,6 +267,7 @@ const ShoppingCartContainer: FC = () => {
|
|||||||
setRefreshStatus(true)
|
setRefreshStatus(true)
|
||||||
const res = await fetchData(getFilterData(searchOptions))
|
const res = await fetchData(getFilterData(searchOptions))
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
|
clearMultiSelection()
|
||||||
setRefreshStatus(false)
|
setRefreshStatus(false)
|
||||||
alert.success('刷新成功')
|
alert.success('刷新成功')
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user