Index.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\api\controller;
  3. use app\admin\model\Company;
  4. use app\common\model\Ads;
  5. use app\common\model\Menu;
  6. use app\common\controller\Api;
  7. use app\common\model\User;
  8. use app\common\model\UserRelation;
  9. use liuniu\UtilService;
  10. use liuniu\WechatService;
  11. use think\Hook;
  12. use think\Request;
  13. /**
  14. * 首页接口
  15. */
  16. class Index extends Api
  17. {
  18. protected $noNeedLogin = ['*'];
  19. protected $noNeedRight = ['*'];
  20. /**
  21. * 首页
  22. *
  23. */
  24. public function index()
  25. {
  26. $banner = Ads::getbanner($this->cid);
  27. $bottom_menu = Menu::lst($this->cid,29);
  28. $menu = Menu::lst($this->cid,30);
  29. $this->success('获取成功',compact('banner','bottom_menu','menu'));
  30. }
  31. /**
  32. * 获取单位信息
  33. */
  34. public function company()
  35. {
  36. $rs = Company::where('id',$this->cid)->field('company_name,company_tel,sys_appid,wechat_appid,wechat_share_image,wechat_qrcode_image,routine_appid,share_title,share_info,wx_open_appid')->find();
  37. if($rs) {
  38. $this->success('获取成功', $rs->toArray());
  39. }
  40. }
  41. public function wxconfig()
  42. {
  43. $this->success('获取成功',json_decode(WechatService::jsSdk(input('url'),$this->cid),true));
  44. }
  45. public function geocoder(Request $request)
  46. {
  47. list($latitude,$longitude) = UtilService::getMore(
  48. [
  49. ['latitude',''],
  50. ['longitude',''],
  51. ],$request,true
  52. );
  53. if($latitude=='' || $longitude=='') $this->error('请先获取定位');
  54. $url = sprintf("https://apis.map.qq.com/ws/geocoder/v1/?location=%s,%s&key=VYZBZ-P2TRG-RMIQ3-ITAIN-2DKBK-CKFQQ",$latitude,$longitude);
  55. $rs = file_get_contents($url);
  56. $this->success('获取成功',json_decode($rs,true));
  57. }
  58. public function MiniScheme(Request $request)
  59. {
  60. $param = UtilService::postMore(
  61. [
  62. ['path',''],
  63. ['query',''],
  64. ],$request
  65. );
  66. $this->success(UtilService::getMiniScheme($this->cid,$param));
  67. }
  68. public function Minilink(Request $request)
  69. {
  70. $param = UtilService::postMore(
  71. [
  72. ['path',''],
  73. ['query',''],
  74. ],$request
  75. );
  76. $this->success(UtilService::getMiniLink($this->cid,$param));
  77. }
  78. public function test()
  79. {
  80. $params= json_decode('["oH3Q06tuUH-yzGX0r-FM2V6ucNYA",{"openid":"oH3Q06tuUH-yzGX0r-FM2V6ucNYA","nickname":"\u4e0d\u6253\u81ea\u62db","sex":0,"language":"","city":"","province":"","country":"","headimgurl":"https:\/\/thirdwx.qlogo.cn\/mmopen\/vi_32\/AoXC8Dwxrsic913iaUibZgQcRMLCiaDg6T95xqe7KBXl0frpvV9z3UpKrhPxylxytVZyaCBFaiaJV8qR00BuIZG8X9w\/132","subscribe":0,"cid":2},0,1]',true);
  81. Hook::exec("\\app\admin\\behavior\\User", "WechatOauth", $params);
  82. $user = User::where('id', UserRelation::openidToUid("oH3Q06tuUH-yzGX0r-FM2V6ucNYA", 'openid'))->find();
  83. dump($user);
  84. }
  85. }