🐞 fix(ID1001433): 【电子商城】-功能{筛选}:点击重置只需清除筛选条件,不需关闭筛选页面

【【电子商城】-功能{筛选}:点击重置只需清除筛选条件,不需关闭筛选页面】 https://www.tapd.cn/53459131/bugtrace/bugs/view/1153459131001001433
This commit is contained in:
xuan 2023-03-02 17:38:27 +08:00
parent 97a5f22c2b
commit f9dee01031
5 changed files with 57 additions and 30 deletions

View File

@ -69,3 +69,13 @@ export const EnumLabelPageJumpApi = () => {
method: 'get', method: 'get',
}) })
} }
/**
* []
*/
export const EnumAllLabelApi = () => {
return useRequest({
url: '/v1/mall/product/label/enum',
method: 'get',
})
}

View File

@ -5,7 +5,7 @@
// export const BASE_URL = `http://192.168.0.89:40001/lymarket` // export const BASE_URL = `http://192.168.0.89:40001/lymarket`
// export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞 // export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞
// export const BASE_URL = 'https://test.zzfzyc.com/lymarket' // 测试环境 // export const BASE_URL = 'https://test.zzfzyc.com/lymarket' // 测试环境
export const BASE_URL = 'https://pre.zzfzyc.com/lymarket' // 预发布 // export const BASE_URL = 'https://pre.zzfzyc.com/lymarket' // 预发布
// export const BASE_URL = `http://192.168.1.9:40001/lymarket` // 发 // export const BASE_URL = `http://192.168.1.9:40001/lymarket` // 发
// export const BASE_URL = `http://192.168.1.9:50005/lymarket` // 发 // export const BASE_URL = `http://192.168.1.9:50005/lymarket` // 发
// export const BASE_URL = `http://192.168.1.30:50001/lymarket` // 发 // export const BASE_URL = `http://192.168.1.30:50001/lymarket` // 发
@ -13,7 +13,7 @@ export const BASE_URL = 'https://pre.zzfzyc.com/lymarket' // 预发布
// export const BASE_URL = 'https://www.zzfzyc.com/lymarket' // 正式环境 // export const BASE_URL = 'https://www.zzfzyc.com/lymarket' // 正式环境
// export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞 // export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞
// export const BASE_URL = 'http://192.168.1.7:50002/lymarket' // 添 // export const BASE_URL = 'http://192.168.1.7:50002/lymarket' // 添
// export const BASE_URL = 'http://192.168.1.28:50002/lymarket' // 婷 export const BASE_URL = 'http://192.168.1.28:50002/lymarket' // 婷
// export const BASE_URL = 'http://192.168.1.42:50002/lymarket' // 杰 // export const BASE_URL = 'http://192.168.1.42:50002/lymarket' // 杰
// CDN // CDN

View File

