AddFeature: 添加管理员赞助管理
路由表操作,页面管理 创建、修改、删除 类型创建、修改、删除 修改: - api.php - web.php - aside.blade.php - Function/Sponsor.php 新增: - dashboard.blade.php - edit.blade.php - mode.blade.php - Console/Sponsor.php Signed-off-by: XiaoLFeng <gm@x-lf.cn>
This commit is contained in:
parent
9489402bfd
commit
e5fd13819f
762
app/Http/Controllers/Console/Sponsor.php
Normal file
762
app/Http/Controllers/Console/Sponsor.php
Normal file
|
@ -0,0 +1,762 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||
* https://www.x-lf.com/
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers\Console;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Index;
|
||||
use ErrorException;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class Sponsor extends Controller
|
||||
{
|
||||
|
||||
private array $data;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$data = new Index();
|
||||
$this->data = $data->data;
|
||||
}
|
||||
|
||||
public function apiEdit(Request $request, $sponsorId): JsonResponse
|
||||
{
|
||||
$getData = $request->all();
|
||||
$getData['id'] = $sponsorId;
|
||||
if (Auth::check()) {
|
||||
if (Auth::user()->admin) {
|
||||
$dataCheck = Validator::make($getData, [
|
||||
'id' => 'required|int',
|
||||
'name' => 'required|string',
|
||||
'type' => 'required|int',
|
||||
'money' => 'required|numeric',
|
||||
'url' => 'regex:#[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?#',
|
||||
'date' => 'required|string',
|
||||
]);
|
||||
// 检查是否符合规则
|
||||
if ($dataCheck->fails()) {
|
||||
$errorType = array_keys($dataCheck->failed());
|
||||
$i = 0;
|
||||
foreach ($dataCheck->failed() as $valueData) {
|
||||
$errorInfo[$errorType[$i]] = array_keys($valueData);
|
||||
if ($i == 0) {
|
||||
$errorSingle = [
|
||||
'info' => $errorType[$i],
|
||||
'need' => $errorInfo[$errorType[$i]],
|
||||
];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$returnData = [
|
||||
'output' => 'DataFormatError',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '输入内容有错误',
|
||||
'errorSingle' => $errorSingle,
|
||||
'error' => $errorInfo,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
// 查询数据
|
||||
$resultSponsor = (array)DB::table('sponsor')
|
||||
->where([['id', '=', $getData['id']]])
|
||||
->get()
|
||||
->toArray()[0];
|
||||
// 检查数据
|
||||
if ($resultSponsor['id'] !== null) {
|
||||
// 修改数据
|
||||
DB::table('sponsor')
|
||||
->where([['id', '=', $resultSponsor['id']]])
|
||||
->update([
|
||||
'name' => $request->name,
|
||||
'type' => $request->type,
|
||||
'money' => $request->money,
|
||||
'url' => $request->url,
|
||||
'time' => date('Y-m-d H:i:s', strtotime($request->date)),
|
||||
]);
|
||||
$returnData = [
|
||||
'output' => 'Success',
|
||||
'code' => 200,
|
||||
'data' => [
|
||||
'message' => '操作成功',
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'NoData',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '数据不存在',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'NoPermission',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '没有权限',
|
||||
],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'PleaseLogin',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '请登录',
|
||||
],
|
||||
];
|
||||
}
|
||||
return Response::json($returnData, $returnData['code']);
|
||||
}
|
||||
|
||||
public function apiDelete($sponsorId): JsonResponse
|
||||
{
|
||||
$arrayData['sponsorId'] = $sponsorId;
|
||||
if (Auth::check()) {
|
||||
if (Auth::user()->admin) {
|
||||
$checkData = Validator::make($arrayData, [
|
||||
'sponsorId' => 'required|int'
|
||||
]);// 检查是否符合规则
|
||||
if ($checkData->fails()) {
|
||||
$errorType = array_keys($checkData->failed());
|
||||
$i = 0;
|
||||
foreach ($checkData->failed() as $valueData) {
|
||||
$errorInfo[$errorType[$i]] = array_keys($valueData);
|
||||
if ($i == 0) {
|
||||
$errorSingle = [
|
||||
'info' => $errorType[$i],
|
||||
'need' => $errorInfo[$errorType[$i]],
|
||||
];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$returnData = [
|
||||
'output' => 'DataFormatError',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '输入内容有错误',
|
||||
'errorSingle' => $errorSingle,
|
||||
'error' => $errorInfo,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
// 查询数据
|
||||
$resultSponsor = (array)DB::table('sponsor')
|
||||
->where([['id', '=', $sponsorId]])
|
||||
->get()
|
||||
->toArray()[0];
|
||||
// 检查数据
|
||||
if ($resultSponsor['id'] !== null) {
|
||||
// 修改数据
|
||||
DB::table('sponsor')
|
||||
->where([['id', '=', $resultSponsor['id']]])
|
||||
->delete();
|
||||
$returnData = [
|
||||
'output' => 'Success',
|
||||
'code' => 200,
|
||||
'data' => [
|
||||
'message' => '删除成功',
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'NoData',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '数据不存在',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'NoPermission',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '没有权限',
|
||||
],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'PleaseLogin',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '请登录',
|
||||
],
|
||||
];
|
||||
}
|
||||
return Response::json($returnData, $returnData['code']);
|
||||
}
|
||||
|
||||
public function apiAdd(Request $request): JsonResponse
|
||||
{
|
||||
if (Auth::check()) {
|
||||
if (Auth::user()->admin) {
|
||||
// 处理数据
|
||||
$dataCheck = Validator::make($request->all(), [
|
||||
'name' => 'required|string',
|
||||
'type' => 'required|int',
|
||||
'money' => 'required|numeric',
|
||||
'date' => 'required|string',
|
||||
'url' => 'regex:#[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?#',
|
||||
]);
|
||||
if ($dataCheck->fails()) {
|
||||
$errorType = array_keys($dataCheck->failed());
|
||||
$i = 0;
|
||||
foreach ($dataCheck->failed() as $valueData) {
|
||||
$errorInfo[$errorType[$i]] = array_keys($valueData);
|
||||
if ($i == 0) {
|
||||
$errorSingle = [
|
||||
'info' => $errorType[$i],
|
||||
'need' => $errorInfo[$errorType[$i]],
|
||||
];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$returnData = [
|
||||
'output' => 'DataFormatError',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '输入内容有错误',
|
||||
'errorSingle' => $errorSingle,
|
||||
'error' => $errorInfo,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
if (empty($request->url)) $request->url = null;
|
||||
// 操作数据库
|
||||
DB::table('sponsor')
|
||||
->insert([
|
||||
'name' => $request->name,
|
||||
'url' => $request->url,
|
||||
'type' => $request->type,
|
||||
'money' => $request->money,
|
||||
'time' => date('Y-m-d H:i:s', strtotime($request->date)),
|
||||
]);
|
||||
$returnData = [
|
||||
'output' => 'Success',
|
||||
'code' => 200,
|
||||
'data' => [
|
||||
'message' => '操作成功',
|
||||
],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'NoPermission',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '没有权限',
|
||||
],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'PleaseLogin',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '请登录',
|
||||
],
|
||||
];
|
||||
}
|
||||
return Response::json($returnData, $returnData['code']);
|
||||
}
|
||||
|
||||
public function apiTypeAdd(Request $request): JsonResponse
|
||||
{
|
||||
if (Auth::check()) {
|
||||
if (Auth::user()->admin) {
|
||||
$dataCheck = Validator::make($request->all(), [
|
||||
'name' => 'required|string',
|
||||
'url' => 'required|regex:#[a-zA-z]+://[^\s]*#',
|
||||
'include' => 'int',
|
||||
'link' => 'int',
|
||||
]);
|
||||
if ($dataCheck->fails()) {
|
||||
$errorType = array_keys($dataCheck->failed());
|
||||
$i = 0;
|
||||
foreach ($dataCheck->failed() as $valueData) {
|
||||
$errorInfo[$errorType[$i]] = array_keys($valueData);
|
||||
if ($i == 0) {
|
||||
$errorSingle = [
|
||||
'info' => $errorType[$i],
|
||||
'need' => $errorInfo[$errorType[$i]],
|
||||
];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$returnData = [
|
||||
'output' => 'DataFormatError',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '输入内容有错误',
|
||||
'errorSingle' => $errorSingle,
|
||||
'error' => $errorInfo,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
// 处理数据
|
||||
if (empty($request->include)) $request->include = 0;
|
||||
if (empty($request->link)) $request->link = 0;
|
||||
DB::table('sponsor_type')
|
||||
->insert([
|
||||
'name' => $request->name,
|
||||
'url' => $request->url,
|
||||
'include' => $request->include,
|
||||
'link' => $request->link,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
$returnData = [
|
||||
'output' => 'Success',
|
||||
'code' => 200,
|
||||
'data' => [
|
||||
'message' => '创建成功',
|
||||
],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'NoPermission',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '没有权限',
|
||||
],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'PleaseLogin',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '请登录',
|
||||
],
|
||||
];
|
||||
}
|
||||
return Response::json($returnData, $returnData['code']);
|
||||
}
|
||||
|
||||
public function apiTypeEdit(Request $request, $typeId = null): JsonResponse
|
||||
{
|
||||
|
||||
if ((empty($typeId) && !empty($request->edit_id)) || (!empty($typeId) && empty($request->edit_id))) {
|
||||
$getData = $request->all();
|
||||
if (!empty($typeId) && empty($request->edit_id)) $getData['edit_id'] = $typeId;
|
||||
if (Auth::check()) {
|
||||
if (Auth::user()->admin) {
|
||||
// 检查数据
|
||||
$dataCheck = Validator::make($getData, [
|
||||
'edit_id' => 'required|int',
|
||||
'edit_name' => 'required|string',
|
||||
'edit_url' => 'required|regex:#[a-zA-z]+://[^\s]*#',
|
||||
'edit_include' => 'int',
|
||||
'edit_link' => 'int',
|
||||
]);
|
||||
if ($dataCheck->fails()) {
|
||||
$errorType = array_keys($dataCheck->failed());
|
||||
$i = 0;
|
||||
foreach ($dataCheck->failed() as $valueData) {
|
||||
$errorInfo[$errorType[$i]] = array_keys($valueData);
|
||||
if ($i == 0) {
|
||||
$errorSingle = [
|
||||
'info' => $errorType[$i],
|
||||
'need' => $errorInfo[$errorType[$i]],
|
||||
];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$returnData = [
|
||||
'output' => 'DataFormatError',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '输入内容有错误',
|
||||
'errorSingle' => $errorSingle,
|
||||
'error' => $errorInfo,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
// 操作数据库
|
||||
$resultSponsorType = (array)DB::table('sponsor_type')
|
||||
->where([['id', '=', $getData['edit_id']]])
|
||||
->get()
|
||||
->toArray()[0];
|
||||
if (!empty($resultSponsorType['id'])) {
|
||||
if (empty($getData['edit_include'])) $getData['edit_include'] = 0;
|
||||
if (empty($getData['edit_link'])) $getData['edit_link'] = 0;
|
||||
// 操作数据库
|
||||
DB::table('sponsor_type')
|
||||
->where([['id', '=', $resultSponsorType['id']]])
|
||||
->update([
|
||||
'name' => $getData['edit_name'],
|
||||
'url' => $getData['edit_url'],
|
||||
'include' => $getData['edit_include'],
|
||||
'link' => $getData['edit_link'],
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
$returnData = [
|
||||
'output' => 'Success',
|
||||
'code' => 200,
|
||||
'data' => [
|
||||
'message' => '修改成功',
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'NoData',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '不存在数据',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'NoPermission',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '没有权限',
|
||||
],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'PleaseLogin',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '请登录',
|
||||
],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'InputError',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '不允许Url参数与表单参数同时输入',
|
||||
],
|
||||
];
|
||||
}
|
||||
return Response::json($returnData, $returnData['code']);
|
||||
}
|
||||
|
||||
public function apiTypeDelete($typeId): JsonResponse
|
||||
{
|
||||
if (Auth::check()) {
|
||||
if (Auth::user()->admin) {
|
||||
// 检查ID
|
||||
$arrayData['typeId'] = $typeId;
|
||||
$dataCheck = Validator::make($arrayData, [
|
||||
'typeId' => 'required|int',
|
||||
]);
|
||||
if ($dataCheck->fails()) {
|
||||
$errorType = array_keys($dataCheck->failed());
|
||||
$i = 0;
|
||||
foreach ($dataCheck->failed() as $valueData) {
|
||||
$errorInfo[$errorType[$i]] = array_keys($valueData);
|
||||
if ($i == 0) {
|
||||
$errorSingle = [
|
||||
'info' => $errorType[$i],
|
||||
'need' => $errorInfo[$errorType[$i]],
|
||||
];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$returnData = [
|
||||
'output' => 'DataFormatError',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '输入内容有错误',
|
||||
'errorSingle' => $errorSingle,
|
||||
'error' => $errorInfo,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
// 操作数据库
|
||||
$resultSponsorType = (array)DB::table('sponsor_type')
|
||||
->where([['id', '=', $typeId]])
|
||||
->get()
|
||||
->toArray()[0];
|
||||
if (!empty($resultSponsorType['id'])) {
|
||||
// 删除数据
|
||||
DB::table('sponsor_type')
|
||||
->where([['id', '=', $resultSponsorType['id']]])
|
||||
->delete();
|
||||
$returnData = [
|
||||
'output' => 'Success',
|
||||
'code' => 200,
|
||||
'data' => [
|
||||
'message' => '操作成功',
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'NoData',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '不存在数据',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'NoPermission',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '没有权限',
|
||||
],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'PleaseLogin',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '请登录',
|
||||
],
|
||||
];
|
||||
}
|
||||
return Response::json($returnData, $returnData['code']);
|
||||
}
|
||||
|
||||
public function apiTypeSelect($typeId): JsonResponse
|
||||
{
|
||||
if (Auth::check()) {
|
||||
if (Auth::user()->admin) {
|
||||
// 检查ID
|
||||
$arrayData['typeId'] = $typeId;
|
||||
$dataCheck = Validator::make($arrayData, [
|
||||
'typeId' => 'required|int',
|
||||
]);
|
||||
if ($dataCheck->fails()) {
|
||||
$errorType = array_keys($dataCheck->failed());
|
||||
$i = 0;
|
||||
foreach ($dataCheck->failed() as $valueData) {
|
||||
$errorInfo[$errorType[$i]] = array_keys($valueData);
|
||||
if ($i == 0) {
|
||||
$errorSingle = [
|
||||
'info' => $errorType[$i],
|
||||
'need' => $errorInfo[$errorType[$i]],
|
||||
];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$returnData = [
|
||||
'output' => 'DataFormatError',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '输入内容有错误',
|
||||
'errorSingle' => $errorSingle,
|
||||
'error' => $errorInfo,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
// 获取数据
|
||||
$resultTypeSponsor = (array)DB::table('sponsor_type')
|
||||
->where([['id', '=', $typeId]])
|
||||
->get()
|
||||
->toArray()[0];
|
||||
if (!empty($resultTypeSponsor['id'])) {
|
||||
$returnData = [
|
||||
'output' => 'Success',
|
||||
'code' => 200,
|
||||
'data' => [
|
||||
'message' => '查询成功',
|
||||
'data' => $resultTypeSponsor,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'NoData',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '不存在数据',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'NoPermission',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '没有权限',
|
||||
],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$returnData = [
|
||||
'output' => 'PleaseLogin',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => '请登录',
|
||||
],
|
||||
];
|
||||
}
|
||||
return Response::json($returnData, $returnData['code']);
|
||||
}
|
||||
|
||||
protected function viewSponsorDashboard(): Factory|View|Application
|
||||
{
|
||||
$this->getAfadianData();
|
||||
// 获取模块
|
||||
$resultSponsorType = DB::table('sponsor_type')
|
||||
->get()
|
||||
->toArray();
|
||||
$this->data['sponsorCountYear'] = 0;
|
||||
$this->data['sponsorCount'] = 0;
|
||||
$this->data['sponsorCountNumber'] = count($this->data['sponsor']);
|
||||
foreach ($this->data['sponsor'] as $value) {
|
||||
$this->data['sponsorCount'] += $value['money'];
|
||||
if ($value['time'] >= date('Y') . '-01-01 00:00:00') {
|
||||
$this->data['sponsorCountYear'] += $value['money'];
|
||||
}
|
||||
}
|
||||
foreach ($resultSponsorType as $value) {
|
||||
$this->data['sponsorType'][$value->id] = [
|
||||
'id' => $value->id,
|
||||
'name' => $value->name,
|
||||
'url' => $value->url,
|
||||
'include' => $value->include,
|
||||
'link' => $value->link,
|
||||
];
|
||||
}
|
||||
return view('console.sponsor.dashboard', $this->data);
|
||||
}
|
||||
|
||||
private function getAfadianData(): void
|
||||
{
|
||||
$verify = ['verify' => true];
|
||||
if ($_SERVER['SERVER_PORT'] != 443) $verify = ['verify' => false];
|
||||
|
||||
// 从数据库获取数据
|
||||
$result = DB::table('info')
|
||||
->get()
|
||||
->toArray();
|
||||
$sponsor = DB::table('sponsor')
|
||||
->orderBy('time', 'desc')
|
||||
->limit(50)
|
||||
->get()
|
||||
->toArray();
|
||||
try {
|
||||
for ($i = 0; $sponsor[$i] != null; $i++) {
|
||||
$this->data['sponsor'][$i] = [
|
||||
'id' => $sponsor[$i]->id,
|
||||
'name' => $sponsor[$i]->name,
|
||||
'url' => $sponsor[$i]->url,
|
||||
'type' => $sponsor[$i]->type,
|
||||
'money' => $sponsor[$i]->money,
|
||||
'time' => date('Y-m-d', strtotime($sponsor[$i]->time)),
|
||||
];
|
||||
}
|
||||
} catch (ErrorException $e) {
|
||||
}
|
||||
$userID = $result[20]->data;
|
||||
$token = $result[21]->data;
|
||||
$time = time();
|
||||
$params = [
|
||||
'page' => 1,
|
||||
'per_page' => 100,
|
||||
];
|
||||
$sign = md5($token . 'params' . json_encode($params) . 'ts' . $time . 'user_id' . $userID);
|
||||
|
||||
$data = [
|
||||
'query' => [
|
||||
'user_id' => $userID,
|
||||
'params' => json_encode($params),
|
||||
'ts' => $time,
|
||||
'sign' => $sign,
|
||||
],
|
||||
];
|
||||
|
||||
$client = new Client($verify);
|
||||
try {
|
||||
$response = $client->get('https://afdian.net/api/open/query-sponsor', $data);
|
||||
$getData = json_decode($response->getBody()->getContents());
|
||||
} catch (GuzzleException $e) {
|
||||
return;
|
||||
}
|
||||
// 处理数据
|
||||
$j = 0;
|
||||
foreach ($getData->data->list as $value) {
|
||||
// 整合数据
|
||||
$data_elem[$j] = [
|
||||
'id' => $value->last_pay_time,
|
||||
'name' => $value->user->name,
|
||||
'url' => null,
|
||||
'type' => 5,
|
||||
'money' => (double)$value->all_sum_amount,
|
||||
'time' => date('Y-m-d', $value->last_pay_time),
|
||||
];
|
||||
$j++;
|
||||
}
|
||||
$this->data['sponsor'] = array_merge($this->data['sponsor'], $data_elem);
|
||||
usort($this->data['sponsor'], function ($a, $b) {
|
||||
return strtotime($b['time']) - strtotime($a['time']);
|
||||
});
|
||||
}
|
||||
|
||||
protected function viewEdit($sponsorId): Application|Factory|View|RedirectResponse
|
||||
{
|
||||
$getData['sponsorId'] = $sponsorId;
|
||||
$checkData = Validator::make($getData, [
|
||||
'sponsorId' => 'required|int'
|
||||
]);
|
||||
if ($checkData->fails()) {
|
||||
return Response::redirectTo(route('console.sponsor.dashboard'));
|
||||
} else {
|
||||
$resultSponsor = DB::table('sponsor')
|
||||
->where([['id', '=', $sponsorId]])
|
||||
->get()
|
||||
->toArray();
|
||||
$resultSponsor = (array)$resultSponsor[0];
|
||||
if (!empty($resultSponsor['id'])) {
|
||||
$this->data['sponsor'] = $resultSponsor;
|
||||
$this->data['sponsor']['time'] = date('m/d/Y', strtotime($resultSponsor['time']));
|
||||
$resultSponsorType = DB::table('sponsor_type')
|
||||
->get()
|
||||
->toArray();
|
||||
foreach ($resultSponsorType as $value) {
|
||||
$this->data['sponsorType'][$value->id] = [
|
||||
'id' => $value->id,
|
||||
'name' => $value->name,
|
||||
'url' => $value->url,
|
||||
'include' => $value->include,
|
||||
'link' => $value->link,
|
||||
];
|
||||
}
|
||||
return view('console.sponsor.edit', $this->data);
|
||||
} else {
|
||||
return Response::redirectTo(route('console.sponsor.dashboard'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function viewMode(): Factory|View|Application
|
||||
{
|
||||
$this->data['sponsorTypeCount'] = DB::table('sponsor_type')->count('id');
|
||||
$this->data['sponsorType'] = DB::table('sponsor_type')
|
||||
->get()
|
||||
->toArray();
|
||||
return view('console.sponsor.mode', $this->data);
|
||||
}
|
||||
}
|
|
@ -113,7 +113,7 @@ private function getAfadianData(): void
|
|||
'url' => $sponsor[$i]->url,
|
||||
'type' => $sponsor[$i]->type,
|
||||
'money' => $sponsor[$i]->money,
|
||||
'time' => $sponsor[$i]->time,
|
||||
'time' => date('Y-m-d', strtotime($sponsor[$i]->time)),
|
||||
];
|
||||
}
|
||||
} catch (ErrorException $e) {
|
||||
|
@ -153,7 +153,7 @@ private function getAfadianData(): void
|
|||
'url' => null,
|
||||
'type' => 5,
|
||||
'money' => (double)$value->all_sum_amount,
|
||||
'time' => date('Y-m-d H:i:s', $value->last_pay_time),
|
||||
'time' => date('Y-m-d', $value->last_pay_time),
|
||||
];
|
||||
$j++;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ class="flex items-center w-full p-2 text-gray-900 transition duration-75 rounded
|
|||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#"
|
||||
<a href="{{ route('console.sponsor.dashboard') }}"
|
||||
class="flex items-center p-2 text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700">
|
||||
<i class="bi bi-piggy-bank"></i>
|
||||
<span class="flex-1 ml-3 whitespace-nowrap">赞助管理</span>
|
||||
|
|
288
resources/views/console/sponsor/dashboard.blade.php
Normal file
288
resources/views/console/sponsor/dashboard.blade.php
Normal file
|
@ -0,0 +1,288 @@
|
|||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
|
||||
<link rel="stylesheet" href="{{ asset('css/flowbite.css') }}">
|
||||
@include('modules.head')
|
||||
{!! $webHeader !!}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<button data-drawer-target="sidebar-multi-level-sidebar" data-drawer-toggle="sidebar-multi-level-sidebar"
|
||||
aria-controls="sidebar-multi-level-sidebar" type="button"
|
||||
class="inline-flex items-center p-2 mt-2 ml-3 text-sm text-gray-500 rounded-lg sm:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600">
|
||||
<span class="sr-only">Open sidebar</span>
|
||||
<svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
||||
<path clip-rule="evenodd" fill-rule="evenodd"
|
||||
d="M2 4.75A.75.75 0 012.75 4h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 4.75zm0 10.5a.75.75 0 01.75-.75h7.5a.75.75 0 010 1.5h-7.5a.75.75 0 01-.75-.75zM2 10a.75.75 0 01.75-.75h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 10z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
@include('console.modules.aside')
|
||||
|
||||
<div class="p-4 sm:ml-64">
|
||||
<div class="p-4 border-gray-200 border-dashed rounded-lg dark:border-gray-700">
|
||||
@include('console.modules.personal')
|
||||
<div class="grid grid-cols-1 gap-4 mb-4">
|
||||
<div class="text-2xl text-gray-400 dark:text-gray-500"><i class="bi bi-piggy-bank"></i> 赞助管理</div>
|
||||
<div class="grid grid-cols-10 gap-4">
|
||||
<div class="col-span-10 lg:col-span-7 items-center justify-center rounded bg-white dark:bg-gray-800 shadow-lg">
|
||||
@if(!empty($sponsor[0]['id']))
|
||||
<ul class="w-full divide-y divide-gray-200 dark:divide-gray-700 px-5">
|
||||
@foreach($sponsor as $value)
|
||||
<li class="py-3 sm:py-4">
|
||||
<div class="flex items-center space-x-4">
|
||||
<div class="flex-1 min-w-0">
|
||||
<p class="text-sm font-bold text-gray-900 truncate dark:text-white">
|
||||
{{ $value['name'] }}
|
||||
</p>
|
||||
<p class="text-sm text-gray-500 truncate dark:text-gray-400 grid grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
<span class="font-bold">{{ $value['time'] }}</span>
|
||||
<span>{{ $sponsorType[$value['type']]['name'] }}</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="inline-flex">
|
||||
<div class="grid grid-cols-3 gap-4 items-center justify-center">
|
||||
<div class="text-end col-span-2 text-base font-semibold text-gray-900 dark:text-white">
|
||||
{{ $value['money'] }} CNY
|
||||
</div>
|
||||
<div class="text-end col-span-1 text-base font-semibold text-gray-900 dark:text-white">
|
||||
@if($value['type'] == 5)
|
||||
<button type="button" class="focus:outline-none text-white bg-red-800 hover:bg-red-800 focus:ring-4
|
||||
focus:ring-red-300 font-medium rounded-lg text-sm px-5 py-2.5 dark:bg-red-700
|
||||
dark:hover:bg-red-700 dark:focus:ring-red-900" disabled>无法操作
|
||||
</button>
|
||||
@else
|
||||
<a href="{{ route('console.sponsor.edit', $value['id']) }}" type="button" class="text-white bg-blue-700
|
||||
hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5
|
||||
dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800">点击编辑</a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-span-10 lg:col-span-3">
|
||||
<div class="items-center justify-center rounded bg-white dark:bg-gray-800 grid grid-cols-1 gap-4">
|
||||
<button data-modal-target="Modal" data-modal-toggle="Modal" type="submit" class="text-white bg-green-500 hover:bg-green-600 focus:ring-4
|
||||
focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-green-600
|
||||
dark:hover:bg-green-700 dark:focus:ring-blue-800 shadow-lg">
|
||||
<i class="bi bi-currency-yen"></i>
|
||||
<span class="ps-1">新增赞助</span>
|
||||
</button>
|
||||
<a href="{{ route('console.sponsor.mode') }}" class="text-white bg-blue-500 hover:bg-blue-600 focus:ring-4
|
||||
focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600
|
||||
dark:hover:bg-blue-700 dark:focus:ring-blue-800 shadow-lg">
|
||||
<i class="bi bi-currency-yen"></i>
|
||||
<span class="ps-1">赞助方式列表</span>
|
||||
</a>
|
||||
<div class="p-6 bg-white border border-gray-200 rounded-lg shadow-lg dark:bg-gray-800 dark:border-gray-700 grid grid-cols-1 gap-4">
|
||||
<div class="p-2 bg-green-50 rounded-lg shadow sm:p-4 dark:bg-gray-800 dark:border-gray-700 text-center">
|
||||
今年({{ date('Y') }})收款 <b>{{ $sponsorCountYear }}</b> 元
|
||||
</div>
|
||||
<div class="p-2 bg-pink-50 rounded-lg shadow sm:p-4 dark:bg-gray-800 dark:border-gray-700 text-center">
|
||||
总计金额 <b>{{ $sponsorCount }}</b> 元
|
||||
</div>
|
||||
<div class="p-2 bg-blue-50 rounded-lg shadow sm:p-4 dark:bg-gray-800 dark:border-gray-700 text-center">
|
||||
目前站长收到了 <b>{{ $sponsorCountNumber }}</b> 份赞助
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Toast -->
|
||||
<div id="toast"
|
||||
class="z-[9999] fixed top-5 left-5 hidden items-center w-full max-w-xs p-4 space-x-4 text-gray-500 bg-white divide-x divide-gray-200 rounded-lg shadow dark:text-gray-400 dark:divide-gray-700 space-x dark:bg-gray-800"
|
||||
role="alert">
|
||||
<div class="pl-4 text-sm font-normal">
|
||||
<span id="toast-icon" class="pe-1"><i class="bi bi-info-circle text-blue-500"></i></span>
|
||||
<span id="toast-info">Message sent successfully.</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<div id="Modal" tabindex="-1" aria-hidden="true" class="fixed top-0 left-0 right-0 z-50 hidden w-full p-4 overflow-x-hidden overflow-y-auto md:inset-0 h-[calc
|
||||
(100%-1rem)] max-h-full">
|
||||
<div class="relative w-full max-w-2xl max-h-full">
|
||||
<!-- Modal content -->
|
||||
<div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
|
||||
<!-- Modal header -->
|
||||
<div class="flex items-start justify-between p-4 border-b rounded-t dark:border-gray-600">
|
||||
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">
|
||||
新增赞助
|
||||
</h3>
|
||||
<button type="button" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ml-auto
|
||||
inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" data-modal-hide="Modal">
|
||||
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
|
||||
</svg>
|
||||
<span class="sr-only">Close modal</span>
|
||||
</button>
|
||||
</div>
|
||||
<!-- Modal body -->
|
||||
<div class="p-6 space-y-6">
|
||||
<form id="FormData" action="#" onsubmit="return false" method="POST">
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label for="name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">
|
||||
赞助者名字 <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3.5 pointer-events-none">
|
||||
<i class="bi bi-person"></i>
|
||||
</div>
|
||||
<input type="text" name="name" id="name" placeholder="筱锋" class="bg-gray-50 border border-gray-300 text-sm
|
||||
text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600
|
||||
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full pl-10">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="type" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">
|
||||
赞助方式 <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<select id="type" name="type" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500
|
||||
focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white
|
||||
dark:focus:ring-blue-500 dark:focus:border-blue-500">
|
||||
@if($sponsorType === null)
|
||||
<option>还未创建赞助方式</option>
|
||||
@else
|
||||
@foreach($sponsorType as $value)
|
||||
<option value="{{ $value['id'] }}"
|
||||
@if($value['id'] == 5) disabled @endif>
|
||||
{{ $value['name'] }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label for="money" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">
|
||||
赞助金额 <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3.5 pointer-events-none">
|
||||
<i class="bi bi-piggy-bank"></i>
|
||||
</div>
|
||||
<input type="number" name="money" id="money" placeholder="13.14" class="bg-gray-50 border border-gray-300
|
||||
text-sm text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600
|
||||
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full pl-10">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="date" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">
|
||||
赞助时间 <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<div class="relative max-w-sm">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3.5 pointer-events-none">
|
||||
<i class="bi bi-calendar-date"></i>
|
||||
</div>
|
||||
<input datepicker type="text" name="date" id="date" value="{{ date('m/d/Y') }}" class="bg-gray-50 border border-gray-300
|
||||
text-gray-900 text-sm p-2.5 rounded-lg focus:ring-blue-500 focus:border-blue-500 block dark:bg-gray-700 dark:border-gray-600
|
||||
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 w-full pl-10 dark:focus:border-blue-500">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-span-2">
|
||||
<label for="url" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">赞助者网站</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3.5 pointer-events-none">
|
||||
<i class="bi bi-link-45deg"></i>
|
||||
</div>
|
||||
<input type="text" name="url" id="url" placeholder="https://www.x-lf.com/" class="bg-gray-50 border border-gray-300 text-sm
|
||||
text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600
|
||||
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full pl-10">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!-- Modal footer -->
|
||||
<div class="flex items-center p-6 space-x-2 border-t border-gray-200 rounded-b dark:border-gray-600">
|
||||
<button type="button" id="SubmitSend" onclick="submit()" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none
|
||||
focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700
|
||||
dark:focus:ring-blue-800">
|
||||
<i class="bi bi-currency-yen"></i>
|
||||
<span class="ps-1">新增赞助</span>
|
||||
</button>
|
||||
<button data-modal-hide="Modal" type="button" onclick="location.reload()" class="text-gray-500 bg-white hover:bg-gray-100 focus:ring-4
|
||||
focus:outline-none focus:ring-blue-300 rounded-lg border border-gray-200 text-sm font-medium px-5 py-2.5 hover:text-gray-900 focus:z-10
|
||||
dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:text-white dark:hover:bg-gray-600 dark:focus:ring-gray-600">
|
||||
<i class="bi bi-x-circle"></i>
|
||||
<span class="ps-1">取消新增</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="{{ asset('js/app.js') }}"></script>
|
||||
<script src="{{ asset('js/jquery.js') }}"></script>
|
||||
<script src="{{ asset('js/datepicker.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
function submit() {
|
||||
$.ajax({
|
||||
async: true,
|
||||
method: "POST",
|
||||
data: $('#FormData').serialize(),
|
||||
url: '{{ route('api.sponsor.add') }}',
|
||||
dataType: "json",
|
||||
beforeSend: function () {
|
||||
$('#SubmitSend').prop('disabled', true).removeClass('bg-blue-500').addClass('bg-blue-600')
|
||||
.html('<svg aria-hidden="true" role="status" class="inline w-4 h-4 text-white animate-spin" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="#E5E7EB"/> <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentColor"/></svg>' +
|
||||
'<span class="ps-1">正在操作</span>');
|
||||
},
|
||||
success: function (returnData) {
|
||||
if (returnData.output === "Success") {
|
||||
$('#SubmitSend').html('<i class="bi bi-check2-circle"></i><span class="ps-1">操作成功</span>')
|
||||
|
||||
Toast.toggle('操作成功', '<i class="bi bi-check-circle text-green-500"></i>');
|
||||
setTimeout(function () {
|
||||
location.href = '{{ route('console.sponsor.dashboard') }}';
|
||||
}, 3000);
|
||||
} else {
|
||||
$('#SubmitSend').html('<i class="bi bi-currency-yen"></i><span class="ps-1">新增赞助</span>')
|
||||
.prop('disabled', false).removeClass('bg-blue-600').addClass('bg-blue-500');
|
||||
Toast('未知错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
},
|
||||
error: function (returnData) {
|
||||
Toast.set('其他错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
if (returnData.responseJSON.output === 'DataFormatError') {
|
||||
for (let key in Enum) {
|
||||
if (returnData.responseJSON.data.errorSingle.info === key) {
|
||||
Toast.toggle(Enum[key] + '错误,注意格式', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Toast.toggle('未知错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
$('#SubmitSend').html('<i class="bi bi-currency-yen"></i><span class="ps-1">新增赞助</span>')
|
||||
.prop('disabled', false).removeClass('bg-blue-600').addClass('bg-blue-500');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class Toast {
|
||||
static toggle(data, icon) {
|
||||
this.set(data, icon);
|
||||
$('#toast').fadeIn(300);
|
||||
setTimeout(function () {
|
||||
$('#toast').fadeOut(300);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
static set(data, icon) {
|
||||
$('#toast-icon').html(icon);
|
||||
$('#toast-info').text(data);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</html>
|
298
resources/views/console/sponsor/edit.blade.php
Normal file
298
resources/views/console/sponsor/edit.blade.php
Normal file
|
@ -0,0 +1,298 @@
|
|||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
|
||||
<link rel="stylesheet" href="{{ asset('css/flowbite.css') }}">
|
||||
@include('modules.head')
|
||||
{!! $webHeader !!}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<button data-drawer-target="sidebar-multi-level-sidebar" data-drawer-toggle="sidebar-multi-level-sidebar"
|
||||
aria-controls="sidebar-multi-level-sidebar" type="button"
|
||||
class="inline-flex items-center p-2 mt-2 ml-3 text-sm text-gray-500 rounded-lg sm:hidden hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600">
|
||||
<span class="sr-only">Open sidebar</span>
|
||||
<svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
||||
<path clip-rule="evenodd" fill-rule="evenodd"
|
||||
d="M2 4.75A.75.75 0 012.75 4h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 4.75zm0 10.5a.75.75 0 01.75-.75h7.5a.75.75 0 010 1.5h-7.5a.75.75 0 01-.75-.75zM2 10a.75.75 0 01.75-.75h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 10z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
@include('console.modules.aside')
|
||||
|
||||
<div class="p-4 sm:ml-64">
|
||||
<div class="p-4 border-gray-200 border-dashed rounded-lg dark:border-gray-700">
|
||||
@include('console.modules.personal')
|
||||
<div class="grid grid-cols-1 gap-4 mb-4">
|
||||
<div class="text-2xl text-gray-400 dark:text-gray-500"><i class="bi bi-link-45deg"></i> 修改赞助</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-10 gap-4 mb-4">
|
||||
<div class="col-span-10 lg:col-span-7 items-center justify-center rounded bg-white dark:bg-gray-800 shadow-lg">
|
||||
<div class="p-10">
|
||||
<form id="FormData" action="#" onsubmit="return false" method="POST">
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label for="id" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">序列号</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3.5 pointer-events-none">
|
||||
<i class="bi bi-app"></i>
|
||||
</div>
|
||||
<input type="number" name="id" id="id" value="{{ $sponsor['id'] }}" class="bg-gray-100 border border-gray-300 text-gray-900
|
||||
text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 dark:bg-gray-700 dark:border-gray-600
|
||||
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">赞助者名字</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3.5 pointer-events-none">
|
||||
<i class="bi bi-person"></i>
|
||||
</div>
|
||||
<input type="text" name="name" id="name" value="{{ $sponsor['name'] }}" class="bg-gray-50 border border-gray-300 text-sm
|
||||
text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600
|
||||
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full pl-10">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="type" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">赞助方式</label>
|
||||
<select id="type" name="type" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500
|
||||
focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white
|
||||
dark:focus:ring-blue-500 dark:focus:border-blue-500">
|
||||
@if($sponsorType === null)
|
||||
<option>还未创建赞助方式</option>
|
||||
@else
|
||||
@foreach($sponsorType as $value)
|
||||
<option value="{{ $value['id'] }}"
|
||||
@if($sponsor['type'] == $value['id']) selected @endif
|
||||
@if($value['id'] == 5) disabled @endif>
|
||||
{{ $value['name'] }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label for="name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">赞助金额</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3.5 pointer-events-none">
|
||||
<i class="bi bi-piggy-bank"></i>
|
||||
</div>
|
||||
<input type="number" name="money" id="money" value="{{ $sponsor['money'] }}" class="bg-gray-50 border border-gray-300
|
||||
text-sm text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600
|
||||
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full pl-10">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="url" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">赞助网站</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3.5 pointer-events-none">
|
||||
<i class="bi bi-link-45deg"></i>
|
||||
</div>
|
||||
<input type="text" name="url" id="url" value="{{ $sponsor['url'] }}" class="bg-gray-50 border border-gray-300 text-sm
|
||||
text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600
|
||||
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full pl-10">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="date" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">赞助时间</label>
|
||||
<div class="relative max-w-sm">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3.5 pointer-events-none">
|
||||
<i class="bi bi-calendar-date"></i>
|
||||
</div>
|
||||
<input datepicker type="text" name="date" id="date" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm p-2.5
|
||||
rounded-lg focus:ring-blue-500 focus:border-blue-500 block dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400
|
||||
dark:text-white dark:focus:ring-blue-500 w-full pl-10 dark:focus:border-blue-500" value="{{ $sponsor['time'] }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-span-10 lg:col-span-3">
|
||||
<div class="items-center justify-center rounded bg-white dark:bg-gray-800 shadow-lg grid grid-cols-1 mb-4">
|
||||
<div class="p-2 xl:p-8 grid grid-cols-2">
|
||||
<button onclick="ajax()" id="SubmitSend" type="submit" class="m-2 text-white bg-green-500 hover:bg-green-600 focus:ring-4
|
||||
focus:outline-none
|
||||
focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-green-600 dark:hover:bg-green-700
|
||||
dark:focus:ring-blue-800">
|
||||
<i class="bi bi-send"></i>
|
||||
<span class="ps-1">提交修改</span>
|
||||
</button>
|
||||
<button data-modal-target="Modal" data-modal-toggle="Modal" id="SubmitRefuse" type="submit" class="m-2 text-white bg-red-500
|
||||
hover:bg-red-600
|
||||
focus:ring-4 focus:outline-none
|
||||
focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-red-600 dark:hover:bg-red-700
|
||||
dark:focus:ring-blue-800">
|
||||
<i class="bi bi-trash3"></i>
|
||||
<span class="ps-1">删除赞助</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Toast -->
|
||||
<div id="toast"
|
||||
class="z-[9999] fixed top-5 left-5 hidden items-center w-full max-w-xs p-4 space-x-4 text-gray-500 bg-white divide-x divide-gray-200 rounded-lg shadow dark:text-gray-400 dark:divide-gray-700 space-x dark:bg-gray-800"
|
||||
role="alert">
|
||||
<div class="pl-4 text-sm font-normal">
|
||||
<span id="toast-icon" class="pe-1"><i class="bi bi-info-circle text-blue-500"></i></span>
|
||||
<span id="toast-info">Message sent successfully.</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<div id="Modal" tabindex="-1" class="fixed top-0 left-0 right-0 z-50 hidden p-4 overflow-x-hidden overflow-y-auto md:inset-0 h-[calc(100%-1rem)] max-h-full">
|
||||
<div class="relative w-full max-w-md max-h-full">
|
||||
<div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
|
||||
<button type="button" class="absolute top-3 right-2.5 text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8
|
||||
h-8 ml-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" data-modal-hide="Modal">
|
||||
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
|
||||
</svg>
|
||||
<span class="sr-only">Close modal</span>
|
||||
</button>
|
||||
<div class="p-6 text-center">
|
||||
<svg class="mx-auto mb-4 text-gray-400 w-12 h-12 dark:text-gray-200" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
||||
viewBox="0 0 20 20">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M10 11V6m0 8h.01M19 10a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"/>
|
||||
</svg>
|
||||
<form id="FormDataCancel" action="#" onsubmit="return false" method="POST">
|
||||
<div class="mb-5 text-md font-normal text-gray-500 dark:text-gray-400">
|
||||
<div class="mb-3">您确认删除该赞助内容吗?</div>
|
||||
</div>
|
||||
</form>
|
||||
<button data-modal-hide="Modal" onclick="deleted()" type="button" class="text-white bg-red-600 hover:bg-red-800 focus:ring-4 focus:outline-none
|
||||
focus:ring-red-300 dark:focus:ring-red-800 font-medium rounded-lg text-sm inline-flex items-center px-5 py-2.5 text-center mr-2">
|
||||
确认删除
|
||||
</button>
|
||||
<button data-modal-hide="Modal" onclick="location.reload()" type="button" class="text-gray-500 bg-white hover:bg-gray-100 focus:ring-4
|
||||
focus:outline-none focus:ring-gray-200 rounded-lg border border-gray-200 text-sm font-medium px-5 py-2.5 hover:text-gray-900 focus:z-10
|
||||
dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:text-white dark:hover:bg-gray-600 dark:focus:ring-gray-600">
|
||||
取消操作
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="{{ asset('js/app.js') }}"></script>
|
||||
<script src="{{ asset('js/jquery.js') }}"></script>
|
||||
<script src="{{ asset('js/datepicker.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
function ajax() {
|
||||
$.ajax({
|
||||
async: true,
|
||||
method: "POST",
|
||||
data: $('#FormData').serialize(),
|
||||
url: '{{ route('api.sponsor.edit', $sponsor['id']) }}',
|
||||
dataType: "json",
|
||||
beforeSend: function () {
|
||||
$('#SubmitSend').prop('disabled', true).removeClass('bg-green-500').addClass('bg-green-600')
|
||||
.html('<svg aria-hidden="true" role="status" class="inline w-4 h-4 text-white animate-spin" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="#E5E7EB"/> <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentColor"/></svg>' +
|
||||
'<span class="ps-1">正在操作</span>');
|
||||
$('#SubmitRefuse').prop('disabled', true).removeClass('bg-red-500').addClass('bg-red-600');
|
||||
},
|
||||
success: function (returnData) {
|
||||
if (returnData.output === "Success") {
|
||||
$('#SubmitSend').html('<i class="bi bi-check2-circle"></i><span class="ps-1">操作成功</span>')
|
||||
|
||||
Toast.toggle('操作成功', '<i class="bi bi-check-circle text-green-500"></i>');
|
||||
setTimeout(function () {
|
||||
location.href = '{{ route('console.sponsor.dashboard') }}';
|
||||
}, 3000);
|
||||
} else {
|
||||
$('#SubmitSend').html('<i class="bi bi-send"></i><span class="ps-1">提交修改</span>')
|
||||
.prop('disabled', false).removeClass('bg-green-600').addClass('bg-green-500');
|
||||
$('#SubmitRefuse').html('<i class="bi bi-trash3"></i><span class="ps-1">提交修改</span>')
|
||||
.prop('disabled', false).removeClass('bg-red-600').addClass('bg-red-500');
|
||||
Toast('未知错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
},
|
||||
error: function (returnData) {
|
||||
Toast.set('其他错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
if (returnData.responseJSON.output === 'DataFormatError') {
|
||||
for (let key in Enum) {
|
||||
if (returnData.responseJSON.data.errorSingle.info === key) {
|
||||
Toast.toggle(Enum[key] + '错误,注意格式', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Toast.toggle('未知错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
$('#SubmitSend').html('<i class="bi bi-send"></i><span class="ps-1">提交修改</span>')
|
||||
.prop('disabled', false).removeClass('bg-green-600').addClass('bg-green-500');
|
||||
$('#SubmitRefuse').html('<i class="bi bi-trash3"></i><span class="ps-1">提交修改</span>')
|
||||
.prop('disabled', false).removeClass('bg-red-600').addClass('bg-red-500');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleted() {
|
||||
$.ajax({
|
||||
async: true,
|
||||
method: "POST",
|
||||
data: $('#FormDataCancel').serialize(),
|
||||
url: '{{ route('api.sponsor.delete', $sponsor['id']) }}',
|
||||
dataType: "json",
|
||||
beforeSend: function () {
|
||||
$('#SubmitSend').prop('disabled', true).removeClass('bg-green-500').addClass('bg-green-600');
|
||||
$('#SubmitRefuse').prop('disabled', true).removeClass('bg-red-500').addClass('bg-red-600')
|
||||
.html('<svg aria-hidden="true" role="status" class="inline w-4 h-4 text-white animate-spin" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="#E5E7EB"/> <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentColor"/></svg>' +
|
||||
'<span class="ps-1">正在操作</span>');
|
||||
},
|
||||
success: function (returnData) {
|
||||
$('#SubmitRefuse').html('<i class="bi bi-check2-circle"></i><span class="ps-1">操作成功</span>')
|
||||
|
||||
if (returnData.output === "Success") {
|
||||
Toast.toggle('操作成功', '<i class="bi bi-check-circle text-green-500"></i>');
|
||||
setTimeout(function () {
|
||||
location.href = '{{ route('console.sponsor.dashboard') }}';
|
||||
}, 3000);
|
||||
} else {
|
||||
Toast('未知错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
$('#SubmitSend').html('<i class="bi bi-send"></i><span class="ps-1">提交修改</span>')
|
||||
.prop('disabled', false).removeClass('bg-green-600').addClass('bg-green-500');
|
||||
$('#SubmitRefuse').html('<i class="bi bi-trash3"></i><span class="ps-1">提交修改</span>')
|
||||
.prop('disabled', false).removeClass('bg-red-600').addClass('bg-red-500');
|
||||
}
|
||||
},
|
||||
error: function (returnData) {
|
||||
Toast.set('其他错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
if (returnData.responseJSON.output === 'DataFormatError') {
|
||||
for (let key in Enum) {
|
||||
if (returnData.responseJSON.data.errorSingle.info === key) {
|
||||
Toast.toggle(Enum[key] + '错误,注意格式', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Toast.toggle('未知错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
$('#SubmitSend').html('<i class="bi bi-send"></i><span class="ps-1">提交修改</span>')
|
||||
.prop('disabled', false).removeClass('bg-green-600').addClass('bg-green-500');
|
||||
$('#SubmitRefuse').html('<i class="bi bi-trash3"></i><span class="ps-1">提交修改</span>')
|
||||
.prop('disabled', false).removeClass('bg-red-600').addClass('bg-red-500');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class Toast {
|
||||
static toggle(data, icon) {
|
||||
this.set(data, icon);
|
||||
$('#toast').fadeIn(300);
|
||||
setTimeout(function () {
|
||||
$('#toast').fadeOut(300);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
static set(data, icon) {
|
||||
$('#toast-icon').html(icon);
|
||||
$('#toast-info').text(data);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</html>
|
500
resources/views/console/sponsor/mode.blade.php
Normal file
500
resources/views/console/sponsor/mode.blade.php
Normal file
|
@ -0,0 +1,500 @@
|
|||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
|
||||
<link rel="stylesheet" href="{{ asset('css/flowbite.css') }}">
|
||||
@include('modules.head')
|
||||
{!! $webHeader !!}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<button data-drawer-target="sidebar-multi-level-sidebar" data-drawer-toggle="sidebar-multi-level-sidebar"
|
||||
aria-controls="sidebar-multi-level-sidebar" type="button"
|
||||
class="inline-flex items-center p-2 mt-2 ml-3 text-sm text-gray-500 rounded-lg sm:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600">
|
||||
<span class="sr-only">Open sidebar</span>
|
||||
<svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
||||
<path clip-rule="evenodd" fill-rule="evenodd"
|
||||
d="M2 4.75A.75.75 0 012.75 4h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 4.75zm0 10.5a.75.75 0 01.75-.75h7.5a.75.75 0 010 1.5h-7.5a.75.75 0 01-.75-.75zM2 10a.75.75 0 01.75-.75h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 10z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
@include('console.modules.aside')
|
||||
|
||||
<div class="p-4 sm:ml-64">
|
||||
<div class="p-4 border-gray-200 border-dashed rounded-lg dark:border-gray-700">
|
||||
@include('console.modules.personal')
|
||||
<div class="grid grid-cols-1 gap-4 mb-4">
|
||||
<div class="text-2xl text-gray-400 dark:text-gray-500"><i class="bi bi-piggy-bank"></i> 赞助方式管理</div>
|
||||
<div class="grid grid-cols-10 gap-4">
|
||||
<div class="col-span-10 lg:col-span-7">
|
||||
<div class="items-center justify-center rounded dark:bg-gray-800 shadow-lg">
|
||||
<div class="relative overflow-x-auto shadow-md sm:rounded-lg">
|
||||
<table class="w-full text-sm text-left text-gray-500 dark:text-gray-400">
|
||||
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3">别名</th>
|
||||
<th scope="col" class="px-6 py-3">计入收入</th>
|
||||
<th scope="col" class="px-6 py-3">跳转(链接)</th>
|
||||
<th scope="col" class="px-6 py-3">修改时间</th>
|
||||
<th scope="col" class="px-6 py-3 text-end">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php $i = 0; @endphp
|
||||
@foreach($sponsorType as $value)
|
||||
<tr class="@if($i%2 == 0)bg-white dark:bg-gray-900 @else bg-gray-50 dark:bg-gray-800 @endif border-b dark:border-gray-700">
|
||||
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
|
||||
{{ $value->name }}
|
||||
</th>
|
||||
<td class="px-6 py-4">
|
||||
@if($value->include)
|
||||
<span class="inline-flex items-center bg-green-100 text-green-800 text-xs font-medium mr-2 px-2.5 py-0.5
|
||||
rounded-full dark:bg-green-900 dark:text-green-300">
|
||||
<span class="w-2 h-2 mr-1 bg-green-500 rounded-full"></span>
|
||||
TRUE
|
||||
</span>
|
||||
@else
|
||||
<span class="inline-flex items-center bg-red-100 text-red-800 text-xs font-medium mr-2 px-2.5 py-0.5
|
||||
rounded-full dark:bg-red-900 dark:text-red-300">
|
||||
<span class="w-2 h-2 mr-1 bg-red-500 rounded-full"></span>
|
||||
FALSE
|
||||
</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
@if($value->link)
|
||||
<span class="inline-flex items-center bg-green-100 text-green-800 text-xs font-medium mr-2 px-2.5 py-0.5
|
||||
rounded-full dark:bg-green-900 dark:text-green-300">
|
||||
<span class="w-2 h-2 mr-1 bg-green-500 rounded-full"></span>
|
||||
TRUE
|
||||
</span>
|
||||
@else
|
||||
<span class="inline-flex items-center bg-red-100 text-red-800 text-xs font-medium mr-2 px-2.5 py-0.5
|
||||
rounded-full dark:bg-red-900 dark:text-red-300">
|
||||
<span class="w-2 h-2 mr-1 bg-red-500 rounded-full"></span>
|
||||
FALSE
|
||||
</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
@if($value->updated_at === null)
|
||||
暂无修改
|
||||
@else
|
||||
{{ $value->updated_at }}
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-6 py-4 text-end">
|
||||
<button data-modal-target="EditModal" data-modal-toggle="EditModal" id="editButton"
|
||||
onclick="select({{ $value->id }})" class="font-medium text-blue-600 dark:text-blue-500
|
||||
hover:underline">编辑
|
||||
</button>
|
||||
@if($value->id > 5)
|
||||
<button id="delButton" onclick="deleted({{ $value->id }})" class="font-medium text-red-600 dark:text-red-500
|
||||
hover:underline ps-1">删除
|
||||
</button>
|
||||
@else
|
||||
<button class="font-medium text-gray-600 dark:text-gray-500 ps-1" disabled>删除</button>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@php $i ++; @endphp
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-span-10 lg:col-span-3">
|
||||
<div class="items-center justify-center rounded bg-white dark:bg-gray-800 grid grid-cols-1 gap-4">
|
||||
<button data-modal-target="AddModal" data-modal-toggle="AddModal" class="text-white bg-green-500 hover:bg-green-600 focus:ring-4
|
||||
focus:outline-none focus:ring-green-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-green-600
|
||||
dark:hover:bg-green-700 dark:focus:ring-green-800 shadow-lg">
|
||||
<i class="bi bi-folder-plus"></i>
|
||||
<span class="ps-1">添加赞助方式</span>
|
||||
</button>
|
||||
<a href="{{ route('console.sponsor.dashboard') }}" class="text-white bg-blue-500 hover:bg-blue-600 focus:ring-4
|
||||
focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600
|
||||
dark:hover:bg-blue-700 dark:focus:ring-blue-800 shadow-lg">
|
||||
<i class="bi bi-currency-yen"></i>
|
||||
<span class="ps-1">返回赞助列表</span>
|
||||
</a>
|
||||
<div class="p-6 bg-white border border-gray-200 rounded-lg shadow-lg dark:bg-gray-800 dark:border-gray-700 grid grid-cols-1 gap-4">
|
||||
<div class="p-2 bg-green-50 rounded-lg shadow sm:p-4 dark:bg-gray-800 dark:border-gray-700 text-center">
|
||||
当前分类有 <b>{{ $sponsorTypeCount }}</b> 个
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Toast -->
|
||||
<div id="toast"
|
||||
class="z-[9999] fixed top-5 left-5 hidden items-center w-full max-w-xs p-4 space-x-4 text-gray-500 bg-white divide-x divide-gray-200 rounded-lg shadow dark:text-gray-400 dark:divide-gray-700 space-x dark:bg-gray-800"
|
||||
role="alert">
|
||||
<div class="pl-4 text-sm font-normal">
|
||||
<span id="toast-icon" class="pe-1"><i class="bi bi-info-circle text-blue-500"></i></span>
|
||||
<span id="toast-info">Message sent successfully.</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<div id="AddModal" tabindex="-1" aria-hidden="true" class="fixed top-0 left-0 right-0 z-50 hidden w-full p-4 overflow-x-hidden overflow-y-auto md:inset-0
|
||||
h-[calc(100%-1rem)] max-h-full">
|
||||
<div class="relative w-full max-w-2xl max-h-full">
|
||||
<!-- Modal content -->
|
||||
<div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
|
||||
<!-- Modal header -->
|
||||
<div class="flex items-start justify-between p-4 border-b rounded-t dark:border-gray-600">
|
||||
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">
|
||||
新增赞助方式
|
||||
</h3>
|
||||
<button type="button" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ml-auto
|
||||
inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" data-modal-hide="AddModal">
|
||||
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
|
||||
</svg>
|
||||
<span class="sr-only">Close modal</span>
|
||||
</button>
|
||||
</div>
|
||||
<!-- Modal body -->
|
||||
<div class="p-6 space-y-6">
|
||||
<form id="FormData" action="#" onsubmit="return false" method="POST">
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label for="name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">
|
||||
别名 <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3.5 pointer-events-none">
|
||||
<i class="bi bi-type"></i>
|
||||
</div>
|
||||
<input type="text" name="name" id="name" class="bg-gray-50 border border-gray-300 text-sm
|
||||
text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600
|
||||
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full pl-10">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="url" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">
|
||||
链接地址 <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3.5 pointer-events-none">
|
||||
<i class="bi bi-link-45deg"></i>
|
||||
</div>
|
||||
<input type="text" name="url" id="url" class="bg-gray-50 border border-gray-300 text-sm
|
||||
text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600
|
||||
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full pl-10">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-span-2">
|
||||
<label class="relative inline-flex items-center cursor-pointer">
|
||||
<input type="checkbox" value="1" id="include" name="include" class="sr-only peer" checked>
|
||||
<div
|
||||
class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"></div>
|
||||
<span class="ml-3 text-sm font-medium text-gray-900 dark:text-gray-300">计入收入</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-span-2">
|
||||
<label class="relative inline-flex items-center cursor-pointer">
|
||||
<input type="checkbox" value="1" id="link" name="link" class="sr-only peer">
|
||||
<div
|
||||
class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"></div>
|
||||
<span class="ml-3 text-sm font-medium text-gray-900 dark:text-gray-300">跳转(连接)</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!-- Modal footer -->
|
||||
<div class="flex items-center p-6 space-x-2 border-t border-gray-200 rounded-b dark:border-gray-600">
|
||||
<button type="button" id="SubmitSend" onclick="submit()" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none
|
||||
focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700
|
||||
dark:focus:ring-blue-800">
|
||||
<i class="bi bi-folder-plus"></i>
|
||||
<span class="ps-1">新增方式</span>
|
||||
</button>
|
||||
<button data-modal-hide="AddModal" type="button" class="text-gray-500 bg-white hover:bg-gray-100 focus:ring-4
|
||||
focus:outline-none focus:ring-blue-300 rounded-lg border border-gray-200 text-sm font-medium px-5 py-2.5 hover:text-gray-900 focus:z-10
|
||||
dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:text-white dark:hover:bg-gray-600 dark:focus:ring-gray-600">
|
||||
<i class="bi bi-x-circle"></i>
|
||||
<span class="ps-1">取消新增</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<div id="EditModal" tabindex="-1" aria-hidden="true" class="fixed top-0 left-0 right-0 z-50 hidden w-full p-4 overflow-x-hidden overflow-y-auto md:inset-0
|
||||
h-[calc(100%-1rem)] max-h-full">
|
||||
<div class="relative w-full max-w-2xl max-h-full">
|
||||
<!-- Modal content -->
|
||||
<div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
|
||||
<!-- Modal header -->
|
||||
<div class="flex items-start justify-between p-4 border-b rounded-t dark:border-gray-600">
|
||||
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">
|
||||
赞助方式修改
|
||||
</h3>
|
||||
<button type="button" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ml-auto
|
||||
inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" data-modal-hide="EditModal">
|
||||
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
|
||||
</svg>
|
||||
<span class="sr-only">Close modal</span>
|
||||
</button>
|
||||
</div>
|
||||
<!-- Modal body -->
|
||||
<div class="p-6 space-y-6">
|
||||
<form id="FormDataEdit" action="#" onsubmit="return false" method="POST">
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label>
|
||||
<input type="number" name="edit_id" id="edit_id" hidden="hidden"/>
|
||||
</label>
|
||||
<label for="edit_name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">
|
||||
别名 <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3.5 pointer-events-none">
|
||||
<i class="bi bi-type"></i>
|
||||
</div>
|
||||
<input type="text" name="edit_name" id="edit_name" class="bg-gray-50 border border-gray-300 text-sm
|
||||
text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600
|
||||
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full pl-10">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="edit_url" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">
|
||||
链接地址 <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 flex items-center pl-3.5 pointer-events-none">
|
||||
<i class="bi bi-link-45deg"></i>
|
||||
</div>
|
||||
<input type="text" name="edit_url" id="edit_url" class="bg-gray-50 border border-gray-300 text-sm
|
||||
text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600
|
||||
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full pl-10">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-span-2">
|
||||
<label class="relative inline-flex items-center cursor-pointer">
|
||||
<input type="checkbox" value="1" id="edit_include" name="edit_include" class="sr-only peer">
|
||||
<div
|
||||
class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"></div>
|
||||
<span class="ml-3 text-sm font-medium text-gray-900 dark:text-gray-300">计入收入</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-span-2">
|
||||
<label class="relative inline-flex items-center cursor-pointer">
|
||||
<input type="checkbox" value="1" id="edit_link" name="edit_link" class="sr-only peer">
|
||||
<div
|
||||
class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"></div>
|
||||
<span class="ml-3 text-sm font-medium text-gray-900 dark:text-gray-300">跳转(连接)</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!-- Modal footer -->
|
||||
<div class="flex items-center p-6 space-x-2 border-t border-gray-200 rounded-b dark:border-gray-600">
|
||||
<button type="button" id="EditSubmitSend" onclick="edit()" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none
|
||||
focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700
|
||||
dark:focus:ring-blue-800">
|
||||
<i class="bi bi-folder-plus"></i>
|
||||
<span class="ps-1">修改内容</span>
|
||||
</button>
|
||||
<button data-modal-hide="EditModal" type="button" class="text-gray-500 bg-white hover:bg-gray-100 focus:ring-4
|
||||
focus:outline-none focus:ring-blue-300 rounded-lg border border-gray-200 text-sm font-medium px-5 py-2.5 hover:text-gray-900 focus:z-10
|
||||
dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:text-white dark:hover:bg-gray-600 dark:focus:ring-gray-600">
|
||||
<i class="bi bi-x-circle"></i>
|
||||
<span class="ps-1">取消新增</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="{{ asset('js/app.js') }}"></script>
|
||||
<script src="{{ asset('js/jquery.js') }}"></script>
|
||||
<script src="{{ asset('js/datepicker.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
function submit() {
|
||||
$.ajax({
|
||||
async: true,
|
||||
method: "POST",
|
||||
data: $('#FormData').serialize(),
|
||||
url: '{{ route('api.sponsor.type.add') }}',
|
||||
dataType: "json",
|
||||
beforeSend: function () {
|
||||
$('#SubmitSend').prop('disabled', true).removeClass('bg-blue-500').addClass('bg-blue-600')
|
||||
.html('<svg aria-hidden="true" role="status" class="inline w-4 h-4 text-white animate-spin" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="#E5E7EB"/> <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentColor"/></svg>' +
|
||||
'<span class="ps-1">正在操作</span>');
|
||||
},
|
||||
success: function (returnData) {
|
||||
if (returnData.output === "Success") {
|
||||
$('#SubmitSend').html('<i class="bi bi-check2-circle"></i><span class="ps-1">操作成功</span>')
|
||||
|
||||
Toast.toggle('操作成功', '<i class="bi bi-check-circle text-green-500"></i>');
|
||||
setTimeout(function () {
|
||||
location.href = '{{ route('console.sponsor.mode') }}';
|
||||
}, 3000);
|
||||
} else {
|
||||
$('#SubmitSend').html('<i class="bi bi-folder-plus"></i><span class="ps-1">新增方式</span>')
|
||||
.prop('disabled', false).removeClass('bg-blue-600').addClass('bg-blue-500');
|
||||
Toast('未知错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
},
|
||||
error: function (returnData) {
|
||||
Toast.set('其他错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
if (returnData.responseJSON.output === 'DataFormatError') {
|
||||
for (let key in Enum) {
|
||||
if (returnData.responseJSON.data.errorSingle.info === key) {
|
||||
Toast.toggle(Enum[key] + '错误,注意格式', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Toast.toggle('未知错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
$('#SubmitSend').html('<i class="bi bi-folder-plus"></i><span class="ps-1">新增方式</span>')
|
||||
.prop('disabled', false).removeClass('bg-blue-600').addClass('bg-blue-500');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function select(ElemData) {
|
||||
$.ajax({
|
||||
async: true,
|
||||
method: "GET",
|
||||
url: '{{ route('api.sponsor.type.select','') }}/' + ElemData,
|
||||
dataType: "json",
|
||||
success: function (returnData) {
|
||||
if (returnData.output === "Success") {
|
||||
$('#edit_id').val(returnData.data.data.id);
|
||||
$('#edit_name').val(returnData.data.data.name);
|
||||
$('#edit_url').val(returnData.data.data.url);
|
||||
if (returnData.data.data.include) {
|
||||
$('#edit_include').prop('checked', true);
|
||||
} else {
|
||||
$('#edit_include').prop('checked', false);
|
||||
}
|
||||
if (returnData.data.data.link) {
|
||||
$('#edit_link').prop('checked', true);
|
||||
} else {
|
||||
$('#edit_link').prop('checked', false);
|
||||
}
|
||||
} else {
|
||||
Toast.toggle('获取失败', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
Toast.toggle('获取失败', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function edit() {
|
||||
$.ajax({
|
||||
async: true,
|
||||
method: "POST",
|
||||
data: $('#FormDataEdit').serialize(),
|
||||
url: '{{ route('api.sponsor.type.edit') }}',
|
||||
dataType: "json",
|
||||
beforeSend: function () {
|
||||
$('#EditSubmitSend').prop('disabled', true).removeClass('bg-blue-500').addClass('bg-blue-600')
|
||||
.html('<svg aria-hidden="true" role="status" class="inline w-4 h-4 text-white animate-spin" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="#E5E7EB"/> <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentColor"/></svg>' +
|
||||
'<span class="ps-1">正在操作</span>');
|
||||
},
|
||||
success: function (returnData) {
|
||||
if (returnData.output === "Success") {
|
||||
$('#EditSubmitSend').html('<i class="bi bi-check2-circle"></i><span class="ps-1">修改内容</span>')
|
||||
|
||||
Toast.toggle('操作成功', '<i class="bi bi-check-circle text-green-500"></i>');
|
||||
setTimeout(function () {
|
||||
location.href = '{{ route('console.sponsor.mode') }}';
|
||||
}, 3000);
|
||||
} else {
|
||||
$('#EditSubmitSend').html('<i class="bi bi-folder-plus"></i><span class="ps-1">修改内容</span>')
|
||||
.prop('disabled', false).removeClass('bg-blue-600').addClass('bg-blue-500');
|
||||
Toast('未知错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
},
|
||||
error: function (returnData) {
|
||||
Toast.set('其他错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
if (returnData.responseJSON.output === 'DataFormatError') {
|
||||
for (let key in Enum) {
|
||||
if (returnData.responseJSON.data.errorSingle.info === key) {
|
||||
Toast.toggle(Enum[key] + '错误,注意格式', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Toast.toggle('未知错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
$('#EditSubmitSend').html('<i class="bi bi-folder-plus"></i><span class="ps-1">修改内容</span>')
|
||||
.prop('disabled', false).removeClass('bg-blue-600').addClass('bg-blue-500');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleted(ElemData) {
|
||||
$.ajax({
|
||||
async: true,
|
||||
method: "POST",
|
||||
url: '{{ route('api.sponsor.type.delete','') }}/' + ElemData,
|
||||
dataType: "json",
|
||||
success: function (returnData) {
|
||||
if (returnData.output === "Success") {
|
||||
$('#SubmitSend').html('<i class="bi bi-check2-circle"></i><span class="ps-1">操作成功</span>')
|
||||
|
||||
Toast.toggle('操作成功', '<i class="bi bi-check-circle text-green-500"></i>');
|
||||
setTimeout(function () {
|
||||
location.href = '{{ route('console.sponsor.mode') }}';
|
||||
}, 3000);
|
||||
} else {
|
||||
Toast('未知错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
},
|
||||
error: function (returnData) {
|
||||
Toast.set('其他错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
if (returnData.responseJSON.output === 'DataFormatError') {
|
||||
for (let key in Enum) {
|
||||
if (returnData.responseJSON.data.errorSingle.info === key) {
|
||||
Toast.toggle(Enum[key] + '错误,注意格式', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Toast.toggle('未知错误', '<i class="bi bi-x-circle text-red-500"></i>');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class Enum {
|
||||
static name = '别名';
|
||||
static url = '链接地址';
|
||||
}
|
||||
|
||||
class Toast {
|
||||
static toggle(data, icon) {
|
||||
this.set(data, icon);
|
||||
$('#toast').fadeIn(300);
|
||||
setTimeout(function () {
|
||||
$('#toast').fadeOut(300);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
static set(data, icon) {
|
||||
$('#toast-icon').html(icon);
|
||||
$('#toast-info').text(data);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</html>
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
use App\Http\Controllers\Authme;
|
||||
use App\Http\Controllers\Console\Link as ConsoleLink;
|
||||
use App\Http\Controllers\Console\Sponsor as ConsoleSponsor;
|
||||
use App\Http\Controllers\Function\Link;
|
||||
use App\Http\Controllers\Function\Sponsor;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
@ -54,4 +55,14 @@
|
|||
|
||||
Route::prefix('sponsor')->group(function () {
|
||||
Route::get('get-type', [Sponsor::class, 'apiSponsorType'])->name('api.sponsor.get-type');
|
||||
Route::post('add', [ConsoleSponsor::class, 'apiAdd'])->name('api.sponsor.add');
|
||||
Route::post('edit/{sponsorId}', [ConsoleSponsor::class, 'apiEdit'])->name('api.sponsor.edit');
|
||||
Route::post('delete/{sponsorId}', [ConsoleSponsor::class, 'apiDelete'])->name('api.sponsor.delete');
|
||||
Route::prefix('type')->group(function () {
|
||||
Route::post('add', [ConsoleSponsor::class, 'apiTypeAdd'])->name('api.sponsor.type.add');
|
||||
Route::post('edit/{typeId}', [ConsoleSponsor::class, 'apiTypeEdit'])->name('api.sponsor.type.edit-number');
|
||||
Route::post('edit', [ConsoleSponsor::class, 'apiTypeEdit'])->name('api.sponsor.type.edit');
|
||||
Route::post('delete/{typeId}', [ConsoleSponsor::class, 'apiTypeDelete'])->name('api.sponsor.type.delete');
|
||||
Route::get('select/{typeId}', [ConsoleSponsor::class, 'apiTypeSelect'])->name('api.sponsor.type.select');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
use App\Http\Controllers\Console\Dashboard;
|
||||
use App\Http\Controllers\Console\Link as ConsoleLink;
|
||||
use App\Http\Controllers\Console\Sponsor as ConsoleSponsor;
|
||||
use App\Http\Controllers\DataBase;
|
||||
use App\Http\Controllers\Function\Link as UserLink;
|
||||
use App\Http\Controllers\Function\Sponsor;
|
||||
|
@ -64,6 +65,11 @@
|
|||
Route::get('sort', [ConsoleLink::class, 'viewSort'])->name('console.friends-link.sort');
|
||||
Route::get('color', [ConsoleLink::class, 'viewColor'])->name('console.friends-link.color');
|
||||
});
|
||||
Route::prefix('sponsor')->group(function () {
|
||||
Route::get('dashboard', [ConsoleSponsor::class, 'viewSponsorDashboard'])->name('console.sponsor.dashboard');
|
||||
Route::get('edit/{sponsorId}', [ConsoleSponsor::class, 'viewEdit'])->name('console.sponsor.edit');
|
||||
Route::get('mode', [ConsoleSponsor::class, 'viewMode'])->name('console.sponsor.mode');
|
||||
});
|
||||
});
|
||||
|
||||
Route::prefix('auth')->group(function () {
|
||||
|
|
Loading…
Reference in New Issue
Block a user