45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller\user;
|
|
|
|
use app\api\controller\Controller;
|
|
use app\api\model\User as UserModel;
|
|
use app\api\model\Order as OrderModel;
|
|
use app\api\model\Setting as SettingModel;
|
|
|
|
/**
|
|
* 个人中心主页
|
|
* Class Index
|
|
* @package app\api\controller\user
|
|
*/
|
|
class Index extends Controller
|
|
{
|
|
/**
|
|
* 获取当前用户信息
|
|
* @return array
|
|
* @throws \app\common\exception\BaseException
|
|
* @throws \think\Exception
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public function detail()
|
|
{
|
|
// 当前用户信息
|
|
$user = $this->getUser(false);
|
|
// 订单总数
|
|
$model = new OrderModel;
|
|
return $this->renderSuccess([
|
|
'userInfo' => $user,
|
|
'orderCount' => [
|
|
'payment' => $model->getCount($user, 'payment'),
|
|
'received' => $model->getCount($user, 'received'),
|
|
'comment' => $model->getCount($user, 'comment'),
|
|
],
|
|
'setting' => [
|
|
'points_name' => SettingModel::getPointsName(),
|
|
],
|
|
'menus' => (new UserModel)->getMenus() // 个人中心菜单列表
|
|
]);
|
|
}
|
|
|
|
}
|