mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 20:17:24 +08:00
mybonus.php remove medal
This commit is contained in:
+19
-9
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
require "../include/bittorrent.php";
|
||||
|
||||
$query = \App\Models\Medal::query();
|
||||
$query = \App\Models\Medal::query()->where('get_type', \App\Models\Medal::GET_TYPE_EXCHANGE);
|
||||
$q = htmlspecialchars($_REQUEST['q'] ?? '');
|
||||
if (!empty($q)) {
|
||||
$query->where('username', 'name', "%{$q}%");
|
||||
@@ -18,9 +18,9 @@ $columnPriceLabel = nexus_trans('medal.fields.price');
|
||||
$columnDurationLabel = nexus_trans('medal.fields.duration');
|
||||
$columnDescriptionLabel = nexus_trans('medal.fields.description');
|
||||
$columnActionLabel = nexus_trans('nexus.action');
|
||||
$header = '<h1 style="text-align: center">'.$title.'</h1>';
|
||||
$filterForm = <<<FORM
|
||||
<div>
|
||||
<h1 style="text-align: center">$title</h1>
|
||||
<form id="filterForm" action="{$_SERVER['REQUEST_URI']}" method="get">
|
||||
<input id="q" type="text" name="q" value="{$q}" placeholder="username">
|
||||
<input type="submit">
|
||||
@@ -37,6 +37,7 @@ $table = <<<TABLE
|
||||
<td class="colhead">ID</td>
|
||||
<td class="colhead">$columnNameLabel</td>
|
||||
<td class="colhead">$columnImageLargeLabel</td>
|
||||
<td class="colhead">$columnPriceLabel</td>
|
||||
<td class="colhead">$columnDurationLabel</td>
|
||||
<td class="colhead">$columnDescriptionLabel</td>
|
||||
<td class="colhead">$columnActionLabel</td>
|
||||
@@ -44,10 +45,18 @@ $table = <<<TABLE
|
||||
</thead>
|
||||
TABLE;
|
||||
$table .= '<tbody>';
|
||||
$userMedals = \App\Models\UserMedal::query()->where('uid', $CURUSER['id'])->orderBy('id', 'desc')->get()->keyBy('medal_id');
|
||||
$userMedals = \App\Models\UserMedal::query()->where('uid', $CURUSER['id'])
|
||||
->orderBy('id', 'desc')
|
||||
->get()
|
||||
->keyBy('medal_id')
|
||||
;
|
||||
foreach ($rows as $row) {
|
||||
if ($userMedals->has($CURUSER['id'])) {
|
||||
$btnText = nexus_trans('medal.buy_already');
|
||||
if ($userMedals->has($row->id) || $CURUSER['seedbonus'] < $row->price) {
|
||||
if ($userMedals->has($row->id)) {
|
||||
$btnText = nexus_trans('medal.buy_already');
|
||||
} else {
|
||||
$btnText = nexus_trans('medal.require_more_bonus');
|
||||
}
|
||||
$disabled = ' disabled';
|
||||
$class = '';
|
||||
} else {
|
||||
@@ -60,16 +69,17 @@ foreach ($rows as $row) {
|
||||
$class, $row->id, $btnText, $disabled
|
||||
);
|
||||
$table .= sprintf(
|
||||
'<tr><td>%s</td><td>%s</td><td><img src="%s" style="max-width: 60px;max-height: 60px;" class="preview" /></td><td>%s</td><td>%s</td><td>%s</td>',
|
||||
$row->id, $row->name, $row->image_large, $row->duration, $row->description, $action
|
||||
'<tr><td>%s</td><td>%s</td><td><img src="%s" style="max-width: 60px;max-height: 60px;" class="preview" /></td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>',
|
||||
$row->id, $row->name, $row->image_large, number_format($row->price), $row->duration, $row->description, $action
|
||||
);
|
||||
}
|
||||
$table .= '</tbody></table>';
|
||||
echo $table . $paginationBottom;
|
||||
echo $header . $table . $paginationBottom;
|
||||
$confirmMsg = nexus_trans('medal.confirm_to_buy');
|
||||
$js = <<<JS
|
||||
jQuery('.buy').on('click', function (e) {
|
||||
let medalId = jQuery(this).attr('data-id')
|
||||
layer.confirm("确定要购买吗?", function (index) {
|
||||
layer.confirm("{$confirmMsg}", function (index) {
|
||||
let params = {
|
||||
action: "buyMedal",
|
||||
params: {medal_id: medalId}
|
||||
|
||||
Reference in New Issue
Block a user