|
@@ -32,24 +32,24 @@ export default function HomeScreen() {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
axiosInstance.interceptors.request.use(
|
|
axiosInstance.interceptors.request.use(
|
|
|
- (config) => {
|
|
|
|
|
|
|
+ config => {
|
|
|
config.headers = config.headers || {};
|
|
config.headers = config.headers || {};
|
|
|
if (token) {
|
|
if (token) {
|
|
|
config.headers["Authorization"] = "Bearer " + token;
|
|
config.headers["Authorization"] = "Bearer " + token;
|
|
|
}
|
|
}
|
|
|
return config;
|
|
return config;
|
|
|
},
|
|
},
|
|
|
- (error) => {
|
|
|
|
|
|
|
+ error => {
|
|
|
return Promise.reject(error);
|
|
return Promise.reject(error);
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
axiosInstance.interceptors.response.use(
|
|
axiosInstance.interceptors.response.use(
|
|
|
- (response) => {
|
|
|
|
|
|
|
+ response => {
|
|
|
setError("");
|
|
setError("");
|
|
|
return response.data;
|
|
return response.data;
|
|
|
},
|
|
},
|
|
|
- (error) => {
|
|
|
|
|
|
|
+ error => {
|
|
|
setError(error.response.data.error);
|
|
setError(error.response.data.error);
|
|
|
return Promise.reject(error.response.data);
|
|
return Promise.reject(error.response.data);
|
|
|
}
|
|
}
|
|
@@ -59,13 +59,13 @@ export default function HomeScreen() {
|
|
|
|
|
|
|
|
const chooseGoods = React.useMemo(() => {
|
|
const chooseGoods = React.useMemo(() => {
|
|
|
if (selectGoodsId) {
|
|
if (selectGoodsId) {
|
|
|
- return goods.find((item) => {
|
|
|
|
|
|
|
+ return goods.find(item => {
|
|
|
return item.id == selectGoodsId;
|
|
return item.id == selectGoodsId;
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
return {};
|
|
return {};
|
|
|
}
|
|
}
|
|
|
- }, [selectGoodsId]);
|
|
|
|
|
|
|
+ }, [selectGoodsId, goods]);
|
|
|
|
|
|
|
|
useFocusEffect(
|
|
useFocusEffect(
|
|
|
React.useCallback(() => {
|
|
React.useCallback(() => {
|
|
@@ -76,14 +76,14 @@ export default function HomeScreen() {
|
|
|
.post("/auth/login", data, {
|
|
.post("/auth/login", data, {
|
|
|
withCredentials: true,
|
|
withCredentials: true,
|
|
|
})
|
|
})
|
|
|
- .then((res) => {
|
|
|
|
|
|
|
+ .then(res => {
|
|
|
setToken(res);
|
|
setToken(res);
|
|
|
});
|
|
});
|
|
|
}, [])
|
|
}, [])
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
const GoodsInfos = () => {
|
|
const GoodsInfos = () => {
|
|
|
- return goods.map((item) => (
|
|
|
|
|
|
|
+ return goods.map(item => (
|
|
|
<Picker.Item
|
|
<Picker.Item
|
|
|
label={item.name + "-" + item.merchantId}
|
|
label={item.name + "-" + item.merchantId}
|
|
|
value={item.id}
|
|
value={item.id}
|
|
@@ -92,13 +92,17 @@ export default function HomeScreen() {
|
|
|
));
|
|
));
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
React.useEffect(() => {
|
|
React.useEffect(() => {
|
|
|
if (token) {
|
|
if (token) {
|
|
|
console.log(token);
|
|
console.log(token);
|
|
|
- axiosInstance.get("/goods/all").then((res) => {
|
|
|
|
|
- console.log(res.content);
|
|
|
|
|
- setGoods(res.content);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ axiosInstance
|
|
|
|
|
+ .get("/goods/all?size=999&sort=id,desc")
|
|
|
|
|
+ .then(res => {
|
|
|
|
|
+ console.log(res.content);
|
|
|
|
|
+ setGoods(res.content);
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
}, [token, check]);
|
|
}, [token, check]);
|
|
|
|
|
|
|
@@ -128,7 +132,7 @@ export default function HomeScreen() {
|
|
|
selectGoodsId +
|
|
selectGoodsId +
|
|
|
"&pass=true"
|
|
"&pass=true"
|
|
|
)
|
|
)
|
|
|
- .then((res) => {
|
|
|
|
|
|
|
+ .then(res => {
|
|
|
changeCheck(!check);
|
|
changeCheck(!check);
|
|
|
});
|
|
});
|
|
|
}}
|
|
}}
|
|
@@ -148,7 +152,7 @@ export default function HomeScreen() {
|
|
|
.post("/shoppingCart/cart", data, {
|
|
.post("/shoppingCart/cart", data, {
|
|
|
withCredentials: true,
|
|
withCredentials: true,
|
|
|
})
|
|
})
|
|
|
- .then((res) => {
|
|
|
|
|
|
|
+ .then(res => {
|
|
|
setCartId(res.id);
|
|
setCartId(res.id);
|
|
|
});
|
|
});
|
|
|
}}
|
|
}}
|
|
@@ -166,7 +170,7 @@ export default function HomeScreen() {
|
|
|
.post("/orderInfo/order", data, {
|
|
.post("/orderInfo/order", data, {
|
|
|
withCredentials: true,
|
|
withCredentials: true,
|
|
|
})
|
|
})
|
|
|
- .then((res) => {
|
|
|
|
|
|
|
+ .then(res => {
|
|
|
setOrderId(res.id);
|
|
setOrderId(res.id);
|
|
|
});
|
|
});
|
|
|
}}
|
|
}}
|