User.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 think\facade\Cache;
  12. use think\facade\Session;
  13. class User extends BaseController {
  14. public function login() {
  15. $channelId = input('channelId');
  16. if (empty($channelId)){
  17. throw new ApiException('渠道id不为空');
  18. }
  19. $params = [
  20. 'id' => $channelId,
  21. 'userid' => input('unionid'),
  22. 'name' => input('nickName'),
  23. 'avatar' => input('avatar'),
  24. 'key' => md5(input('unionid').CommonService::getSetData($channelId)['channel_auth_code'])
  25. ];
  26. Session::set('wxId',input('unionid'));
  27. (new UserModel())->insertGetId([
  28. 'channel_id' => $channelId,
  29. 'unionid' => input('unionid'),
  30. 'name' => input('nickName'),
  31. 'avatar' => input('avatar'),
  32. 'key' => $params['key'],
  33. ]);
  34. header('Location:http://mudu.tv/activity.php?a=userAssign&'.http_build_query($params));
  35. }
  36. public function clearSession() {
  37. // var_dump($_SERVER);
  38. Session::clear();
  39. // var_dump($_SERVER);
  40. }
  41. }