🦄 refactor:搜索页点击搜索

This commit is contained in:
Haiyi 2022-09-16 18:43:14 +08:00
parent 9342906c67
commit c2fa0766aa
3 changed files with 49 additions and 10 deletions

View File

@ -30,14 +30,32 @@ page {
justify-content: space-between; justify-content: space-between;
margin-bottom: 32px; margin-bottom: 32px;
.histroyFonts { .histroyLeft {
margin-left: 32px; display: flex;
font-size: 28px; align-items: center;
font-family: PingFangSC-Regular, PingFang SC; justify-content: space-between;
font-weight: 400; width: 100%;
color: #000000; 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 { .icon_delect {
margin-right: 45px; margin-right: 45px;
color: #f7f7f7; color: #f7f7f7;

View File

@ -144,7 +144,6 @@ export default memo(() => {
const [goodObj, setGoodsobj] = useState({}) const [goodObj, setGoodsobj] = useState({})
//点击对应商品显示购物车 //点击对应商品显示购物车
const showCart = async (item) => { const showCart = async (item) => {
console.log(item, 6666)
setSearchObj((e) => ({ ...e, goodsId: item.id })) setSearchObj((e) => ({ ...e, goodsId: item.id }))
setShowShopCart(true) setShowShopCart(true)
setGoodsobj(item) setGoodsobj(item)
@ -269,6 +268,25 @@ export default memo(() => {
setGoodlist([...goodList]) 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 ( return (
<View className={styles.main}> <View className={styles.main}>
<Search placeholder='请输入搜索布料' showBtn={false} changeOnSearch={getSearchData} debounceTime={300} > <Search placeholder='请输入搜索布料' showBtn={false} changeOnSearch={getSearchData} debounceTime={300} >
@ -285,7 +303,7 @@ export default memo(() => {
<View className={styles.bigBox}> <View className={styles.bigBox}>
{histroyList.map((item, index) => { {histroyList.map((item, index) => {
return ( return (
<View key={index} className={styles.itemBox}>{item.search_key}</View> <View onClick={() => handItem(item)} key={index} className={styles.itemBox}>{item.search_key}</View>
) )
})} })}
</View> </View>
@ -298,7 +316,10 @@ export default memo(() => {
{ {
hasFonts && <> hasFonts && <>
<View className={styles.topBox}> <View className={styles.topBox}>
<View className={styles.histroyFonts}></View> <View className={styles.histroyLeft}>
<View className={styles.histroyFonts}></View>
<View className={styles.back} onClick={() => handBack()}></View>
</View>
</View> </View>
{ {
!!searchList.length && searchList.map((item, index) => { !!searchList.length && searchList.map((item, index) => {

View File

@ -2,7 +2,7 @@
font-family: "iconfont"; font-family: "iconfont";
/* Project id 3619513 */ /* Project id 3619513 */
src: src:
url('iconfont.ttf?t=1663065236955') format('truetype'); url('/src/styles/iconfont.ttf') format('truetype');
} }
.iconfont { .iconfont {