RoutineService.php 908 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\extra\service\wechat;
  3. use app\extra\basic\Service;
  4. use EasyWeChat\MiniApp\Application;
  5. class RoutineService extends Service
  6. {
  7. protected $request;
  8. protected $utils;
  9. /**
  10. * 设置模型
  11. * @return string
  12. */
  13. public function __construct()
  14. {
  15. $miniapp = new Application($this->options());
  16. $this->request = $miniapp->getClient();
  17. $this->utils = $miniapp->getUtils();
  18. }
  19. protected function options()
  20. {
  21. return ['app_id'=>sConf('wechat.mini_appid'),'secret'=>sConf('wechat.mini_secret'),'token'=>'','aes_key'=>''];
  22. }
  23. /**
  24. * 列表
  25. * @param array $param
  26. */
  27. public function getUserInfo(string $code)
  28. {
  29. try {
  30. return $this->utils->codeToSession($code);
  31. } catch (\Throwable $throwable) {
  32. return error($throwable->getMessage());
  33. }
  34. }
  35. }