WechatLogic.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\api\logic;
  15. use app\common\logic\BaseLogic;
  16. use app\common\service\wechat\WeChatOaService;
  17. use EasyWeChat\Kernel\Exceptions\Exception;
  18. /**
  19. * 微信
  20. * Class WechatLogic
  21. * @package app\api\logic
  22. */
  23. class WechatLogic extends BaseLogic
  24. {
  25. /**
  26. * @notes 微信JSSDK授权接口
  27. * @param $params
  28. * @return false|mixed[]
  29. * @throws \Psr\SimpleCache\InvalidArgumentException
  30. * @throws \Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface
  31. * @throws \Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface
  32. * @throws \Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface
  33. * @throws \Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface
  34. * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
  35. * @author 段誉
  36. * @date 2023/3/1 11:49
  37. */
  38. public static function jsConfig($params)
  39. {
  40. try {
  41. $url = urldecode($params['url']);
  42. return (new WeChatOaService())->getJsConfig($url, [
  43. 'onMenuShareTimeline',
  44. 'onMenuShareAppMessage',
  45. 'onMenuShareQQ',
  46. 'onMenuShareWeibo',
  47. 'onMenuShareQZone',
  48. 'openLocation',
  49. 'getLocation',
  50. 'chooseWXPay',
  51. 'updateAppMessageShareData',
  52. 'updateTimelineShareData',
  53. 'openAddress',
  54. 'scanQRCode'
  55. ]);
  56. } catch (Exception $e) {
  57. self::setError('获取jssdk失败:' . $e->getMessage());
  58. return false;
  59. }
  60. }
  61. }