Address.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Index.php
  4. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  5. * =========================================================
  6. * Copy right 2015-2025 山西牛酷信息科技有限公司, 保留所有权利。
  7. * ----------------------------------------------
  8. * 官方网址: http://www.niushop.com.cn
  9. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  10. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  11. * =========================================================
  12. * @author : niuteam
  13. * @date : 2015.1.17
  14. * @version : v1.0.0.0
  15. */
  16. namespace app\api\controller;
  17. use app\model\system\Address as AddressModel;
  18. /**
  19. * 地址管理
  20. * @author Administrator
  21. *
  22. */
  23. class Address extends BaseApi
  24. {
  25. /**
  26. * 基础信息
  27. */
  28. public function info()
  29. {
  30. $id = $this->params['id'];
  31. $address = new AddressModel();
  32. $info = $address->getAreaInfo($id);
  33. return $this->response($info);
  34. }
  35. /**
  36. * 列表信息
  37. */
  38. public function lists()
  39. {
  40. $pid = isset($this->params['pid']) ? $this->params['pid'] : 0;
  41. $address = new AddressModel();
  42. $list = $address->getAreas($pid);
  43. return $this->response($list);
  44. }
  45. /**
  46. * 树状结构信息
  47. */
  48. public function tree()
  49. {
  50. $id = $this->params['id'];
  51. $address = new AddressModel();
  52. $tree = $address->getAreas($id);
  53. return $this->response($tree);
  54. }
  55. /**
  56. * 获取全部城市列表
  57. */
  58. public function city(){
  59. $address = new AddressModel();
  60. $data = $address->getAreaList([ ['level', '=', 2], ['status', '=', 1] ], 'id,shortname as title', 'sort asc');
  61. return $this->response($data);
  62. }
  63. /**
  64. * 根据城市名称获取城市
  65. */
  66. public function cityByName(){
  67. $name = $this->params['city'] ?? '';
  68. $address = new AddressModel();
  69. $data = $address->getAreasInfo([ ['name', 'like', "%{$name}%"], ['level', '=', 2], ['status', '=', 1] ], 'id,shortname as title');
  70. return $this->response($data);
  71. }
  72. }