HaitaoController.class.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Controller;
  15. class HaitaoController extends CommonController {
  16. protected function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->cur_page = 'haitao';
  20. }
  21. public function info()
  22. {
  23. $per_page = 2;
  24. $page = I('post.page',1);
  25. $offset = ($page - 1) * $per_page;
  26. $subject_id = I('get.subject_id',0);
  27. $this->subject_id = $subject_id;
  28. $this->fromindex = I('get.fromindex',0);
  29. $subject = M('guobie')->where( array('id' => $subject_id) )->find();
  30. $this->subject = $subject;
  31. $sql = 'select g.goods_id,g.name,g.quantity,g.pinprice,g.price,g.danprice,g.pin_count,g.image,g.fan_image,g.store_id,g.seller_count from '.C('DB_PREFIX')."guobie as sg , ".C('DB_PREFIX')."goods as g
  32. where sg.id ={$subject_id} and g.type='haitao' and sg.id = g.guobie_id and g.status =1 and g.quantity >0 order by sg.id asc limit {$offset},{$per_page}";
  33. $list = M()->query($sql);
  34. if(!empty($list)) {
  35. foreach($list as $key => $v){
  36. if(!empty($v['fan_image'])){
  37. $list[$key]['image']=resize($v['fan_image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  38. }else {
  39. $list[$key]['image']=resize($v['image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  40. }
  41. }
  42. }
  43. $this->list = $list;
  44. $type_template = array();
  45. $type_template['haitao'] = array('html' => 'haitao_info',
  46. 'fetch_html' => 'Haitao:haitao_ajax_info_fetch');
  47. if($page > 1) {
  48. $result = array('code' => 0);
  49. if(!empty($list)) {
  50. $result['code'] = 1;
  51. $result['html'] = $this->fetch($type_template['haitao']['fetch_html']);
  52. }
  53. echo json_encode($result);
  54. die();
  55. }
  56. $this->display($type_template['haitao']['html']);
  57. }
  58. //进行中
  59. public function index(){
  60. $haitao_list = M('guobie')->where( array('is_index' => 1) )->order('id asc')->limit(5)->select();
  61. $this->haitao_list = $haitao_list;
  62. $parent_category = M('goods_category')->where( array('is_haitao' => 1,'pid' => 0) )->order('sort_order asc')->find();
  63. $category_list = M('goods_category')->where( array('pid' =>$parent_category['id'],'is_haitao' => 1 ) )->order('sort_order asc')->select();
  64. $this->category_list = $category_list;
  65. $per_page = 4;
  66. $page = I('post.page',1);
  67. $offset = ($page - 1) * $per_page;
  68. $this->fromindex = I('get.fromindex',0);
  69. $sql = 'select g.goods_id,g.name,g.quantity,g.pinprice,g.price,g.danprice,g.pin_count,g.image,g.store_id,g.seller_count from '.C('DB_PREFIX')."guobie as sg , ".C('DB_PREFIX')."goods as g
  70. where g.type='haitao' and sg.is_index =1 and sg.id = g.guobie_id and g.status =1 and g.quantity >0 order by sg.id asc limit {$offset},{$per_page}";
  71. $list = M()->query($sql);
  72. $this->list = $list;
  73. $type_template = array();
  74. $type_template['haitao'] = array('html' => 'haitao_index',
  75. 'fetch_html' => 'Haitao:haitao_ajax_fetch');
  76. if($page > 1) {
  77. $result = array('code' => 0);
  78. if(!empty($list)) {
  79. $result['code'] = 1;
  80. $result['html'] = $this->fetch($type_template['haitao']['fetch_html']);
  81. }
  82. echo json_encode($result);
  83. die();
  84. }
  85. $this->display($type_template['haitao']['html']);
  86. }
  87. }