User.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. namespace app\index\controller;
  3. use app\index\model\user\PointsLog as PointsLogModel;
  4. use app\index\model\Goods as GoodsModel;
  5. use app\index\model\Order as OrderModel;
  6. use think\facade\Session;
  7. /**
  8. * 默认控制器
  9. * Class User
  10. * @package app\api\controller
  11. */
  12. class User extends Controller
  13. {
  14. /**
  15. * 个人中心
  16. * @return \think\response\View
  17. */
  18. public function personal()
  19. {
  20. $userId = Session::get('user_id');
  21. if (empty($userId)) {
  22. return view('passport/logIn');
  23. }
  24. $goodsModel = new GoodsModel();
  25. //$goods['content'] = html_entity_decode($goods['content']);
  26. return view('order', ['goods' => []]);
  27. }
  28. /**
  29. * 我的订单页面
  30. * @return \think\response\View
  31. */
  32. public function order(string $orderType = 'received')
  33. {
  34. $userId = Session::get('user_id');
  35. if (empty($userId)) {
  36. return view('passport/logIn');
  37. }
  38. return view('order');
  39. }
  40. /**
  41. * 订单详情
  42. * @param $orderId
  43. * @return \think\response\View
  44. * @throws \cores\exception\BaseException
  45. * @throws \think\db\exception\DataNotFoundException
  46. * @throws \think\db\exception\DbException
  47. * @throws \think\db\exception\ModelNotFoundException
  48. */
  49. public function orderDetails($orderId)
  50. {
  51. $userId = Session::get('user_id');
  52. if (empty($userId)) {
  53. return view('passport/logIn');
  54. }
  55. $model = OrderModel::getUserOrderDetail($orderId);
  56. return view('orderDetails', ['order' => $model]);
  57. }
  58. /**
  59. * 我的积分页面
  60. * @return \think\response\View
  61. */
  62. public function myScores()
  63. {
  64. $userId = Session::get('user_id');
  65. if (empty($userId)) {
  66. return view('passport/logIn');
  67. }
  68. $model = new PointsLogModel;
  69. $list = $model->getList();
  70. $user = \app\index\service\User::getCurrentLoginUser();
  71. return view('integral', ['user' => $user]);
  72. }
  73. /**
  74. * 我的积分列表
  75. * @return \think\response\Json
  76. * @throws \app\common\exception\BaseException
  77. * @throws \think\db\exception\DbException
  78. */
  79. public function pointsLogs()
  80. {
  81. $model = new PointsLogModel;
  82. $list = $model->getList();
  83. return $this->renderSuccess(compact('list'));
  84. }
  85. /**
  86. * 分享商品
  87. * @return \think\response\Json
  88. */
  89. public function shareUser()
  90. {
  91. $userId = Session::get('user_id');
  92. if (empty($userId)) {
  93. return $this->renderJson(config('status.not_logged'), 'Log in please!');
  94. }
  95. $goodsId = $this->request->param('goodsId');
  96. if (empty($goodsId)) {
  97. return $this->renderError('Invalid goods');
  98. }
  99. $encryptUserId = encrypt($userId);
  100. $url = url('/index/index/productDetail?goodsId=' . $goodsId . '&key=' . $encryptUserId);
  101. //todo 发邮件
  102. return $this->renderSuccess([]);
  103. }
  104. }