diff --git a/src/api/material.ts b/src/api/material.ts index 1b47f30..a777a95 100644 --- a/src/api/material.ts +++ b/src/api/material.ts @@ -45,3 +45,13 @@ export const GetProductDetailApi = () => { }) } +/** + * 根据LAB匹配色卡基础资料 + * @returns +*/ +export const GetLabProductApi = () => { + return useRequest({ + url: `/v1/mall/product/color/absorb/match`, + method: "get", + }) +} diff --git a/src/api/search.ts b/src/api/search.ts index 9f91366..5b0f296 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -3,9 +3,31 @@ import { useRequest } from "@/use/useHttp" /** * 获取热门搜索 */ - export const getHotSearchApi = () => { + export const GetHotSearchApi = () => { return useRequest({ - url: `/v1/mall/hotSearch`, + url: `/v1/mall/hotSearch/list`, method: "get", }) +} + + +/** + * 获取历史搜索 + */ + export const GetSearchHistoryApi = () => { + return useRequest({ + url: `/v1/mall/searchHistory/list`, + method: "get", + }) +} + + +/** + * 添加搜索关键字 + */ + export const AddSearchHistoryApi = () => { + return useRequest({ + url: `/v1/mall/searchHistory`, + method: "post", + }) } \ No newline at end of file diff --git a/src/common/constant.js b/src/common/constant.js index 7c65e86..7bab9fc 100644 --- a/src/common/constant.js +++ b/src/common/constant.js @@ -24,4 +24,9 @@ export const IMG_CND_Prefix = "http://test.cdn.zzfzyc.com" export const CDN_UPLOAD_IMG = `${UPLOAD_CDN_URL || ''}`; //appid -export const WX_APPID = 'wx68d92d7cbf0b6963' \ No newline at end of file +export const WX_APPID = 'wx68d92d7cbf0b6963' + +//场景值 +export const SCENE = { + SearchScene : 0 //商城面料搜索 +} \ No newline at end of file diff --git a/src/common/fotmat.js b/src/common/fotmat.js index 3cff723..1877f76 100644 --- a/src/common/fotmat.js +++ b/src/common/fotmat.js @@ -142,5 +142,5 @@ export const toDecimal2 = (x) => { * @returns */ export const formatImgUrl = (url) => { - return IMG_CND_Prefix + url + return url?IMG_CND_Prefix + url:'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F811%2F021315104H2%2F150213104H2-3-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651817947&t=5467a207f845ddfc7737d55934e6b26d' } \ No newline at end of file diff --git a/src/components/filter copy/index copy.tsx b/src/components/filter copy/index copy.tsx new file mode 100644 index 0000000..06f2ff3 --- /dev/null +++ b/src/components/filter copy/index copy.tsx @@ -0,0 +1,130 @@ +import { GetProductKindListApi } from "@/api/material"; +import Popup, {Params as PopuParams} from "@/components/popup" +import { Input, ScrollView, Text, Textarea, View } from "@tarojs/components" +import { useDidShow } from "@tarojs/taro"; +import classnames from "classnames"; +import { useEffect, useState } from "react"; +import styles from './index.module.scss' + +type params = { + onFiltr?: (val:object) => void +} & PopuParams +export default ({onClose, onFiltr, show = false}:params) => { + + //搜索条件 + const [filterObj, setFilterObj] = useState({ + seriesId: '', + minWidth: '', + maxWidth: '', + minWeight: '', + maxWeight: '', + element: '' + }) + + //获取系列 + const {fetchData: kindFetchData} = GetProductKindListApi() + const [kindList, setKindList] = useState([]) + const getCategoryList = async () => { + let {data} = await kindFetchData() + setKindList(data.list) + } + + useEffect(() => { + show&&getCategoryList() + }, [show]) + + //切换系列 + const changeKind = (e) => { + setFilterObj({...filterObj, seriesId:e.id}) + } + + const onCloseEven = () => { + onClose?.() + } + const onRest = () => { + console.log('12123') + setFilterObj({ + seriesId: '', + minWidth: '', + maxWidth: '', + minWeight: '', + maxWeight: '', + element: '' + }) + } + useEffect(() => { + console.log(filterObj) + }, [filterObj]) + + const onVerify = () => { + console.log(filterObj) + onFiltr?.(filterObj) + } + + const setNumber = (e, field) => { + console.log(e) + let num = parseFloat(e.detail.value) + if(isNaN(num)) { + filterObj[field] = null + } else { + filterObj[field] = parseFloat(num.toFixed(2)) + } + setFilterObj({...filterObj}) + } + + const setElement = (e) => { + let res = e.detail.value + setFilterObj({...filterObj, element:res}) + } + return ( + + onCloseEven()} showIconButton={true}> + + 全部筛选 + + + + 系列 + + {kindList.map(item => changeKind(item)} className={classnames(styles.btn_item, (filterObj.seriesId == item.id)&&styles.select_btn_item)}>{item.name})} + + + + 幅宽 + + setNumber(e,'minWidth')} placeholder="自定义最低值" placeholderStyle="font-size: 26rpx"/> + + setNumber(e,'maxWidth')} placeholder="自定义最高值" placeholderStyle="font-size: 26rpx"/> + cm + + + + 克重 + + setNumber(e,'minWeight')} placeholder="自定义最低值" placeholderStyle="font-size: 26rpx"/> + + setNumber(e,'maxWeight')} placeholder="自定义最高值" placeholderStyle="font-size: 26rpx"/> + g + + + + 成分 + +