ShopdiyController.class.php 4.3 KB

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