From d970fd827a1917e7150d29f955e0b813a2500111 Mon Sep 17 00:00:00 2001 From: Kaguya Date: Sat, 2 Dec 2017 00:36:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=AF=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E5=AE=9A=E5=88=B6=E5=AE=A2=E6=88=B7=E7=AB=AF=E7=9A=84?= =?UTF-8?q?API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Client/ClientApiController.php | 59 ++++ .../Client/ClientShopController.php | 52 ++++ config/routes.php | 8 + resources/views/material/client/code.tpl | 286 ++++++++++++++++++ resources/views/material/client/footer.tpl | 11 + resources/views/material/client/main.tpl | 195 ++++++++++++ resources/views/material/client/shop.tpl | 218 +++++++++++++ 7 files changed, 829 insertions(+) create mode 100644 app/Controllers/Client/ClientApiController.php create mode 100644 app/Controllers/Client/ClientShopController.php create mode 100644 resources/views/material/client/code.tpl create mode 100644 resources/views/material/client/footer.tpl create mode 100644 resources/views/material/client/main.tpl create mode 100644 resources/views/material/client/shop.tpl diff --git a/app/Controllers/Client/ClientApiController.php b/app/Controllers/Client/ClientApiController.php new file mode 100644 index 0000000..4b55fe1 --- /dev/null +++ b/app/Controllers/Client/ClientApiController.php @@ -0,0 +1,59 @@ +get($accessToken); + $user = User::find($token->userId); + $Anns = Ann::orderBy('date', 'desc')->first(); + $res['ret'] = 1; + $res['msg'] = "ok"; + $res['data'] = $Anns; + return $this->echoJson($response, $res); + + + //return $this->view()->assign("anns", $Anns)->display('user/announcement.tpl'); + } + + public function Redirect($request, $response, $args){ + $user = Auth::getUser(); + $url = $request->getQueryParams()["target"]; + if(!$user->isLogin){ + $accessToken = Helper::getTokenFromReq($request); + $storage = Factory::createTokenStorage(); + $token = $storage->get($accessToken); + if ($token==null) { + $res['ret'] = 0; + $res['msg'] = "token is null"; + return $this->echoJson($response, $res); + } + $user = User::find($token->userId); + $time = 3600*24; + Auth::login($user->id, $time); + } + return $response->withRedirect($url); + } + + + + +} \ No newline at end of file diff --git a/app/Controllers/Client/ClientShopController.php b/app/Controllers/Client/ClientShopController.php new file mode 100644 index 0000000..bec1130 --- /dev/null +++ b/app/Controllers/Client/ClientShopController.php @@ -0,0 +1,52 @@ +isLogin); + if(!$user->isLogin){ + return $response->withRedirect('/api/redirect?target=/client/shop'); + } + $pageNum = 1; + if (isset($request->getQueryParams()["page"])) { + $pageNum = $request->getQueryParams()["page"]; + } + $shops = Shop::where("status", 1)->paginate(15, ['*'], 'page', $pageNum); + $shops->setPath('/user/shop'); + + return $this->view()->assign('shops', $shops)->display('client/shop.tpl'); + } + + public function GetCode($request, $response, $args) + { + $user = Auth::getUser(); + //var_dump($user->isLogin); + if(!$user->isLogin){ + return $response->withRedirect('/api/redirect?target=/client/code'); + } + $pageNum = 1; + if (isset($request->getQueryParams()["page"])) { + $pageNum = $request->getQueryParams()["page"]; + } + $codes = Code::where('type', '<>', '-2')->where('userid', '=', $user->id)->orderBy('id', 'desc')->paginate(15, ['*'], 'page', $pageNum); + $codes->setPath('/user/code'); + return $this->view()->assign('codes', $codes)->assign('pmw', Pay::getHTML($user))->display('client/code.tpl'); + } + +} \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index 015edaf..48a2fda 100644 --- a/config/routes.php +++ b/config/routes.php @@ -296,6 +296,14 @@ $app->group('/api', function () { $this->post('/token', 'App\Controllers\ApiController:newToken'); $this->get('/node', 'App\Controllers\ApiController:node')->add(new Api()); $this->get('/user/{id}', 'App\Controllers\ApiController:userInfo')->add(new Api()); + $this->get('/announcement','App\Controllers\Client\ClientApiController:GetAnnouncement'); + $this->get('/redirect','App\Controllers\Client\ClientApiController:Redirect'); +}); + +//Client pages +$app->group('/client',function (){ + $this->get('/shop','App\Controllers\Client\ClientShopController:GetShop'); + $this->get('/code','App\Controllers\Client\ClientShopController:GetCode'); }); // mu diff --git a/resources/views/material/client/code.tpl b/resources/views/material/client/code.tpl new file mode 100644 index 0000000..d65ef99 --- /dev/null +++ b/resources/views/material/client/code.tpl @@ -0,0 +1,286 @@ + + + + + + + + + +{include file='client/main.tpl'} + + + + + + + +
+
+
+
+
+
+
+
+