@ -92,7 +92,6 @@ const Filter = (props: params) => {
setFilterObj(res) setFilterObj(res)
onFilter?.(res) onFilter?.(res)
onReset?.(res) onReset?.(res)
dropDownRef.current?.closePopup()
} }
// 提交搜索 // 提交搜索
@ -118,8 +117,12 @@ const Filter = (props: params) => {
}) })
}, [filterObj]) }, [filterObj])
const onCloseOverlay = () => {
onVerify()
}
return ( return (
<DropDownItem ref={dropDownRef} direction="down" titleSlot={ <DropDownItem onCloseOverlay={onCloseOverlay} ref={dropDownRef} direction="down" titleSlot={
<> <>
<IconFont customStyle={{ marginRight: '10rpx' }} name="icon-shaixuan" color={isInitial ? '#808080' : '#4581ff'} size={40}></IconFont> <IconFont customStyle={{ marginRight: '10rpx' }} name="icon-shaixuan" color={isInitial ? '#808080' : '#4581ff'} size={40}></IconFont>
<Text style={{ color: isInitial ? '#808080' : '#4581ff' }}></Text> <Text style={{ color: isInitial ? '#808080' : '#4581ff' }}></Text>

View File

@ -1,5 +1,4 @@
export default { export default {
navigationBarTitleText: '搜索', navigationBarTitleText: '面料商城',
enablePullDownRefresh: true,
backgroundTextStyle: 'dark', backgroundTextStyle: 'dark',
} }

View File

@ -1,5 +1,5 @@
import { Text, View } from '@tarojs/components' import { Text, View } from '@tarojs/components'
import Taro, { usePullDownRefresh, useRouter } from '@tarojs/taro' import Taro, { usePullDownRefresh, useReady, useRouter } from '@tarojs/taro'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import SelectData from './components/selectData' import SelectData from './components/selectData'
import styles from './searchList.module.scss' import styles from './searchList.module.scss'
@ -15,7 +15,7 @@ import useLogin from '@/use/useLogin'
import LabAndImg from '@/components/LabAndImg' import LabAndImg from '@/components/LabAndImg'
import IconFont from '@/components/iconfont/iconfont' import IconFont from '@/components/iconfont/iconfont'
import Tag from '@/components/tag' import Tag from '@/components/tag'
import { GetLabelProductsApi, HomePageJumpApi } from '@/api/search' import { EnumAllLabelApi, GetLabelProductsApi, HomePageJumpApi } from '@/api/search'
enum FilterOptions { enum FilterOptions {
RECOMMEND = 1, RECOMMEND = 1,
@ -24,16 +24,34 @@ enum FilterOptions {
} }
export default () => { export default () => {
const isFirst = useRef(true)
useLogin() useLogin()
const router = useRouter() const router = useRouter()
const { fetchData } = HomePageJumpApi() const { fetchData } = HomePageJumpApi()
// 获取标签列表 // 获取指定的标签组的标签列表
const getLabels = async() => { const getLabelsWithHomeJump = async() => {
const res = await fetchData({ page_jump: router.params.pageJump || 1 }) await getAllLabel()
if (router.params.pageJump) {
setLabelList(res.data.list.map(item => ({ id: item.product_label_id, name: item.product_label_name }))) const res = await fetchData({ page_jump: router.params.pageJump || 1 })
const labelIds = res.data.list.map(item => item.product_label_id)
setLabelIds(labelIds)
setSearchField(prev => ({ ...prev, label_ids: labelIds.join(',') }))
}
else {
setLabelIds([])
setSearchField(prev => ({ ...prev, label_ids: '' }))
}
isFirst.current = false
}
// 获取所有标签列表
const { fetchData: getAllLabelApi } = EnumAllLabelApi()
const getAllLabel = async() => {
const res = await getAllLabelApi()
const labelList = res.data.list.map(item => ({ id: item.id, name: item.name }))
setLabelList(labelList)
} }
// 搜索参数 // 搜索参数
@ -55,17 +73,20 @@ export default () => {
const getProductList = async() => { const getProductList = async() => {
const { data } = await materialFetchData(getFilterData(searchField)) const { data } = await materialFetchData(getFilterData(searchField))
setMaterialList({ list: data.list, total: data.total }) setMaterialList({ list: data.list, total: data.total })
Taro.stopPullDownRefresh() setRefresherTriggeredStatus(false)
} }
useEffect(() => { useEffect(() => {
getLabels() getLabelsWithHomeJump()
}, []) }, [])
// 监听筛选条件变化 // 监听筛选条件变化
useEffect(() => { useEffect(() => {
getProductList() // 首次进入页面不执行
}, [searchField]) if (!isFirst.current) {
getProductList()
}
}, [searchField, isFirst.current])
// 上拉加载数据 // 上拉加载数据
const pageNum = useRef({ size: searchField.size, page: searchField.page }) const pageNum = useRef({ size: searchField.size, page: searchField.page })
@ -90,15 +111,16 @@ export default () => {
pageNum.current = { size: 10, page: 1 } pageNum.current = { size: 10, page: 1 }
}, []) }, [])
const handleInput = (e) => {
if (e === '') {
getSearchData(e)
}
}
const goLinkPage = (item) => { const goLinkPage = (item) => {
goLink('/pages/details/index', { id: item.id }) goLink('/pages/details/index', { id: item.id })
} }
// 页面下拉刷新
usePullDownRefresh(() => {
setSearchField({ ...searchField, size: 10 })
})
const [labelIds, setLabelIds] = useState<number[]>([]) const [labelIds, setLabelIds] = useState<number[]>([])
// 获取筛选条件 // 获取筛选条件
@ -146,13 +168,6 @@ export default () => {
[materialList], [materialList],
) )
// 返回
const handCancel = () => {
Taro.navigateBack({
delta: 1,
})
}
const [currentOption, setCurrentOption] = useState(FilterOptions.RECOMMEND) const [currentOption, setCurrentOption] = useState(FilterOptions.RECOMMEND)
const handleSelectFilterOptions = (key: FilterOptions) => { const handleSelectFilterOptions = (key: FilterOptions) => {
@ -187,7 +202,7 @@ export default () => {
return ( return (
<View className={styles.main}> <View className={styles.main}>
<View className={styles.search}> <View className={styles.search}>
<Search placeholder="请输入搜索面料" showBtn btnTitle="取消" clickOnSearch={handCancel} defaultValue={router.params.key} changeOnSearch={getSearchData} debounceTime={300} /> <Search placeholder="请输入搜索面料" showBtn btnTitle="搜索" clickOnSearch={getSearchData} defaultValue={router.params.key} changeOnSearch={handleInput} debounceTime={300} />
</View> </View>
<View className={styles.filter}> <View className={styles.filter}>
<View className={styles.filter_all}> <View className={styles.filter_all}>