|
|
|
@ -3,10 +3,12 @@ import { useEffect, useState } from 'react'; |
|
|
|
|
import Taro from '@tarojs/taro'; |
|
|
|
|
import './index.less' |
|
|
|
|
|
|
|
|
|
export default function PopupHalfScreen({ visible, onClose, isfilter, onFilter }) { |
|
|
|
|
export default function PopupHalfScreen({ visible, onClose, hideFilter, onFilter }) { |
|
|
|
|
|
|
|
|
|
//弹窗内容数据
|
|
|
|
|
const [popUpContextList, setpopUpContextList] = useState<any[]>([]) |
|
|
|
|
const [states, setStates] = useState<any[]>([]) |
|
|
|
|
const [refer, setRefer] = useState<any[]>([]) |
|
|
|
|
|
|
|
|
|
//管理关闭动画状态
|
|
|
|
|
const [isAnimationOpen, setisAnimationOpen] = useState(false) |
|
|
|
@ -14,6 +16,13 @@ export default function PopupHalfScreen({ visible, onClose, isfilter, onFilter } |
|
|
|
|
//本地记录筛选内容
|
|
|
|
|
const [userFilter, setuserFilter] = useState(0) |
|
|
|
|
|
|
|
|
|
//记录用户筛选状态
|
|
|
|
|
const [filterForm, setFilterForm] = useState({ |
|
|
|
|
filter: '', |
|
|
|
|
state: '', |
|
|
|
|
refer: '', |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
Taro.request({ |
|
|
|
|
url: 'https://interapi.jm-kid.com/api/product/filter', |
|
|
|
@ -26,7 +35,10 @@ export default function PopupHalfScreen({ visible, onClose, isfilter, onFilter } |
|
|
|
|
}, |
|
|
|
|
success: (res) => { |
|
|
|
|
console.log('订阅筛选分类请求成功=>', res.data) |
|
|
|
|
setpopUpContextList(res.data.data) |
|
|
|
|
const { data } = res |
|
|
|
|
setpopUpContextList(data.data) |
|
|
|
|
setStates(data.state) |
|
|
|
|
setRefer(data.refer) |
|
|
|
|
}, |
|
|
|
|
fail: (err) => { |
|
|
|
|
console.log('订阅筛选分类请求失败=>', err) |
|
|
|
@ -34,7 +46,7 @@ export default function PopupHalfScreen({ visible, onClose, isfilter, onFilter } |
|
|
|
|
}) |
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!visible) { |
|
|
|
|
return null; |
|
|
|
@ -49,15 +61,25 @@ export default function PopupHalfScreen({ visible, onClose, isfilter, onFilter } |
|
|
|
|
}, 500) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleFilterSelect = (target: number) => { |
|
|
|
|
|
|
|
|
|
if(isfilter === target){ |
|
|
|
|
// onFilter('')
|
|
|
|
|
setuserFilter(0) |
|
|
|
|
}else{ |
|
|
|
|
// onFilter(target)
|
|
|
|
|
setuserFilter(target) |
|
|
|
|
} |
|
|
|
|
const handleFilterSelect = (val: string) => { |
|
|
|
|
setFilterForm({ |
|
|
|
|
...filterForm, |
|
|
|
|
filter: filterForm.filter === val ? '' : val |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const handleStateSelect = (val: string) => { |
|
|
|
|
setFilterForm({ |
|
|
|
|
...filterForm, |
|
|
|
|
state: filterForm.state === val ? '' : val |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const handleReferSelect = (val: string) => { |
|
|
|
|
setFilterForm({ |
|
|
|
|
...filterForm, |
|
|
|
|
refer: filterForm.refer === val ? '' : val |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const handleReset = () => { |
|
|
|
@ -67,7 +89,7 @@ export default function PopupHalfScreen({ visible, onClose, isfilter, onFilter } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const handleCommit = () => { |
|
|
|
|
onFilter(userFilter) |
|
|
|
|
onFilter(filterForm) |
|
|
|
|
handleOverlayClick(null) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -90,8 +112,8 @@ export default function PopupHalfScreen({ visible, onClose, isfilter, onFilter } |
|
|
|
|
<View className='popup_content' onClick={(e) => e.stopPropagation()}> |
|
|
|
|
{/* 弹窗内容 */} |
|
|
|
|
<View className='popop_content_header'> |
|
|
|
|
<Image
|
|
|
|
|
className='popup_content_header_icon'
|
|
|
|
|
<Image |
|
|
|
|
className='popup_content_header_icon' |
|
|
|
|
src='https://oss.jm-kid.com/wx_5colorflower/foldUp.svg' |
|
|
|
|
onClick={handleOverlayClick} |
|
|
|
|
/> |
|
|
|
@ -103,8 +125,8 @@ export default function PopupHalfScreen({ visible, onClose, isfilter, onFilter } |
|
|
|
|
scrollWithAnimation |
|
|
|
|
> |
|
|
|
|
{ |
|
|
|
|
popUpContextList.map((item: any, index: number) => ( |
|
|
|
|
<View
|
|
|
|
|
!hideFilter && popUpContextList.map((item: any, index: number) => ( |
|
|
|
|
<View |
|
|
|
|
className='popup_content_body_item' |
|
|
|
|
key={index} |
|
|
|
|
> |
|
|
|
@ -112,23 +134,23 @@ export default function PopupHalfScreen({ visible, onClose, isfilter, onFilter } |
|
|
|
|
<View className='popup_content_body_item_group'> |
|
|
|
|
{ |
|
|
|
|
item.category.map((subItem: any, subIndex: number) => ( |
|
|
|
|
<View
|
|
|
|
|
<View |
|
|
|
|
className='popup_content_body_item_group_bar' |
|
|
|
|
key={subIndex} |
|
|
|
|
onClick={()=>handleFilterSelect(subItem.id)} |
|
|
|
|
style={ |
|
|
|
|
userFilter === subItem.id ? { |
|
|
|
|
filterForm.filter === subItem.id ? { |
|
|
|
|
backgroundColor: '#3BA366' |
|
|
|
|
} : {} |
|
|
|
|
} |
|
|
|
|
> |
|
|
|
|
<Text
|
|
|
|
|
<Text |
|
|
|
|
className='popup_content_body_item_group_bar_title' |
|
|
|
|
style={ |
|
|
|
|
userFilter === subItem.id ? { |
|
|
|
|
filterForm.filter === subItem.id ? { |
|
|
|
|
color: '#ffffff' |
|
|
|
|
} : {} |
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
>{subItem.title}</Text> |
|
|
|
|
</View> |
|
|
|
|
)) |
|
|
|
@ -137,25 +159,82 @@ export default function PopupHalfScreen({ visible, onClose, isfilter, onFilter } |
|
|
|
|
</View> |
|
|
|
|
)) |
|
|
|
|
} |
|
|
|
|
<View className='popup_content_body_item'> |
|
|
|
|
<Text className='popup_content_body_item_title'>状态</Text> |
|
|
|
|
<View className='popup_content_body_item_group'> |
|
|
|
|
{ |
|
|
|
|
states.map((item: any, index: number) => ( |
|
|
|
|
<View |
|
|
|
|
className='popup_content_body_item_group_bar' |
|
|
|
|
key={index} |
|
|
|
|
onClick={()=>handleStateSelect(item.id)} |
|
|
|
|
style={ |
|
|
|
|
filterForm.state === item.id ? { |
|
|
|
|
backgroundColor: '#3BA366' |
|
|
|
|
} : {} |
|
|
|
|
} |
|
|
|
|
> |
|
|
|
|
<Text |
|
|
|
|
className='popup_content_body_item_group_bar_title' |
|
|
|
|
style={ |
|
|
|
|
filterForm.state === item.id ? { |
|
|
|
|
color: '#ffffff' |
|
|
|
|
} : {} |
|
|
|
|
} |
|
|
|
|
>{item.title}</Text> |
|
|
|
|
</View> |
|
|
|
|
)) |
|
|
|
|
} |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
<View className='popup_content_body_item'> |
|
|
|
|
<Text className='popup_content_body_item_title'>来源</Text> |
|
|
|
|
<View className='popup_content_body_item_group'> |
|
|
|
|
{ |
|
|
|
|
refer.map((item: any, index: number) => ( |
|
|
|
|
<View |
|
|
|
|
className='popup_content_body_item_group_bar' |
|
|
|
|
key={index} |
|
|
|
|
onClick={()=>handleReferSelect(item.id)} |
|
|
|
|
style={ |
|
|
|
|
filterForm.refer === item.id ? { |
|
|
|
|
backgroundColor: '#3BA366' |
|
|
|
|
} : {} |
|
|
|
|
} |
|
|
|
|
> |
|
|
|
|
<Text |
|
|
|
|
className='popup_content_body_item_group_bar_title' |
|
|
|
|
style={ |
|
|
|
|
filterForm.refer === item.id ? { |
|
|
|
|
color: '#ffffff' |
|
|
|
|
} : {} |
|
|
|
|
} |
|
|
|
|
>{item.title}</Text> |
|
|
|
|
</View> |
|
|
|
|
)) |
|
|
|
|
} |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
</ScrollView> |
|
|
|
|
<View className='popup_content_footer'> |
|
|
|
|
<View
|
|
|
|
|
className='popup_content_footer_btn'
|
|
|
|
|
<View |
|
|
|
|
className='popup_content_footer_btn' |
|
|
|
|
style={{background: '#3BA366'}} |
|
|
|
|
onClick={handleReset} |
|
|
|
|
> |
|
|
|
|
<Text
|
|
|
|
|
className='popup_content_footer_btn_text'
|
|
|
|
|
<Text |
|
|
|
|
className='popup_content_footer_btn_text' |
|
|
|
|
style={{color: '#fff'}} |
|
|
|
|
>重置</Text> |
|
|
|
|
</View> |
|
|
|
|
<View
|
|
|
|
|
className='popup_content_footer_btn'
|
|
|
|
|
<View |
|
|
|
|
className='popup_content_footer_btn' |
|
|
|
|
style={{background: '#FCCA1E'}} |
|
|
|
|
onClick={handleCommit}
|
|
|
|
|
onClick={handleCommit} |
|
|
|
|
> |
|
|
|
|
<Text
|
|
|
|
|
className='popup_content_footer_btn_text'
|
|
|
|
|
<Text |
|
|
|
|
className='popup_content_footer_btn_text' |
|
|
|
|
style={{color: '#000'}} |
|
|
|
|
>确定</Text> |
|
|
|
|
</View> |
|
|
|
|