From f16f10fe8228de939404d6dcc0ec76565ca8a471 Mon Sep 17 00:00:00 2001 From: pllx Date: Tue, 28 Apr 2026 11:37:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E8=B4=AD=E4=B9=B0?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=92=93=E9=B1=BC=E5=8D=A1=E5=90=8E=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=BC=80=E5=90=AF=E9=92=93=E9=B1=BC=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/ShopController.php | 5 +++++ resources/js/chat-room/shop-controls.js | 21 ++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/ShopController.php b/app/Http/Controllers/ShopController.php index 562666d..b1dca54 100644 --- a/app/Http/Controllers/ShopController.php +++ b/app/Http/Controllers/ShopController.php @@ -125,6 +125,11 @@ class ShopController extends Controller 'total_price' => $result['total_price'] ?? $item->price, ]; + // 购买自动钓鱼卡后返回剩余分钟数,前端用于自动开启钓鱼 + if ($item->type === 'auto_fishing') { + $response['auto_fishing_minutes_left'] = $this->shopService->getActiveAutoFishingMinutesLeft($user); + } + // ── 装扮购买:向前端透传槽位与样式信息,用于即时更新装扮状态 ── if (! empty($result['slot'])) { $response['slot'] = $result['slot']; diff --git a/resources/js/chat-room/shop-controls.js b/resources/js/chat-room/shop-controls.js index 59686bd..fb1714e 100644 --- a/resources/js/chat-room/shop-controls.js +++ b/resources/js/chat-room/shop-controls.js @@ -556,7 +556,7 @@ async function confirmAndBuyItem(item) { const confirmed = await confirmShopPurchase(confirmMessage); if (confirmed) { - buyItem(item.id, item.name, item.price, "all", "", quantity); + buyItem(item.id, item.name, item.price, "all", "", quantity, item.type); } } @@ -645,7 +645,7 @@ export function confirmGift() { } closeGiftDialog(); - buyItem(item.id, item.name, item.price, recipient, message); + buyItem(item.id, item.name, item.price, recipient, message, 1, item.type); } /** @@ -659,7 +659,7 @@ export function confirmGift() { * @param {number} quantity 购买数量 * @returns {Promise} */ -export async function buyItem(itemId, name, price, recipient, message, quantity = 1) { +export async function buyItem(itemId, name, price, recipient, message, quantity = 1, itemType = '') { try { const response = await fetch(getShopUrls().buy, { method: "POST", @@ -675,7 +675,7 @@ export async function buyItem(itemId, name, price, recipient, message, quantity const data = await response.json(); if (data.status === "success") { - handleBuySuccess(data, name); + handleBuySuccess(data, name, itemType); return; } @@ -692,7 +692,7 @@ export async function buyItem(itemId, name, price, recipient, message, quantity * @param {string} itemName 商品名称 * @returns {void} */ -function handleBuySuccess(data, itemName) { +function handleBuySuccess(data, itemName, itemType = '') { const balance = document.getElementById("shop-jjb"); if (data.jjb !== undefined && balance) { @@ -717,8 +717,15 @@ function handleBuySuccess(data, itemName) { shopLoaded = false; setTimeout(() => { fetchShopData(); - shopLoaded = true; - }, 1000); + }, 300); + + // 自动钓鱼卡购买后立即开启自动钓鱼 + if (itemType === "auto_fishing" && typeof window.checkAndAutoStartFishing === "function") { + if (!window.chatContext) window.chatContext = {}; + window.chatContext.autoFishingMinutesLeft = Number(data.auto_fishing_minutes_left || 1); + window.chatContext.fishingCooldownSeconds = 0; + setTimeout(() => window.checkAndAutoStartFishing(), 500); + } } /**