ThirdWxController.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Http\Controllers\Api\V1;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request;
  5. use App\Facades\ThirdWxFacade;
  6. use App\Facades\UserFacade;
  7. use Illuminate\Support\Facades\Log;
  8. class ThirdWxController extends Controller
  9. {
  10. /**
  11. * 授权的url
  12. *
  13. * @return \Illuminate\Http\Response
  14. */
  15. public function auth(Request $request)
  16. {
  17. return ThirdWxFacade::authorization();
  18. }
  19. public function getUserInfo(Request $request)
  20. {
  21. if (empty($request->weichat_uid)) {
  22. return 0;
  23. }
  24. $userInfo = ThirdWxFacade::getUserInfo($request->weichat_uid);
  25. Log::info('getUserInfo', [$userInfo]);
  26. $wxUserInfo = $userInfo->getData()->data->datas;
  27. Log::info('wxUserInfo', [$wxUserInfo]);
  28. Log::info('IP', [$request->ip()]);
  29. if (isset($wxUserInfo->id)){
  30. return $login = UserFacade::wxWebLoginOrReg('', $request->ip(), $wxUserInfo, $request->weichat_uid);
  31. }
  32. // return $userInfo;
  33. }
  34. public function getJsSdk(Request $request){
  35. $url = $request->url;
  36. return ThirdWxFacade::getJsSdk(config('console.thirdWx.weid'), $url);
  37. }
  38. }