diff --git a/src/api/order.ts b/src/api/order.ts index 3d6853b..721c4b1 100644 --- a/src/api/order.ts +++ b/src/api/order.ts @@ -140,6 +140,13 @@ export const MpSearchHistoryList = () => { method: 'get', }) } +// 关键字搜索历史 +export const DeleteSearchHistoryList = () => { + return useRequest({ + url: '/v1/mp/searchHistory/delete', + method: 'delete', + }) +} // 添加关键字搜索 export const MpSearchHistory = () => { return useRequest({ diff --git a/src/pages/searchPage/index.module.scss b/src/pages/searchPage/index.module.scss index 2120d2c..9a7f5a7 100644 --- a/src/pages/searchPage/index.module.scss +++ b/src/pages/searchPage/index.module.scss @@ -1,92 +1,77 @@ page { - background: #ffff; + background: #ffff; } .main { - background: #ffff; + background: #ffff; - .topBox { - padding-left: 24px; - } + .cancelFont { + width: 76px; + font-size: 28px; + color: #000000; + margin-left: 32px; + margin-right: 32px; + } - .cancelFont { - width: 76px; - font-size: 28px; - font-family: PingFangSC-Regular, PingFang SC; - font-weight: 400; - color: #000000; + .line { + width: 750px; + height: 1px; + background: #000000; + opacity: 0.05; + margin-top: 16px; + margin-bottom: 32px; + } + + .topBox { + display: flex; + padding: 0 24px; + align-items: center; + justify-content: space-between; + margin-bottom: 32px; + + .histroyLeft { + display: flex; + align-items: center; + justify-content: space-between; + width: 100%; + overflow: hidden; + + .histroyFonts { margin-left: 32px; + font-size: 28px; + color: #000000; + } + + .back { margin-right: 32px; + font-size: 28px; + color: #000000; + } } - .line { - width: 750px; - height: 1px; - background: #000000; - opacity: 0.05; - margin-top: 16px; - margin-bottom: 32px; + .icon_delect { + margin-right: 45px; + color: #f7f7f7; } + } - .topBox { - display: flex; - align-items: center; - justify-content: space-between; - margin-bottom: 32px; + .bigBox { + display: flex; + flex-wrap: wrap; + padding-left: 32px; - .histroyLeft { - display: flex; - align-items: center; - justify-content: space-between; - width: 100%; - overflow: hidden; - - .histroyFonts { - margin-left: 32px; - font-size: 28px; - font-family: PingFangSC-Regular, PingFang SC; - font-weight: 400; - color: #000000; - } - - .back { - margin-right: 32px; - font-size: 28px; - font-family: PingFangSC-Regular, PingFang SC; - font-weight: 400; - color: #000000; - } - } - - - - .icon_delect { - margin-right: 45px; - color: #f7f7f7; - } + .itemBox { + background: #f7f7f7; + border-radius: 8px; + text-align: center; + padding-top: 12px; + padding-bottom: 12px; + padding-left: 17px; + padding-right: 17px; + font-size: 24px; + color: #000000; + margin-right: 16px; + margin-bottom: 16px; } - - - .bigBox { - display: flex; - flex-wrap: wrap; - padding-left: 32px; - - .itemBox { - background: #F7F7F7; - border-radius: 8px; - text-align: center; - padding-top: 12px; - padding-bottom: 12px; - padding-left: 17px; - padding-right: 17px; - font-size: 24px; - font-family: PingFangSC-Regular, PingFang SC; - font-weight: 400; - color: #000000; - margin-right: 16px; - margin-bottom: 16px; - } - } - -} \ No newline at end of file + } +} diff --git a/src/pages/searchPage/index.tsx b/src/pages/searchPage/index.tsx index a478c10..47e5699 100644 --- a/src/pages/searchPage/index.tsx +++ b/src/pages/searchPage/index.tsx @@ -11,11 +11,14 @@ import { debounce, getFilterData } from '@/common/util' import ShopCart from '@/components/shoppingCart' import { ClientListApi, + DeleteSearchHistoryList, MpProductColorList, MpSearchHistory, - MpSearchHistoryList - , MpShoppingCartProductColorList, + MpSearchHistoryList, + MpShoppingCartProductColorList, } from '@/api/order' +import IconFont from '@/components/iconfont/iconfont' +import { alert } from '@/common/common' const SearchPage = () => { const [clientObj, setclientObj] = useState({ @@ -384,6 +387,35 @@ const SearchPage = () => { setHasFonts(false) setSearchList([]) } + + // 删除历史搜索 + const { fetchData: deleteHistoryApi } = DeleteSearchHistoryList() + const handDelete = async() => { + Taro.showModal({ + title: '确定删除历史搜索记录吗?', + async success(res) { + if (res.confirm) { + const result = await deleteHistoryApi() + if (result.success) { + Taro.showLoading({ + title: '请稍等...', + }) + alert.success('删除成功') + getHistory() + Taro.hideLoading() + } + else { + alert.error('删除失败') + Taro.hideLoading() + } + } + else if (res.cancel) { + console.log('用户点击取消') + } + }, + }) + } + return ( @@ -396,7 +428,10 @@ const SearchPage = () => { !hasFonts && <> 历史搜索 - + { + histroyList.length > 0 + && handDelete()}> + } {!!histroyList.length &&