Common.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\logic\CommonLogic;
  4. use app\BaseController;
  5. use think\exception\ValidateException;
  6. use think\facade\Config;
  7. use think\facade\Validate;
  8. //公共
  9. class Common extends BaseController
  10. {
  11. //登录
  12. public function Login()
  13. {
  14. $param = $this->request->only(['username', 'password'], 'post');
  15. $val = Validate::rule(Config::get('validate_rules.login'));
  16. if (!$val->check($param)) throw new ValidateException($val->getError());
  17. return CommonLogic::Logic($param);
  18. }
  19. //登出
  20. public function logout()
  21. {
  22. return CommonLogic::logout($this->request->post('token', ''));
  23. }
  24. //上传图片
  25. public function upload()
  26. {
  27. $files = $this->request->file('image');
  28. return CommonLogic::upload($files);
  29. }
  30. //获取全部商品单位
  31. public function unitAll(){
  32. $keyword = $this->request->post('keyword', '');
  33. return CommonLogic::unitAll($keyword);
  34. }
  35. //获取省市区地址
  36. public function getAddr(){
  37. $parent_code = $this->request->post('parent_code', '');
  38. return CommonLogic::getAddr($parent_code);
  39. }
  40. }