Common.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\admin\controller;
  3. /**
  4. * ============================================================================
  5. *
  6. * ============================================================================
  7. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  8. * 网站地址: https://www.valimart.net/
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 控制器
  13. */
  14. class Common extends AdminControl {
  15. public function initialize() {
  16. parent::initialize(); // TODO: Change the autogenerated stub
  17. }
  18. /**
  19. * 查询每月的周数组
  20. */
  21. public function getweekofmonth() {
  22. include_once root_path(). 'extend/mall/datehelper.php';
  23. $year = input('param.y');
  24. $month = input('param.m');
  25. $week_arr = getMonthWeekArr($year, $month);
  26. echo json_encode($week_arr);
  27. die;
  28. }
  29. public function ajax_get_brand() {
  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. }