From c2fa0766aab711c2e47db9da05a65ab16457152d Mon Sep 17 00:00:00 2001 From: Haiyi <1021441632@qq.com> Date: Fri, 16 Sep 2022 18:43:14 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=84=20refactor:=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E9=A1=B5=E7=82=B9=E5=87=BB=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/searchPage/index.module.scss | 30 ++++++++++++++++++++------ src/pages/searchPage/index.tsx | 27 ++++++++++++++++++++--- src/styles/iconfont.scss | 2 +- 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/pages/searchPage/index.module.scss b/src/pages/searchPage/index.module.scss index c3b0862..51e531f 100644 --- a/src/pages/searchPage/index.module.scss +++ b/src/pages/searchPage/index.module.scss @@ -30,14 +30,32 @@ page { justify-content: space-between; margin-bottom: 32px; - .histroyFonts { - margin-left: 32px; - font-size: 28px; - font-family: PingFangSC-Regular, PingFang SC; - font-weight: 400; - color: #000000; + .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; diff --git a/src/pages/searchPage/index.tsx b/src/pages/searchPage/index.tsx index 00e5106..3da27db 100644 --- a/src/pages/searchPage/index.tsx +++ b/src/pages/searchPage/index.tsx @@ -144,7 +144,6 @@ export default memo(() => { const [goodObj, setGoodsobj] = useState({}) //点击对应商品显示购物车 const showCart = async (item) => { - console.log(item, 6666) setSearchObj((e) => ({ ...e, goodsId: item.id })) setShowShopCart(true) setGoodsobj(item) @@ -269,6 +268,25 @@ export default memo(() => { setGoodlist([...goodList]) } + //点击关键字搜索内容 + const handItem = (item) => { + Taro.showLoading({ + title: '加载中...', + mask: true + }) + productFetch({ code_or_name: item.search_key }).then((res) => { + if (res.data) { + setHasFonts(true) + setSearchList([...res.data.list]) + Taro.hideLoading() + } + }) + } + //点击返回文字 + const handBack = () => { + setHasFonts(false) + setSearchList([]) + } return ( @@ -285,7 +303,7 @@ export default memo(() => { {histroyList.map((item, index) => { return ( - {item.search_key} + handItem(item)} key={index} className={styles.itemBox}>{item.search_key} ) })} @@ -298,7 +316,10 @@ export default memo(() => { { hasFonts && <> - 搜索结果 + + 搜索结果 + handBack()}>返回 + { !!searchList.length && searchList.map((item, index) => { diff --git a/src/styles/iconfont.scss b/src/styles/iconfont.scss index 270a92f..7e79cb2 100644 --- a/src/styles/iconfont.scss +++ b/src/styles/iconfont.scss @@ -2,7 +2,7 @@ font-family: "iconfont"; /* Project id 3619513 */ src: - url('iconfont.ttf?t=1663065236955') format('truetype'); + url('/src/styles/iconfont.ttf') format('truetype'); } .iconfont {