修复:confirmGift null错误(先保存item再关弹框);MessageSent改为ShouldBroadcastNow立即广播;修复route()引号冲突
This commit is contained in:
@@ -12,11 +12,11 @@ namespace App\Events;
|
|||||||
|
|
||||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
use Illuminate\Broadcasting\PresenceChannel;
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class MessageSent implements ShouldBroadcast
|
class MessageSent implements ShouldBroadcastNow
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
|||||||
@@ -117,8 +117,8 @@ class ShopController extends Controller
|
|||||||
: '';
|
: '';
|
||||||
$sysContent = "{$icon} 【{$user->username}】送出了一张 [{$item->name}],赠给 {$toStr}!{$msgText}";
|
$sysContent = "{$icon} 【{$user->username}】送出了一张 [{$item->name}],赠给 {$toStr}!{$msgText}";
|
||||||
|
|
||||||
// 广播系统消息到公屏
|
// 广播系统消息到公屏(ShouldBroadcastNow 模式)
|
||||||
broadcast(new MessageSent(
|
$sysMsgEvent = new MessageSent(
|
||||||
roomId: $roomId,
|
roomId: $roomId,
|
||||||
message: [
|
message: [
|
||||||
'id' => 0,
|
'id' => 0,
|
||||||
@@ -129,7 +129,8 @@ class ShopController extends Controller
|
|||||||
'color' => '#cc6600',
|
'color' => '#cc6600',
|
||||||
'created_at' => now()->toDateTimeString(),
|
'created_at' => now()->toDateTimeString(),
|
||||||
]
|
]
|
||||||
));
|
);
|
||||||
|
broadcast($sysMsgEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -870,8 +870,10 @@
|
|||||||
const recipient = document.getElementById('gift-recipient').value.trim();
|
const recipient = document.getElementById('gift-recipient').value.trim();
|
||||||
const message = document.getElementById('gift-message').value.trim();
|
const message = document.getElementById('gift-message').value.trim();
|
||||||
document.getElementById('gift-err').textContent = '';
|
document.getElementById('gift-err').textContent = '';
|
||||||
|
// 先将商品数据保存到局部变量,再关闭弹框(closeGiftDialog 会把 _giftItem 设为 null)
|
||||||
|
const item = _giftItem;
|
||||||
closeGiftDialog();
|
closeGiftDialog();
|
||||||
buyItem(_giftItem.id, _giftItem.name, _giftItem.price, recipient, message);
|
buyItem(item.id, item.name, item.price, recipient, message);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 购买商品(最终执行) */
|
/** 购买商品(最终执行) */
|
||||||
|
|||||||
Reference in New Issue
Block a user