User.php 979 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: 中闽 < 1464674022@qq.com >
  5. * Date: 2019/12/5
  6. * Time: 17:44
  7. */
  8. namespace app\api\controller;
  9. use app\api\controller\base\Base;
  10. class User extends Base
  11. {
  12. protected $user;
  13. protected function _initialize()
  14. {
  15. $unionid = $this->request->param('unionid');
  16. if (!$unionid) {
  17. $openid = $this->request->param('openid');
  18. if (!$openid) {
  19. $this->json_error('请先登入');
  20. }
  21. $user = \app\common\model\User::get(['openid' => $openid]);
  22. if (!$user) {
  23. $this->json_error('账号不存在');
  24. }
  25. }
  26. $user = \app\common\model\User::get(['unionid' => $unionid]);
  27. if (!$user) {
  28. $this->json_error('账号不存在');
  29. }
  30. $this->user = $user;
  31. }
  32. //个人资料接口
  33. public function info()
  34. {
  35. $this->json_success('success', $this->user);
  36. }
  37. }