Index.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. $all_ash = Config::where('name','all_ash')->value('value');
  31. $this->success('获取成功',compact('banner','bottom_menu','menu','all_ash'));
  32. }
  33. /**
  34. * 获取单位信息
  35. */
  36. public function company()
  37. {
  38. $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();
  39. if($rs) {
  40. $rs = $rs->toArray();
  41. $rs['all_ash'] = Config::where('name','all_ash')->value('value');
  42. $this->success('获取成功', $rs);
  43. }
  44. }
  45. public function wxconfig()
  46. {
  47. $this->success('获取成功',json_decode(WechatService::jsSdk(input('url'),$this->cid),true));
  48. }
  49. public function geocoder(Request $request)
  50. {
  51. list($latitude,$longitude) = UtilService::getMore(
  52. [
  53. ['latitude',''],
  54. ['longitude',''],
  55. ],$request,true
  56. );
  57. if($latitude=='' || $longitude=='') $this->error('请先获取定位');
  58. $url = sprintf("https://apis.map.qq.com/ws/geocoder/v1/?location=%s,%s&key=VYZBZ-P2TRG-RMIQ3-ITAIN-2DKBK-CKFQQ",$latitude,$longitude);
  59. $rs = file_get_contents($url);
  60. $this->success('获取成功',json_decode($rs,true));
  61. }
  62. public function MiniScheme(Request $request)
  63. {
  64. $param = UtilService::postMore(
  65. [
  66. ['path',''],
  67. ['query',''],
  68. ],$request
  69. );
  70. $this->success(UtilService::getMiniScheme($this->cid,$param));
  71. }
  72. public function Minilink(Request $request)
  73. {
  74. $param = UtilService::postMore(
  75. [
  76. ['path',''],
  77. ['query',''],
  78. ],$request
  79. );
  80. $this->success(UtilService::getMiniLink($this->cid,$param));
  81. }
  82. public function test()
  83. {
  84. $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);
  85. Hook::exec("\\app\admin\\behavior\\User", "WechatOauth", $params);
  86. $user = User::where('id', UserRelation::openidToUid("oH3Q06tuUH-yzGX0r-FM2V6ucNYA", 'openid'))->find();
  87. dump($user);
  88. }
  89. }