ShopdiyController.class.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. *
  6. * @author fish
  7. *
  8. */
  9. namespace Seller\Controller;
  10. class ShopdiyController extends CommonController{
  11. protected function _initialize(){
  12. parent::_initialize();
  13. }
  14. public function index()
  15. {
  16. // 组件数据
  17. $diyviewData = file_get_contents(__ROOT__ . './static/js/diy/diyview.json');
  18. $diyview = json_decode($diyviewData, true);
  19. $goods_category_list = D('Seller/GoodsCategory')->getFullCategory();
  20. $data = D('Seller/Config')->get_all_config();
  21. $global = 0;
  22. $diyJson = 0;
  23. $newdata = D('Seller/Diydata')->get_all_config();
  24. if(!empty($newdata)) {
  25. $diyJson = json_encode($newdata);
  26. if($data['index_diy_json']) {
  27. $diyDataRes = unserialize($data['index_diy_json']);
  28. $global = htmlspecialchars_decode($diyDataRes["global"]);
  29. }
  30. } else if($data['index_diy_json']) {
  31. // 旧数据兼容处理
  32. $diyDataRes = unserialize($data['index_diy_json']);
  33. $diyData = htmlspecialchars_decode($diyDataRes['value']);
  34. $diyDataJson = json_decode($diyData);
  35. $global = json_encode($diyDataJson->global);
  36. $diyJson = json_encode($diyDataJson->value);
  37. if($global=="null") {
  38. $global = htmlspecialchars_decode($diyDataRes["global"]);
  39. }
  40. }
  41. $openDiyPage = D('Home/Front')->get_config_by_name('open_diy_index_page');
  42. $this->global = $global;
  43. $this->openDiyPage = $openDiyPage;
  44. $this->diyJson = $diyJson;
  45. $this->resourceurl = '/static/diycomponent';
  46. $this->diyview = $diyview;
  47. $this->goods_category_list = $goods_category_list;
  48. $this->display();
  49. }
  50. public function link()
  51. {
  52. // 组件数据
  53. $linkData = file_get_contents(__ROOT__ . './static/js/diy/linklist.json');
  54. $list = json_decode($linkData, true);
  55. $link = I('request.link', '');
  56. $category_list = D('Seller/GoodsCategory')->getThreeCategory();
  57. $this->category_list = $category_list;
  58. $this->link = $link;
  59. $link = stripslashes(html_entity_decode($link));
  60. $this->link_array = \json_decode($link, true);
  61. $this->list = $list;
  62. $this->display();
  63. }
  64. public function childLink()
  65. {
  66. $link = I('request.link', array());
  67. $name = I('request.name', array());
  68. $is_array = true;
  69. if (!empty($link)) {
  70. $link = htmlspecialchars_decode($link);
  71. $link = json_decode($link, true);
  72. $is_array = is_array($link);
  73. }
  74. $res = array( "link" => $link, "list" => array() );
  75. echo json_encode($res);
  76. die();
  77. }
  78. public function save()
  79. {
  80. $params = I('request.');
  81. $valueJson = $params["value"];
  82. $valueJson = htmlspecialchars_decode($valueJson);
  83. $value = json_decode($valueJson);
  84. D('Seller/Diydata')->update($value);
  85. $data = array();
  86. $data['open_diy_index_page'] = intval($params['openDiyPage']);
  87. unset($params["value"]);
  88. unset($params["openDiyPage"]);
  89. $data['index_diy_json'] = serialize($params);
  90. D('Seller/Config')->update($data);
  91. show_json(1, array('url' => U('Shopdiy/index')));
  92. die();
  93. }
  94. public function goodsSelect()
  95. {
  96. if (IS_GET) {
  97. $page = I('request.page', 1);
  98. $page_size = I('request.page_size', 10);
  99. $promotion = I('request.promotion', '');
  100. $condition = " type='".$promotion."' and grounding=1 and total > 0 ";
  101. $sql = 'SELECT id FROM ' .C('DB_PREFIX'). 'lionfish_comshop_goods WHERE' .$condition;
  102. $count=count(M()->query($sql));
  103. $Page = new \Think\Page($count, $page_size);
  104. $list = M()->query('SELECT id,goodsname as title,productprice,price as marketprice,total FROM '.C('DB_PREFIX').'lionfish_comshop_goods WHERE '.$condition.' LIMIT '.($page-1)*$page_size.','.$Page->listRows);
  105. if(count($list)) {
  106. foreach($list as $kk => $vv)
  107. {
  108. $thumb = M('lionfish_comshop_goods_images')->where( array('goods_id' => $vv['id'] ) )->order('id asc')->find();
  109. // $vv['image'] = tomedia($thumb['image']);
  110. $vv['image'] = $thumb['thumb'];
  111. $list[$kk] = $vv;
  112. }
  113. }
  114. $page_count = ceil($count/$page_size);
  115. $res = array( "code" => 0, "data" => array('list'=>$list, 'count'=>$count, 'page_count'=>$page_count) );
  116. echo json_encode($res);
  117. die();
  118. }
  119. }
  120. }
  121. ?>