User.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\index\controller;
  3. use app\api\model\Article as ArticleModel;
  4. use app\api\model\Goods as GoodsModel;
  5. use think\facade\Session;
  6. use think\helper\Str;
  7. use think\response\Redirect;
  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('personal', ['goods' => []]);
  28. }
  29. /**
  30. * 分享商品
  31. * @return \think\response\Json
  32. */
  33. public function shareUser()
  34. {
  35. $userId = Session::get('user_id');
  36. if (empty($userId)) {
  37. return $this->renderJson(config('status.not_logged'), 'Log in please!');
  38. }
  39. $goodsId = $this->request->param('goodsId');
  40. if (empty($goodsId)){
  41. return $this->renderError('Invalid goods');
  42. }
  43. $encryptUserId = encrypt($userId);
  44. $url = url('/index/index/productDetail?goodsId=' . $goodsId . '&key=' . $encryptUserId);
  45. //todo 发邮件
  46. return $this->renderSuccess([]);
  47. }
  48. }