截流自动化的商城平台
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ShopApi.php 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop开源商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | gitee下载:https://gitee.com/likeshop_gitee
  7. // | github下载:https://github.com/likeshop-github
  8. // | 访问官网:https://www.likeshop.cn
  9. // | 访问社区:https://home.likeshop.cn
  10. // | 访问手册:http://doc.likeshop.cn
  11. // | 微信公众号:likeshop技术社区
  12. // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
  13. // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
  14. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  15. // | likeshop团队版权所有并拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshop.cn.team
  18. // +----------------------------------------------------------------------
  19. namespace app\common\basics;
  20. use think\App;
  21. /**
  22. * 商家后台移动端API接口基类
  23. * Class ShopApi
  24. * @package app\common\basics
  25. */
  26. abstract class ShopApi
  27. {
  28. /**
  29. * Request实例
  30. */
  31. protected $request;
  32. /**
  33. * 应用实例
  34. */
  35. protected $app;
  36. /**
  37. * 商家信息
  38. * @var
  39. */
  40. protected $shop;
  41. /**
  42. * 商家id
  43. * @var
  44. */
  45. protected $shop_id;
  46. /**
  47. * 管理员id
  48. * @var
  49. */
  50. protected $admin_id;
  51. /**
  52. * 管理员名称
  53. * @var
  54. */
  55. protected $admin_name;
  56. /**
  57. * 管理员信息
  58. * @var array
  59. */
  60. public $admin_info = [];
  61. public $shop_info = [];
  62. /**
  63. * 客户端
  64. * @var null
  65. */
  66. public $client = null;
  67. /**
  68. * 页码
  69. * @var int
  70. */
  71. public $page_no = 1;
  72. /**
  73. * 每页显示条数
  74. * @var int
  75. */
  76. public $page_size = 15;
  77. /**
  78. * 无需登录即可访问的方法
  79. * @var array
  80. */
  81. public $like_not_need_login = [];
  82. /**
  83. * 构造方法
  84. * @access public
  85. * @param App $app 应用对象
  86. */
  87. public function __construct(App $app)
  88. {
  89. $this->app = app();
  90. $this->request = request();
  91. // 控制器初始化
  92. $this->initialize();
  93. }
  94. /**
  95. * 初始化
  96. */
  97. protected function initialize()
  98. {
  99. //用户信息
  100. $this->admin_info = $this->request->admin_info ?? [];
  101. if(boolval($this->admin_info)) {
  102. $this->shop = $this->admin_info ?? null;
  103. $this->shop_id = $this->admin_info['shop_id'] ?? null;
  104. $this->shop_name = $this->admin_info['shop_name'] ?? null;
  105. $this->admin_id = $this->admin_info['id'] ?? null;
  106. $this->admin_name = $this->admin_info['name'] ?? null;
  107. $this->client = $this->admin_info['client'] ?? null;
  108. }
  109. //分页参数
  110. $page_no = (int)$this->request->get('page_no');
  111. $this->page_no = $page_no && is_numeric($page_no) ? $page_no : $this->page_no;
  112. $page_size = (int)$this->request->get('page_size');
  113. $this->page_size = $page_size && is_numeric($page_size) ? $page_size : $this->page_size;
  114. $this->page_size = min($this->page_size, 100);
  115. }
  116. }