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

KefuBase.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. * 客服模块基类
  23. * Class KefuBase
  24. * @package app\common\basics
  25. */
  26. abstract class KefuBase
  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 $kefu_id;
  51. /**
  52. * 客服名称
  53. * @var
  54. */
  55. protected $kefu_name;
  56. /**
  57. * 客服信息
  58. * @var array
  59. */
  60. public $kefu_info = [];
  61. /**
  62. * 客户端
  63. * @var null
  64. */
  65. public $client = null;
  66. /**
  67. * 页码
  68. * @var int
  69. */
  70. public $page_no = 1;
  71. /**
  72. * 每页显示条数
  73. * @var int
  74. */
  75. public $page_size = 15;
  76. /**
  77. * 无需登录即可访问的方法
  78. * @var array
  79. */
  80. public $like_not_need_login = [];
  81. /**
  82. * 构造方法
  83. * @access public
  84. * @param App $app 应用对象
  85. */
  86. public function __construct(App $app)
  87. {
  88. $this->app = app();
  89. $this->request = request();
  90. // 控制器初始化
  91. $this->initialize();
  92. }
  93. /**
  94. * 初始化
  95. */
  96. protected function initialize()
  97. {
  98. //客服信息
  99. if (isset($this->request->kefu_info) && $this->request->kefu_info) {
  100. $this->kefu_info = $this->request->kefu_info ?? [];
  101. }
  102. if(boolval($this->kefu_info)) {
  103. $this->shop_id = $this->kefu_info['shop_id'] ?? 0;
  104. $this->kefu_id = $this->kefu_info['id'] ?? null;
  105. $this->kefu_name = $this->kefu_info['nickname'] ?? null;
  106. $this->client = $this->kefu_info['client'] ?? null;
  107. }
  108. //分页参数
  109. $page_no = (int)$this->request->get('page_no');
  110. $this->page_no = $page_no && is_numeric($page_no) ? $page_no : $this->page_no;
  111. $page_size = (int)$this->request->get('page_size');
  112. $this->page_size = $page_size && is_numeric($page_size) ? $page_size : $this->page_size;
  113. $this->page_size = min($this->page_size, 100);
  114. }
  115. }