fix resource buy & download
Change-Id: I3c350410eb424ada9e757e04c8498637740073db
diff --git "a/src/app/resource/resource-detail/\133resourceId\135/page.tsx" "b/src/app/resource/resource-detail/\133resourceId\135/page.tsx"
index 22abfdb..baec9a6 100644
--- "a/src/app/resource/resource-detail/\133resourceId\135/page.tsx"
+++ "b/src/app/resource/resource-detail/\133resourceId\135/page.tsx"
@@ -570,6 +570,26 @@
}
};
+ const buyResource = async () => {
+ console.log("Buy Resource")
+ try {
+ const response = await axios.post(process.env.PUBLIC_URL + '/resource/purchase', {
+ userId,
+ resourceId
+ });
+
+ if (response.status === 200) {
+ toast.current?.show({ severity: 'success', summary: 'Success', detail: '购买成功' });
+ } else {
+ toast.current?.show({ severity: 'error', summary: 'error', detail: '购买失败' });
+
+ }
+ } catch (error) {
+ console.error('购买失败:', error);
+ toast.current?.show({ severity: 'error', summary: 'error', detail: '购买失败' });
+ }
+ }
+
// 发布评论接口
const publishComment = async () => {
if (!commentValue.trim() || !resource) return;
@@ -739,12 +759,11 @@
</div>
<ButtonGroup >
- {isPurchase()}
<Button label={"$" + resource?.price} style={{
height: "44px", background: "rgba(82, 102, 101, 1)",
borderStyle: "solid", borderWidth: "1px", borderColor: "rgba(82, 102, 101, 1)",
borderRadius: "0 20px 20px 0", fontSize: "26px",
- }} disabled={true} />
+ }} onClick={buyResource} />
</ButtonGroup>
</div>
</div>