Index.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace addons\address\controller;
  3. use think\addons\Controller;
  4. use think\Config;
  5. use think\Hook;
  6. class Index extends Controller
  7. {
  8. public function index()
  9. {
  10. // 语言检测
  11. $lang = strip_tags($this->request->langset());
  12. $site = Config::get("site");
  13. // 配置信息
  14. $config = [
  15. 'site' => array_intersect_key($site, array_flip(['name', 'cdnurl', 'version', 'timezone', 'languages'])),
  16. 'upload' => null,
  17. 'modulename' => 'addons',
  18. 'controllername' => 'index',
  19. 'actionname' => 'index',
  20. 'jsname' => 'addons/address',
  21. 'moduleurl' => '',
  22. 'language' => $lang
  23. ];
  24. $config = array_merge($config, Config::get("view_replace_str"));
  25. // 配置信息后
  26. Hook::listen("config_init", $config);
  27. // 加载当前控制器语言包
  28. $this->view->assign('site', $site);
  29. $this->view->assign('config', $config);
  30. return $this->view->fetch();
  31. }
  32. /**
  33. * 选择地址
  34. * @return string
  35. * @throws \think\Exception
  36. */
  37. public function select()
  38. {
  39. $config = get_addon_config('address');
  40. $lat = $this->request->get('lat', $config['lat']);
  41. $lng = $this->request->get('lng', $config['lng']);
  42. $this->view->assign('lat', $lat);
  43. $this->view->assign('lng', $lng);
  44. $this->view->assign('location', $config['location']);
  45. return $this->view->fetch('index/' . $config['maptype']);
  46. }
  47. }