|
|
|
@@ -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<void>}
|
|
|
|
|
*/
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|