User.php 3.3 KB

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