🦄 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;
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;

View File

@ -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 (
<View className={styles.main}>
<Search placeholder='请输入搜索布料' showBtn={false} changeOnSearch={getSearchData} debounceTime={300} >
@ -285,7 +303,7 @@ export default memo(() => {
<View className={styles.bigBox}>
{histroyList.map((item, index) => {
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>
@ -298,7 +316,10 @@ export default memo(() => {
{
hasFonts && <>
<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>
{
!!searchList.length && searchList.map((item, index) => {

View File

@ -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 {