User.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Author: luzheng.liu
  4. * Time: 2020/12/5 17:15
  5. */
  6. namespace app\index\controller;
  7. use app\common\service\CommonService;
  8. use app\index\BaseController;
  9. use app\index\exception\ApiException;
  10. use app\index\model\UserModel;
  11. use app\index\model\VisitorModel;
  12. use think\facade\Cache;
  13. use think\facade\Session;
  14. class User extends BaseController {
  15. public function login() {
  16. $channelId = input('channelId');
  17. if (empty($channelId)){
  18. throw new ApiException('渠道id不为空');
  19. }
  20. var_dump(input());
  21. die();
  22. if (empty(input('unionid'))){
  23. throw new ApiException('unionid不为空');
  24. }
  25. $params = [
  26. 'id' => $channelId,
  27. 'userid' => input('unionid'),
  28. 'name' => input('nickName'),
  29. 'avatar' => input('avatar'),
  30. 'key' => md5(input('unionid').CommonService::getSetData($channelId)['channel_auth_code'])
  31. ];
  32. Session::set('wxId',input('unionid'));
  33. (new UserModel())->insertGetId([
  34. 'channel_id' => $channelId,
  35. 'unionid' => input('unionid'),
  36. 'name' => input('nickName'),
  37. 'avatar' => input('avatar'),
  38. 'key' => $params['key'],
  39. ]);
  40. header('Location:http://webcasting.bizconfstreaming.com/activity.php?a=userAssign&'.http_build_query($params));
  41. }
  42. public function clearSession() {
  43. // var_dump($_SERVER);
  44. Session::clear();
  45. // var_dump($_SERVER);
  46. }
  47. }