Common.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace app\admin\controller;
  3. /**
  4. *
  5. *
  6. * ----------------------------------------------------------------------------
  7. *
  8. * 控制器
  9. */
  10. class Common extends AdminControl
  11. {
  12. public function initialize()
  13. {
  14. parent::initialize(); // TODO: Change the autogenerated stub
  15. }
  16. /**
  17. * 查询每月的周数组
  18. */
  19. public function getweekofmonth()
  20. {
  21. include_once root_path() . 'extend/mall/datehelper.php';
  22. $year = input('param.y');
  23. $month = input('param.m');
  24. $week_arr = getMonthWeekArr($year, $month);
  25. echo json_encode($week_arr);
  26. die;
  27. }
  28. public function ajax_get_brand()
  29. {
  30. $initial = trim(input('param.letter'));
  31. $keyword = trim(input('param.keyword'));
  32. $type = trim(input('param.type'));
  33. if (!in_array($type, array('letter', 'keyword')) || ($type == 'letter' && empty($initial)) || ($type == 'keyword' && empty($keyword))) {
  34. echo json_encode(array());
  35. die();
  36. }
  37. // 实例化模型
  38. $where = array();
  39. // 验证类型是否关联品牌
  40. if ($type == 'letter') {
  41. switch ($initial) {
  42. case 'all':
  43. break;
  44. case '0-9':
  45. $where[] = array('brand_initial', 'in', array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));
  46. break;
  47. default:
  48. $where[] = array('brand_initial', '=', $initial);
  49. break;
  50. }
  51. } else {
  52. $where[] = array('brand_name|brand_initial', 'like', '%' . $keyword . '%');
  53. }
  54. $brand_array = model('brand')->getBrandPassedList($where, 'brand_id,brand_name,brand_initial', 0, 'brand_initial asc, brand_sort asc');
  55. echo json_encode($brand_array);
  56. die();
  57. }
  58. }