Index.php 3.1 KB

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