🐞 fix(ID1001433): 【电子商城】-功能{筛选}:点击重置只需清除筛选条件,不需关闭筛选页面
【【电子商城】-功能{筛选}:点击重置只需清除筛选条件,不需关闭筛选页面】 https://www.tapd.cn/53459131/bugtrace/bugs/view/1153459131001001433
This commit is contained in:
parent
97a5f22c2b
commit
f9dee01031
@ -69,3 +69,13 @@ export const EnumLabelPageJumpApi = () => {
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* [枚举]首页跳转分类的枚举
|
||||
*/
|
||||
export const EnumAllLabelApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mall/product/label/enum',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
// 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 = '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:50005/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 = `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.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' // 杰
|
||||
|
||||
// CDN
|
||||
|
||||
@ -92,7 +92,6 @@ const Filter = (props: params) => {
|
||||
setFilterObj(res)
|
||||
onFilter?.(res)
|
||||
onReset?.(res)
|
||||
dropDownRef.current?.closePopup()
|
||||
}
|
||||
|
||||
// 提交搜索
|
||||
@ -118,8 +117,12 @@ const Filter = (props: params) => {
|
||||
})
|
||||
}, [filterObj])
|
||||
|
||||
const onCloseOverlay = () => {
|
||||
onVerify()
|
||||
}
|
||||
|
||||
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>
|
||||
<Text style={{ color: isInitial ? '#808080' : '#4581ff' }}>筛选</Text>
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
export default {
|
||||
navigationBarTitleText: '搜索',
|
||||
enablePullDownRefresh: true,
|
||||
navigationBarTitleText: '面料商城',
|
||||
backgroundTextStyle: 'dark',
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
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 SelectData from './components/selectData'
|
||||
import styles from './searchList.module.scss'
|
||||
@ -15,7 +15,7 @@ import useLogin from '@/use/useLogin'
|
||||
import LabAndImg from '@/components/LabAndImg'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import Tag from '@/components/tag'
|
||||
import { GetLabelProductsApi, HomePageJumpApi } from '@/api/search'
|
||||
import { EnumAllLabelApi, GetLabelProductsApi, HomePageJumpApi } from '@/api/search'
|
||||
|
||||
enum FilterOptions {
|
||||
RECOMMEND = 1,
|
||||
@ -24,16 +24,34 @@ enum FilterOptions {
|
||||
}
|
||||
|
||||
export default () => {
|
||||
const isFirst = useRef(true)
|
||||
|
||||
useLogin()
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const { fetchData } = HomePageJumpApi()
|
||||
// 获取标签列表
|
||||
const getLabels = async() => {
|
||||
const res = await fetchData({ page_jump: router.params.pageJump || 1 })
|
||||
|
||||
setLabelList(res.data.list.map(item => ({ id: item.product_label_id, name: item.product_label_name })))
|
||||
// 获取指定的标签组的标签列表
|
||||
const getLabelsWithHomeJump = async() => {
|
||||
await getAllLabel()
|
||||
if (router.params.pageJump) {
|
||||
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 { data } = await materialFetchData(getFilterData(searchField))
|
||||
setMaterialList({ list: data.list, total: data.total })
|
||||
Taro.stopPullDownRefresh()
|
||||
setRefresherTriggeredStatus(false)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getLabels()
|
||||
getLabelsWithHomeJump()
|
||||
}, [])
|
||||
|
||||
// 监听筛选条件变化
|
||||
useEffect(() => {
|
||||
getProductList()
|
||||
}, [searchField])
|
||||
// 首次进入页面不执行
|
||||
if (!isFirst.current) {
|
||||
getProductList()
|
||||
}
|
||||
}, [searchField, isFirst.current])
|
||||
|
||||
// 上拉加载数据
|
||||
const pageNum = useRef({ size: searchField.size, page: searchField.page })
|
||||
@ -90,15 +111,16 @@ export default () => {
|
||||
pageNum.current = { size: 10, page: 1 }
|
||||
}, [])
|
||||
|
||||
const handleInput = (e) => {
|
||||
if (e === '') {
|
||||
getSearchData(e)
|
||||
}
|
||||
}
|
||||
|
||||
const goLinkPage = (item) => {
|
||||
goLink('/pages/details/index', { id: item.id })
|
||||
}
|
||||
|
||||
// 页面下拉刷新
|
||||
usePullDownRefresh(() => {
|
||||
setSearchField({ ...searchField, size: 10 })
|
||||
})
|
||||
|
||||
const [labelIds, setLabelIds] = useState<number[]>([])
|
||||
|
||||
// 获取筛选条件
|
||||
@ -146,13 +168,6 @@ export default () => {
|
||||
[materialList],
|
||||
)
|
||||
|
||||
// 返回
|
||||
const handCancel = () => {
|
||||
Taro.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}
|
||||
|
||||
const [currentOption, setCurrentOption] = useState(FilterOptions.RECOMMEND)
|
||||
|
||||
const handleSelectFilterOptions = (key: FilterOptions) => {
|
||||
@ -187,7 +202,7 @@ export default () => {
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<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 className={styles.filter}>
|
||||
<View className={styles.filter_all}>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user