User.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. class User extends BaseController {
  10. public function login() {
  11. $params = [
  12. 'id' => CommonService::getSetData()['channel_id'],
  13. 'userid' => input('unionid'),
  14. 'name' => input('nickName'),
  15. 'avatar' => input('avatar'),
  16. 'key' => md5(input('userid').CommonService::getSetData()['channel_auth_code'])
  17. ];
  18. session('unionid', input('unionid'));
  19. if (session('unionid')){
  20. $visitorId = input('visitorId');
  21. $notifyUrl = input('notify_url');
  22. //增加客户自己的验证逻辑,例如登录,关注,付费,填手机号等
  23. $key = md5($visitorId.CommonService::getSetData()['channel_auth_code']);
  24. if(strpos($notifyUrl,'?') !== false){//url参数处理,将key加到url参数中
  25. $returnUrl = $notifyUrl."&key=".$key."&expire=3600";
  26. }else{
  27. $returnUrl = $notifyUrl."?key=".$key."&expire=3600";
  28. }
  29. header("Location:".$returnUrl);//跳转到直播观看页
  30. die();
  31. }
  32. header('Location:http://mudu.tv/activity.php?a=userAssign&'.http_build_query($params));
  33. }
  34. }