+
{nav(`/detail?id=${item._id}`)}}>
@@ -195,7 +211,7 @@ export default function Classfy() {
¥{item.price}
-
+ {tocar(item)}} />
diff --git a/src/jjt/Home.jsx b/src/jjt/Home.jsx
index 6cee358ebe09d61df0f11bc5467a18f6261cf228..2562d2464517f7e76ad6a524d121298066cc2f9d 100644
--- a/src/jjt/Home.jsx
+++ b/src/jjt/Home.jsx
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react";
import "./scss/Home.scss";
import { Search } from "react-vant";
import { Badge } from "react-vant";
+import { Toast } from 'react-vant';
import { ChatO } from "@react-vant/icons";
import { Swiper } from "react-vant";
import IconFont from "../jjt/untils/Icon"; //icon图标
@@ -30,7 +31,7 @@ export default function Home() {
};
const hotsearch = ["Vue", "Python", "React", "布局"]; //热搜
const [value, setValue] = useState(""); //热搜
- let Toast = (i) => {
+ let Toast2 = (i) => {
// console.log(i);
setValue(hotsearch[i]);
};
@@ -65,6 +66,22 @@ export default function Home() {
console.log(item._id, 2223);
nav("/jjtclassfy", { state: { _id: item._id } });
};
+ //加入购物车
+ let tocar = async(item) => {
+ console.log(item,555555555)
+ let {data} = await axios.post("/jjt/caradd", item);
+ console.log(data,6666)
+ if(data.code===200){
+ Toast({
+ message: '加入购物车成功',
+ // icon:
,
+ })
+ }else{
+ Toast({
+ message: '加入购物车失败',
+ })
+ }
+ }
useEffect(() => {
getdata();
}, []);
@@ -191,8 +208,8 @@ export default function Home() {
.filter((ele) => ele.typeTwoId._id == item._id)
.slice(0, 2)
.map((i) => (
-
{nav(`/detail?id=${i._id}`)}}>
-
+
+
{nav(`/detail?id=${i._id}`)}}>
@@ -206,7 +223,7 @@ export default function Home() {
¥{(i.price * i.discount) / 10}
¥{i.price}
-
+ {tocar(i)}} />
@@ -270,7 +287,7 @@ export default function Home() {
Toast(i)}
+ onChange={(i) => Toast2(i)}
>
{hotsearch.map((image) => (
{
+ console.log(item,555555555)
+ let {data} = await axios.post("/jjt/caradd", item);
+ console.log(data,6666)
+ if(data.code===200){
+ Toast({
+ message: '加入购物车成功',
+ // icon: ,
+ })
+ }else{
+ Toast({
+ message: '加入购物车失败',
+ })
+ }
+ }
useEffect(() => {
getdata();
mapsea()
@@ -98,7 +114,7 @@ export default function Searchs() {
>
搜索历史
-
+
{searhistory.map((item,index) => (
{
setValue(item.name);
@@ -109,7 +125,7 @@ export default function Searchs() {
热门搜索
-
+
{hotsearchs.map((item, index) => (
精选课程
{bookData.slice(0,9).map((item) => (
-
{nav(`/detail?id=${item._id}`)}}>
-
+
+
{nav(`/detail?id=${item._id}`)}}>
@@ -147,7 +163,7 @@ export default function Searchs() {
}}
>
¥{item.price}
-
+
{tocar(item)}} />
diff --git a/src/jjt/scss/Search.scss b/src/jjt/scss/Search.scss
index d5448b393082e04ec024a9c5c647bcf1469d8151..b1f10a5574a54de31c20e0a6545e12ec1b32e599 100644
--- a/src/jjt/scss/Search.scss
+++ b/src/jjt/scss/Search.scss
@@ -24,8 +24,9 @@ $designHeight: 667;
font-size: 14px;
font-weight: 600;
}
- .hot {
+ .hotjjt {
display: flex;
+ // background: red;
div {
border-radius: 5px;
background: #e3e3e5;
@@ -48,8 +49,10 @@ $designHeight: 667;
font-size: 14px;
font-weight: 600;
}
- .hot {
+ .hotjjt {
display: flex;
+ // background: red;
+ // height: vh(30);
div {
border-radius: 5px;
background: #e3e3e5;
diff --git a/src/jjt/untils/BottomFouter.jsx b/src/jjt/untils/BottomFouter.jsx
index b9f147bffb42c69f91ba8cc3f54ae8098bafedfc..a11ba5c3d1712c5d8e3d50fd28f56d2684ff2f45 100644
--- a/src/jjt/untils/BottomFouter.jsx
+++ b/src/jjt/untils/BottomFouter.jsx
@@ -1,13 +1,15 @@
import React from 'react'
import { Tabbar } from 'react-vant';
import { ShoppingCartO , HomeO, CouponO , ManagerO } from '@react-vant/icons'
+import { useNavigate } from 'react-router-dom';
export default function BottomFouter() {
+ let nav = useNavigate()
return (
}>主页
}>卖书
- }>购物车
+ } onClick={()=>(nav('/shopcar'))}>购物车
}>我的