AuthController.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * 会员中心模块
  4. * @author wesmiler
  5. */
  6. namespace app\weixin\controller;
  7. use app\weixin\model\Member;
  8. use app\weixin\model\Wechat;
  9. use app\weixin\service\PRedis;
  10. use app\weixin\validate\MemberValidate;
  11. use think\Request;
  12. class AuthController extends BaseController
  13. {
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. $needRegProfile = session('needRegProfile');
  18. if($needRegProfile == true){
  19. Wechat::redirectUrl(url('/weixin/index/entry', '', '', true));
  20. exit;
  21. }
  22. }
  23. /**
  24. * 认证
  25. * @return mixed
  26. */
  27. public function index()
  28. {
  29. return $this->fetch();
  30. }
  31. /**
  32. * VIP认证
  33. * @return mixed
  34. */
  35. public function vip()
  36. {
  37. return $this->fetch();
  38. }
  39. /**
  40. * 人工牵线
  41. * @return mixed
  42. */
  43. public function hand()
  44. {
  45. return $this->fetch();
  46. }
  47. /**
  48. * 身份证认证
  49. * @return mixed
  50. */
  51. public function idcard()
  52. {
  53. return $this->fetch();
  54. }
  55. /**
  56. * 认证结果
  57. * @return mixed|string
  58. */
  59. public function authResult(){
  60. $params = input();
  61. $data = input('data',[]);
  62. $code = isset($data['code'])? $data['code'] : '';
  63. $idcard = isset($data['id'])? $data['id'] : '';
  64. $idcardName = isset($data['name'])? $data['name'] : '';
  65. $bizNo = isset($data['bizNo'])? $data['bizNo'] : '';
  66. var_dump($params);
  67. // 签名验证
  68. $userId = mb_substr($bizNo, 11, 0,'utf-8');
  69. if($idcard && $idcardName && $code == 'PASS' && $userId){
  70. $this->assign('bizNo',$bizNo);
  71. $this->assign('code','success');
  72. $this->assign('result','<em>身份验证成功</em>,请等待审核');
  73. }else{
  74. $this->assign('bizNo', '');
  75. $this->assign('code','error');
  76. $this->assign('result','<em>身份验证失败</em>,请返回重试');
  77. }
  78. $params['user_id'] = $userId;
  79. PRedis::set("caches:faceAuth:result:{$bizNo}", $params, 3600);
  80. return $this->fetch();
  81. }
  82. /**
  83. * 学历认证
  84. * @return mixed
  85. */
  86. public function education()
  87. {
  88. return $this->fetch();
  89. }
  90. /**
  91. * 职位认证
  92. * @return mixed
  93. */
  94. public function position()
  95. {
  96. return $this->fetch();
  97. }
  98. }