This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop/source/application/api/controller/user/Index.php
2020-04-25 22:20:29 +08:00

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() // 个人中心菜单列表
]);
}
}