Index.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\api\controller\user;
  10. use app\api\controller\Controller;
  11. use app\api\model\User as UserModel;
  12. use app\api\model\Order as OrderModel;
  13. use app\api\model\Setting as SettingModel;
  14. /**
  15. * 个人中心主页
  16. * Class Index
  17. * @package app\api\controller\user
  18. */
  19. class Index extends Controller
  20. {
  21. /**
  22. * 获取当前用户信息
  23. * @return array
  24. * @throws \app\common\exception\BaseException
  25. * @throws \think\Exception
  26. * @throws \think\exception\DbException
  27. */
  28. public function detail()
  29. {
  30. // 当前用户信息
  31. $user = $this->getUser(false);
  32. // 订单总数
  33. $model = new OrderModel;
  34. return $this->renderSuccess([
  35. 'userInfo' => $user,
  36. 'orderCount' => [
  37. 'payment' => $model->getCount($user, 'payment'),
  38. 'received' => $model->getCount($user, 'received'),
  39. 'comment' => $model->getCount($user, 'comment'),
  40. ],
  41. 'setting' => [
  42. 'points_name' => SettingModel::getPointsName(),
  43. ],
  44. 'menus' => (new UserModel)->getMenus() // 个人中心菜单列表
  45. ]);
  46. }
  47. }