User.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. $params = [
  21. 'id' => $channelId,
  22. 'userid' => input('unionid'),
  23. 'name' => input('nickName'),
  24. 'avatar' => input('avatar'),
  25. 'key' => md5(input('unionid').CommonService::getSetData($channelId)['channel_auth_code'])
  26. ];
  27. Session::set('wxId',input('unionid'));
  28. (new UserModel())->insertGetId([
  29. 'channel_id' => $channelId,
  30. 'unionid' => input('unionid'),
  31. 'name' => input('nickName'),
  32. 'avatar' => input('avatar'),
  33. 'key' => $params['key'],
  34. ]);
  35. header('Location:http://webcasting.bizconfstreaming.com/activity.php?a=userAssign&'.http_build_query($params));
  36. }
  37. public function clearSession() {
  38. // var_dump($_SERVER);
  39. Session::clear();
  40. // var_dump($_SERVER);
  41. }
  42. }