diff --git a/app/Http/Controllers/VipCenterController.php b/app/Http/Controllers/VipCenterController.php index 86e5daf..c52e4b6 100644 --- a/app/Http/Controllers/VipCenterController.php +++ b/app/Http/Controllers/VipCenterController.php @@ -23,7 +23,7 @@ class VipCenterController extends Controller * * @param Request $request 当前请求对象 */ - public function index(Request $request): View + public function index(Request $request): View|\Illuminate\Http\JsonResponse { $user = $request->user(); @@ -47,10 +47,46 @@ class VipCenterController extends Controller ->where('status', 'paid') ->sum('amount'); - return view('vip.center', [ - 'user' => $user, - 'vipLevels' => $vipLevels, - 'paymentLogs' => $paymentLogs, + $data = [ + 'user' => [ + 'id' => $user->id, + 'username' => $user->username, + 'is_vip' => $user->isVip(), + 'vip_name' => $user->vipName(), + 'hy_time' => $user->hy_time?->format('Y-m-d H:i'), + 'vip_level_id' => $user->vip_level_id, + 'can_customize' => $user->canCustomizeVipPresence(), + 'custom_join_message' => $user->custom_join_message, + 'custom_leave_message' => $user->custom_leave_message, + 'custom_join_effect' => $user->custom_join_effect, + 'custom_leave_effect' => $user->custom_leave_effect, + 'vip_level' => $user->vipLevel ? [ + 'id' => $user->vipLevel->id, + 'name' => $user->vipLevel->name, + 'icon' => $user->vipLevel->icon, + 'color' => $user->vipLevel->color, + 'join_effect' => $user->vipLevel->joinEffectKey(), + 'join_banner' => $user->vipLevel->joinBannerStyleKey(), + 'leave_effect' => $user->vipLevel->leaveEffectKey(), + 'leave_banner' => $user->vipLevel->leaveBannerStyleKey(), + 'join_templates' => $user->vipLevel->join_templates_array, + 'leave_templates' => $user->vipLevel->leave_templates_array, + ] : null, + ], + 'vipLevels' => $vipLevels->map(function ($vip) { + return [ + 'id' => $vip->id, + 'name' => $vip->name, + 'icon' => $vip->icon, + 'color' => $vip->color, + 'price' => $vip->price, + 'duration_days' => $vip->duration_days, + 'exp_multiplier' => $vip->exp_multiplier, + 'jjb_multiplier' => $vip->jjb_multiplier, + 'description' => $vip->description, + ]; + }), + 'paymentLogs' => $paymentLogs->items(), 'vipPaymentEnabled' => Sysparam::getValue('vip_payment_enabled', '0') === '1', 'paidOrders' => $paidOrders, 'totalAmount' => $totalAmount, @@ -74,18 +110,34 @@ class VipCenterController extends Controller 'cosmic' => '星穹幻彩', 'farewell' => '告别暮光', ], - ]); + ]; + + if ($request->expectsJson()) { + return response()->json([ + 'status' => 'success', + 'data' => $data, + ]); + } + + return view('vip.center', $data); } /** * 保存会员个人自定义欢迎语与离开语。 */ - public function updatePresenceSettings(UpdateVipPresenceSettingsRequest $request): RedirectResponse + public function updatePresenceSettings(UpdateVipPresenceSettingsRequest $request): RedirectResponse|\Illuminate\Http\JsonResponse { $user = $request->user(); // 只有有效会员且当前等级允许自定义时,才允许保存专属语句。 if (! $user->canCustomizeVipPresence()) { + if ($request->expectsJson()) { + return response()->json([ + 'status' => 'error', + 'message' => '当前会员等级暂不支持自定义欢迎语和离开语。', + ], 403); + } + return redirect() ->route('vip.center') ->with('error', '当前会员等级暂不支持自定义欢迎语和离开语。'); @@ -97,11 +149,20 @@ class VipCenterController extends Controller $user->update([ 'custom_join_message' => $this->sanitizeNullableMessage($data['custom_join_message'] ?? null), 'custom_leave_message' => $this->sanitizeNullableMessage($data['custom_leave_message'] ?? null), + 'custom_join_effect' => $data['custom_join_effect'] ?? null, + 'custom_leave_effect' => $data['custom_leave_effect'] ?? null, ]); + if ($request->expectsJson()) { + return response()->json([ + 'status' => 'success', + 'message' => '设置已保存。', + ]); + } + return redirect() ->route('vip.center') - ->with('success', '会员专属欢迎语和离开语已保存。'); + ->with('success', '设置已保存。'); } /** diff --git a/app/Http/Requests/UpdateVipPresenceSettingsRequest.php b/app/Http/Requests/UpdateVipPresenceSettingsRequest.php index 97fca8d..f0c20d7 100644 --- a/app/Http/Requests/UpdateVipPresenceSettingsRequest.php +++ b/app/Http/Requests/UpdateVipPresenceSettingsRequest.php @@ -27,6 +27,8 @@ class UpdateVipPresenceSettingsRequest extends FormRequest return [ 'custom_join_message' => ['nullable', 'string', 'max:255'], 'custom_leave_message' => ['nullable', 'string', 'max:255'], + 'custom_join_effect' => ['nullable', 'string', 'max:30'], + 'custom_leave_effect' => ['nullable', 'string', 'max:30'], ]; } diff --git a/app/Models/User.php b/app/Models/User.php index d624e85..c44725c 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -37,6 +37,8 @@ class User extends Authenticatable 'sign', 'custom_join_message', 'custom_leave_message', + 'custom_join_effect', + 'custom_leave_effect', 'user_level', 'inviter_id', 'room_id', diff --git a/app/Services/VipPresenceService.php b/app/Services/VipPresenceService.php index 7cb0b4f..ac4ffcd 100644 --- a/app/Services/VipPresenceService.php +++ b/app/Services/VipPresenceService.php @@ -76,12 +76,21 @@ class VipPresenceService ? $this->vipService->getJoinMessage($user) : $this->vipService->getLeaveMessage($user); + // 只有在等级允许自定义时,才允许覆盖默认特效。 + $customEffect = $type === 'join' + ? $user->custom_join_effect + : $user->custom_leave_effect; + + if (! $user->canCustomizeVipPresence()) { + $customEffect = null; + } + return [ 'enabled' => true, 'type' => $type, 'text' => $customMessage ?: $templateMessage, 'color' => $vipLevel->color ?: '#f59e0b', - 'effect' => $type === 'join' ? $this->normalizeEffect($vipLevel->joinEffectKey()) : $this->normalizeEffect($vipLevel->leaveEffectKey()), + 'effect' => $this->normalizeEffect($customEffect ?: ($type === 'join' ? $vipLevel->joinEffectKey() : $vipLevel->leaveEffectKey())), 'banner_style' => $type === 'join' ? $vipLevel->joinBannerStyleKey() : $vipLevel->leaveBannerStyleKey(), 'level_name' => $vipLevel->name, 'icon' => $vipLevel->icon, diff --git a/database/migrations/2026_04_12_170218_add_custom_effects_to_users_table.php b/database/migrations/2026_04_12_170218_add_custom_effects_to_users_table.php new file mode 100644 index 0000000..44d79d8 --- /dev/null +++ b/database/migrations/2026_04_12_170218_add_custom_effects_to_users_table.php @@ -0,0 +1,29 @@ +string('custom_join_effect', 30)->nullable()->after('custom_leave_message')->comment('用户自定义入场特效'); + $table->string('custom_leave_effect', 30)->nullable()->after('custom_join_effect')->comment('用户自定义离场特效'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn(['custom_join_effect', 'custom_leave_effect']); + }); + } +}; diff --git a/resources/views/chat/partials/layout/mobile-drawer.blade.php b/resources/views/chat/partials/layout/mobile-drawer.blade.php index 778ea74..3e41358 100644 --- a/resources/views/chat/partials/layout/mobile-drawer.blade.php +++ b/resources/views/chat/partials/layout/mobile-drawer.blade.php @@ -32,7 +32,7 @@
🛒
商店
-
👑
会员
+
👑
会员
💾
存点
🎮
娱乐
🏦
银行
diff --git a/resources/views/chat/partials/layout/toolbar.blade.php b/resources/views/chat/partials/layout/toolbar.blade.php index cc45882..b85c6d9 100644 --- a/resources/views/chat/partials/layout/toolbar.blade.php +++ b/resources/views/chat/partials/layout/toolbar.blade.php @@ -16,7 +16,7 @@ {{-- ═══════════ 竖向工具条按钮 ═══════════ --}}
商店
-
会员
+
会员
存点
娱乐
赚钱
@@ -1434,6 +1434,400 @@ async function generateWechatBindCode() { })(); +{{-- ═══════════ 会员中心弹窗 ═══════════ --}} + + +
+
+
+
👑 会员中心
+
+ + + +
+ × +
+ + {{-- 会员中心面板 --}} +
+
+
+
我的会员状态
+
加载中...
+
+
+
+
累计已支付
+
¥0.00
+
+
+ +
会员等级列表
+
+ +
+
+ + {{-- 会员相关设置面板 --}} +
+
+
+
+
+
+
+
当前主题预览
+
普通用户
+
+
+
+
+
入场特效
+
+
+
+
+
离场特效
+
+
+
+
+
+ +
+
等级默认语句
+
+
+
默认欢迎语
+
+
+
+
默认离开语
+
+
+
+
+
+ +
+
+
我的个性化设置
+ +
+ + + + +
+
+
+ + {{-- 购买记录面板 --}} +
+
+ + + + + + + + + + + + + +
订单号等级金额状态开通时间
+
+
+
+
+ + + {{-- ═══════════ 婚姻状态弹窗 ═══════════ --}}