diff --git a/app/Http/Controllers/FishingController.php b/app/Http/Controllers/FishingController.php
index 87ff46b..46d0814 100644
--- a/app/Http/Controllers/FishingController.php
+++ b/app/Http/Controllers/FishingController.php
@@ -192,6 +192,7 @@ class FishingController extends Controller
'result' => $result,
'exp_num' => $user->exp_num,
'jjb' => $user->jjb,
+ 'cooldown_seconds' => $cooldown, // 前端自动钓鱼卡循环等待用
]);
}
diff --git a/resources/views/chat/partials/scripts.blade.php b/resources/views/chat/partials/scripts.blade.php
index 139f14e..5201848 100644
--- a/resources/views/chat/partials/scripts.blade.php
+++ b/resources/views/chat/partials/scripts.blade.php
@@ -1623,6 +1623,9 @@
let fishingTimer = null;
let fishingReelTimeout = null;
let _fishToken = null; // 当次钓鱼的 token
+ let _autoFishing = false; // 是否处于自动钓鱼循环中
+ let _autoFishCdTimer = null; // 自动钓鱼冷却计时器
+ let _autoFishCdCountdown = null; // 冷却倒计时 interval
/**
* 创建浮漂 DOM 元素(绝对定位在聊天框上层)
@@ -1707,6 +1710,7 @@
// 保存本次 token(收竿时提交)
_fishToken = data.token;
+ _autoFishing = !!data.auto_fishing; // 持有自动钓鱼卡则开启循环模式
// 聊天框提示
const castDiv = document.createElement('div');
@@ -1830,25 +1834,139 @@
` (经验:${data.exp_num} 金币:${data.jjb})` +
`(${timeStr})`;
container2.appendChild(resultDiv);
+
+ // 自动钓鱼卡循环:等冷却时间后自动再次抛竿
+ if (_autoFishing) {
+ const cooldown = data.cooldown_seconds || 300;
+ const btn = document.getElementById('fishing-btn');
+ btn.disabled = true;
+ btn.textContent = `⏳ 冷却 ${cooldown}s`;
+ btn.onclick = null;
+
+ // 显示停止按钮
+ _showAutoFishStopBtn(cooldown);
+
+ // 倒计时更新文字
+ let remaining = cooldown;
+ _autoFishCdCountdown = setInterval(() => {
+ remaining--;
+ const b = document.getElementById('fishing-btn');
+ if (b) b.textContent = `⏳ 冷却 ${remaining}s`;
+ if (remaining <= 0) {
+ clearInterval(_autoFishCdCountdown);
+ _autoFishCdCountdown = null;
+ }
+ }, 1000);
+
+ // 冷却结束后自动抛竿
+ _autoFishCdTimer = setTimeout(() => {
+ _autoFishCdTimer = null;
+ _hideAutoFishStopBtn();
+ if (_autoFishing) startFishing(); // 仍未停止 → 继续
+ }, cooldown * 1000);
+
+ if (autoScroll) container2.scrollTop = container2.scrollHeight;
+ return; // 不走 resetFishingBtn
+ }
} else {
const errDiv = document.createElement('div');
errDiv.className = 'msg-line';
errDiv.innerHTML =
`【钓鱼】${data.message || '操作失败'}(${timeStr})`;
container2.appendChild(errDiv);
+ _autoFishing = false; // 出错时停止循环
}
if (autoScroll) container2.scrollTop = container2.scrollHeight;
} catch (e) {
window.chatDialog.alert('网络错误:' + e.message, '网络异常', '#cc4444');
+ _autoFishing = false;
}
resetFishingBtn();
}
/**
- * 重置钓鱼按钮状态
+ * 显示「停止自动钓鱼」悬浮按钮
+ * @param {number} cooldown 冷却秒数(用于倒计时提示)
+ */
+ function _showAutoFishStopBtn(cooldown) {
+ if (document.getElementById('auto-fish-stop-btn')) return;
+ const stopBtn = document.createElement('button');
+ stopBtn.id = 'auto-fish-stop-btn';
+ stopBtn.innerHTML = '🛑 停止自动钓鱼';
+ stopBtn.style.cssText = `
+ position: fixed;
+ bottom: 80px;
+ right: 20px;
+ z-index: 10000;
+ background: linear-gradient(135deg, #dc2626, #b91c1c);
+ color: #fff;
+ border: none;
+ border-radius: 20px;
+ padding: 8px 18px;
+ font-size: 13px;
+ font-weight: bold;
+ cursor: pointer;
+ box-shadow: 0 4px 12px rgba(220,38,38,0.4);
+ animation: autoFishBtnPulse 1.8s ease-in-out infinite;
+ `;
+ if (!document.getElementById('auto-fish-stop-style')) {
+ const s = document.createElement('style');
+ s.id = 'auto-fish-stop-style';
+ s.textContent = `@keyframes autoFishBtnPulse {
+ 0%,100% { transform: scale(1); }
+ 50% { transform: scale(1.05); }
+ }`;
+ document.head.appendChild(s);
+ }
+ stopBtn.onclick = stopAutoFishing;
+ document.body.appendChild(stopBtn);
+ }
+
+ /** 隐藏停止按钮 */
+ function _hideAutoFishStopBtn() {
+ const el = document.getElementById('auto-fish-stop-btn');
+ if (el) el.remove();
+ }
+
+ /**
+ * 手动停止自动钓鱼循环
+ */
+ function stopAutoFishing() {
+ _autoFishing = false;
+ if (_autoFishCdTimer) {
+ clearTimeout(_autoFishCdTimer);
+ _autoFishCdTimer = null;
+ }
+ if (_autoFishCdCountdown) {
+ clearInterval(_autoFishCdCountdown);
+ _autoFishCdCountdown = null;
+ }
+ _hideAutoFishStopBtn();
+
+ const noticeDiv = document.createElement('div');
+ noticeDiv.className = 'msg-line';
+ noticeDiv.innerHTML = '🛑 已停止自动钓鱼。';
+ container2.appendChild(noticeDiv);
+ if (autoScroll) container2.scrollTop = container2.scrollHeight;
+
+ resetFishingBtn();
+ }
+
+ /**
+ * 重置钓鱼按钮状态(停止自动循环后调用)
*/
function resetFishingBtn() {
+ _autoFishing = false;
+ _hideAutoFishStopBtn();
+ if (_autoFishCdTimer) {
+ clearTimeout(_autoFishCdTimer);
+ _autoFishCdTimer = null;
+ }
+ if (_autoFishCdCountdown) {
+ clearInterval(_autoFishCdCountdown);
+ _autoFishCdCountdown = null;
+ }
const btn = document.getElementById('fishing-btn');
btn.textContent = '🎣 钓鱼';
btn.disabled = false;