充值码

+

当前余额:{$user->money} 元

+
+ + +
+
+
+
+ +
+
+
+
+
+
+ + {if $pmw!=''} +
+
+
+
+
+ {$pmw} +
+ +
+
+
+
+ {/if} + +
+
+
+
+
+
+
+ {$codes->render()} + + + + + + + + + + {foreach $codes as $code} + {if $code->type!=-2} + + + + {if $code->type==-1} + + {/if} + {if $code->type==10001} + + {/if} + {if $code->type==10002} + + {/if} + {if $code->type>=1&&$code->type<=10000} + + {/if} + {if $code->type==-1} + + {/if} + {if $code->type==10001} + + {/if} + {if $code->type==10002} + + {/if} + {if $code->type>=1&&$code->type<=10000} + + {/if} + + + {/if} + {/foreach} +
ID代码类型操作使用时间
#{$code->id}{$code->code}金额充值流量充值用户续期等级续期 - 等级{$code->type}充值 {$code->number} 元充值 {$code->number} GB 流量延长账户有效期 {$code->number} 天延长等级有效期 {$code->number} 天{$code->usedatetime}
+ {$codes->render()} +
+
+
+ +
+
+
+
+ + + + + + {include file='dialog.tpl'} +
+
+
+ + + + + + + +{include file='client/footer.tpl'} + + + + diff --git a/resources/views/material/client/footer.tpl b/resources/views/material/client/footer.tpl new file mode 100644 index 0000000..57afda5 --- /dev/null +++ b/resources/views/material/client/footer.tpl @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/resources/views/material/client/main.tpl b/resources/views/material/client/main.tpl new file mode 100644 index 0000000..23be7a1 --- /dev/null +++ b/resources/views/material/client/main.tpl @@ -0,0 +1,195 @@ + + + + + + + + {$config["appName"]} + + + + + + + + + + + + + + + + + + + diff --git a/resources/views/material/client/shop.tpl b/resources/views/material/client/shop.tpl new file mode 100644 index 0000000..376bd6a --- /dev/null +++ b/resources/views/material/client/shop.tpl @@ -0,0 +1,218 @@ + + + + + + +{include file='client/main.tpl'} + + + + + + + +
+
+
+ +
+
+
+

系统中所有商品的列表。您购买等级类的商品时有效期会从当前时间开始计算。

+

当前余额:{$user->money} 元

+
+
+
+ +
+ {$shops->render()} + + + + + + + + + + + + {foreach $shops as $shop} + + + + + + + {if $shop->auto_renew==0} + + {else} + + {/if} + + {if $shop->auto_reset_bandwidth==0} + + {else} + + {/if} + + + {/foreach} +
操作ID名称价格内容自动续费天数续费时重置流量
+ 购买 + #{$shop->id}{$shop->name}{$shop->price} 元{$shop->content()}不能自动续费可选 在 {$shop->auto_renew} 天后自动续费不自动重置自动重置
+ {$shops->render()} +
+ + + + + + + + {include file='dialog.tpl'} + +
+ + + +
+{include file='client/footer.tpl'} + + + \ No newline at end of file From 803f12422272dcfb21ee37f24cfc45112f1ad384 Mon Sep 17 00:00:00 2001 From: Kaguya Date: Sat, 2 Dec 2017 01:41:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=8E=9F=E6=9C=89API?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=B8=AA=E7=96=91=E4=BC=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controllers/ApiController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/ApiController.php b/app/Controllers/ApiController.php index 6b12499..1f4303a 100644 --- a/app/Controllers/ApiController.php +++ b/app/Controllers/ApiController.php @@ -80,7 +80,7 @@ class ApiController extends BaseController $storage = Factory::createTokenStorage(); $token = $storage->get($accessToken); $user = User::find($token->userId); - $nodes = Node::where('sort', 0)->where("type", "1")->where( + $nodes = Node::where('sort', 0)->where("type", "1")->where('node_class', '<=', $user->class)->where( function ($query) use ($user) { $query->where("node_group", "=", $user->node_group) ->orWhere("node_group", "=", 0);