ConfigindexController.class.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. *
  6. * @author fish
  7. *
  8. */
  9. namespace Seller\Controller;
  10. class ConfigindexController extends CommonController{
  11. protected function _initialize(){
  12. parent::_initialize();
  13. //'pinjie' => '拼团介绍',
  14. }
  15. public function navigat()
  16. {
  17. $_GPC = I('request.');
  18. $pindex = max(1, intval($_GPC['page']));
  19. $psize = 20;
  20. $condition = "";
  21. if (!empty($_GPC['keyword'])) {
  22. $condition .= ' and navname like "%'.trim($_GPC['keyword']).'%"';
  23. }
  24. if (isset($_GPC['enabled']) && $_GPC['enabled'] >= 0) {
  25. $condition .= ' and enabled = ' . $_GPC['enabled'];
  26. } else {
  27. $_GPC['enabled'] = -1;
  28. }
  29. $list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_navigat
  30. WHERE 1 " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  31. $total = M('lionfish_comshop_navigat')->where('1 '. $condition )->count();
  32. $pager = pagination2($total, $pindex, $psize);
  33. $this->_GPC = $_GPC;
  34. $this->list = $list;
  35. $this->display();
  36. }
  37. public function slider()
  38. {
  39. $condition = ' type="slider" ';
  40. $pindex = I('request.page', 1);
  41. $psize = 20;
  42. $keyword = I('request.keyword');
  43. $this->keyword = $keyword;
  44. if (!empty($keyword)) {
  45. $condition .= ' and advname like '.'"%' . $keyword . '%"';
  46. }
  47. $enabled = I('request.enabled');
  48. if (!empty($enabled) && $enabled >= 0) {
  49. $condition .= ' and enabled = ' . $enabled;
  50. } else {
  51. $enabled = -1;
  52. }
  53. $this->enabled = $enabled;
  54. $list = M()->query('SELECT id,advname,thumb,link,type,displayorder,enabled FROM ' .
  55. C('DB_PREFIX'). "lionfish_comshop_adv \r\n
  56. WHERE " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  57. $total = M('lionfish_comshop_adv')->where($condition)->count();
  58. $pager = pagination2($total, $pindex, $psize);
  59. $this->list = $list;
  60. $this->pager = $pager;
  61. $this->display();
  62. }
  63. public function category()
  64. {
  65. $condition = ' type="slider" ';
  66. $pindex = I('request.page', 1);
  67. $psize = 20;
  68. $keyword = I('request.keyword');
  69. $this->keyword = $keyword;
  70. if (!empty($keyword)) {
  71. $condition .= ' and advname like '.'"%' . $keyword . '%"';
  72. }
  73. $enabled = I('request.enabled',-1);
  74. if (!empty($enabled) && $enabled >= 0) {
  75. $condition .= ' and enabled = ' . $enabled;
  76. } else {
  77. $enabled = -1;
  78. }
  79. $this->enabled = $enabled;
  80. $list = M()->query('SELECT id,cate_id,advname,thumb,link,type,displayorder,enabled FROM ' .
  81. C('DB_PREFIX'). "lionfish_comshop_adv_category \r\n
  82. WHERE " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  83. if( !empty($list) )
  84. {
  85. foreach( $list as $key => $val )
  86. {
  87. $cate_info = M('lionfish_comshop_goods_category')->field('id,name')->where("id=".$val['cate_id'])->find();
  88. $val['cate_name'] = '无分类';
  89. if( !empty($cate_info) )
  90. {
  91. $val['cate_name'] = $cate_info['name'];
  92. }
  93. $list[$key] = $val;
  94. }
  95. }
  96. $total = M('lionfish_comshop_adv')->where($condition)->count();
  97. $pager = pagination2($total, $pindex, $psize);
  98. $this->list = $list;
  99. $this->pager = $pager;
  100. $this->display();
  101. }
  102. //
  103. public function addnavigat()
  104. {
  105. $_GPC = I('request.');
  106. $id = intval($_GPC['id']);
  107. $category = D('Seller/GoodsCategory')->getFullCategory(false, true);
  108. $this->category = $category;
  109. if (!empty($id)) {
  110. // $category = D('Seller/GoodsCategory')->getFullCategory(false, true);
  111. // $this->category = $category;
  112. $item = M('lionfish_comshop_navigat')->where( array('id' => $id) )->find();
  113. if($item['type']==6) {
  114. $couponinfo = M('lionfish_comshop_coupon')->field('id, voucher_title')->where('id in( ' . $item['link'] . ' ) ')->select();
  115. $this->couponinfo = $couponinfo;
  116. }
  117. $this->item = $item;
  118. }
  119. if (IS_POST) {
  120. $data = $_GPC['data'];
  121. if($data['type']==3 || $data['type']==4){
  122. $data['link'] = $data['cid'];
  123. }
  124. if($data['type']==6){
  125. $coupon_id_list = $_GPC['coupon_id'];
  126. $data['link'] = implode(',', $coupon_id_list);
  127. }
  128. D('Seller/Adv')->navigat_update($data);
  129. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  130. }
  131. $this->display();
  132. }
  133. public function changenavigat()
  134. {
  135. $_GPC = I('request.');
  136. $id = intval($_GPC['id']);
  137. //ids
  138. if (empty($id)) {
  139. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  140. }
  141. if (empty($id)) {
  142. show_json(0, array('message' => '参数错误'));
  143. }
  144. $type = trim($_GPC['type']);
  145. $value = trim($_GPC['value']);
  146. if (!(in_array($type, array('enabled', 'displayorder')))) {
  147. show_json(0, array('message' => '参数错误'));
  148. }
  149. $items = M('lionfish_comshop_navigat')->field('id')->where('id in( ' . $id . ' ) ')->select();
  150. foreach ($items as $item) {
  151. M('lionfish_comshop_navigat')->where( array('id' => $item['id']) )->save( array($type => $value) );
  152. }
  153. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  154. }
  155. public function deletenavigat()
  156. {
  157. $_GPC = I('request.');
  158. $id = intval($_GPC['id']);
  159. //ids
  160. if (empty($id)) {
  161. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  162. }
  163. if (empty($id)) {
  164. show_json(0, array('message' => '参数错误'));
  165. }
  166. $items = M('lionfish_comshop_navigat')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  167. foreach ($items as $item) {
  168. M('lionfish_comshop_navigat')->where( array('id' => $item['id']) )->delete();
  169. }
  170. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  171. }
  172. //
  173. public function addslider()
  174. {
  175. $_GPC = I('request.');
  176. $id = I('request.id');
  177. if (!empty($id)) {
  178. $item = M('lionfish_comshop_adv')->where( array('id' => $id) )->find();
  179. if($item['linktype']==6&&$item['link']) {
  180. $couponinfo = M('lionfish_comshop_coupon')->field('id, voucher_title')->where('id in( ' . $item['link'] . ' ) ')->select();
  181. $this->couponinfo = $couponinfo;
  182. }
  183. $this->item = $item;
  184. }
  185. if (IS_POST) {
  186. $data = I('request.data');
  187. if($data['linktype']==6){
  188. $coupon_id_list = $_GPC['coupon_id'];
  189. $data['link'] = implode(',', $coupon_id_list);
  190. }
  191. D('Seller/Adv')->update($data);
  192. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  193. }
  194. $this->display();
  195. }
  196. public function addcategory()
  197. {
  198. $_GPC = I('request.');
  199. $id = I('request.id');
  200. if (!empty($id)) {
  201. $item = M('lionfish_comshop_adv_category')->where( array('id' => $id) )->find();
  202. if($item['linktype']==6&&$item['link']) {
  203. $couponinfo = M('lionfish_comshop_coupon')->field('id, voucher_title')->where('id in( ' . $item['link'] . ' ) ')->select();
  204. $this->couponinfo = $couponinfo;
  205. }
  206. $this->item = $item;
  207. }
  208. if (IS_POST) {
  209. $data = I('request.data');
  210. if($data['linktype']==6){
  211. $coupon_id_list = $_GPC['coupon_id'];
  212. $data['link'] = implode(',', $coupon_id_list);
  213. }
  214. D('Seller/Adv')->updatecagetory($data);
  215. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  216. }
  217. $goods_category_list = M('lionfish_comshop_goods_category')->field('id,name')->where("pid=0 and cate_type='normal' ")->select();
  218. $this->goods_category_list = $goods_category_list;
  219. $this->display();
  220. }
  221. public function changecategory()
  222. {
  223. $id = I('request.id');
  224. //ids
  225. if (empty($id)) {
  226. $ids = I('request.ids');
  227. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  228. }
  229. if (empty($id)) {
  230. show_json(0, array('message' => '参数错误'));
  231. }
  232. $type = I('request.type');
  233. $value = I('request.value');
  234. if (!(in_array($type, array('enabled', 'displayorder')))) {
  235. show_json(0, array('message' => '参数错误'));
  236. }
  237. $items = M('lionfish_comshop_adv_category')->where( array('id' => array('in', $id)) )->select();
  238. foreach ($items as $item) {
  239. M('lionfish_comshop_adv_category')->where( array('id' => $item['id']) )->save( array($type => $value) );
  240. }
  241. show_json(1 , array('url' => $_SERVER['HTTP_REFERER']));
  242. }
  243. public function changeslider()
  244. {
  245. $id = I('request.id');
  246. //ids
  247. if (empty($id)) {
  248. $ids = I('request.ids');
  249. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  250. }
  251. if (empty($id)) {
  252. show_json(0, array('message' => '参数错误'));
  253. }
  254. $type = I('request.type');
  255. $value = I('request.value');
  256. if (!(in_array($type, array('enabled', 'displayorder')))) {
  257. show_json(0, array('message' => '参数错误'));
  258. }
  259. $items = M('lionfish_comshop_adv')->where( array('id' => array('in', $id)) )->select();
  260. foreach ($items as $item) {
  261. M('lionfish_comshop_adv')->where( array('id' => $item['id']) )->save( array($type => $value) );
  262. }
  263. show_json(1 , array('url' => $_SERVER['HTTP_REFERER']));
  264. }
  265. public function delete()
  266. {
  267. $id = I('request.id');
  268. //ids
  269. if (empty($id)) {
  270. $ids = I('request.ids');
  271. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  272. }
  273. if (empty($id)) {
  274. show_json(0, array('message' => '参数错误'));
  275. }
  276. $items = M('lionfish_comshop_adv')->where( array('id' => array('in', $id)) )->select();
  277. foreach ($items as $item) {
  278. M('lionfish_comshop_adv')->where( array('id' => $item['id']) )->delete();
  279. }
  280. show_json(1 , array('url' => $_SERVER['HTTP_REFERER']));
  281. }
  282. public function deletecategory()
  283. {
  284. $id = I('request.id');
  285. //ids
  286. if (empty($id)) {
  287. $ids = I('request.ids');
  288. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  289. }
  290. if (empty($id)) {
  291. show_json(0, array('message' => '参数错误'));
  292. }
  293. $items = M('lionfish_comshop_adv_category')->where( array('id' => array('in', $id)) )->select();
  294. foreach ($items as $item) {
  295. M('lionfish_comshop_adv_category')->where( array('id' => $item['id']) )->delete();
  296. }
  297. show_json(1 , array('url' => $_SERVER['HTTP_REFERER']));
  298. }
  299. /**
  300. * 公告管理
  301. */
  302. public function notice()
  303. {
  304. $pindex = I('request.page',1);
  305. $psize = 20;
  306. $keyword = I('request.keyword','','trim');
  307. $this->keyword = $keyword;
  308. if (!empty($keyword)) {
  309. $condition .= ' and content like "%'.$keyword.'%" ';
  310. }
  311. $enabled = I('request.enabled',-1);
  312. if (isset($enabled) && $enabled >= 0) {
  313. $condition .= ' and enabled = ' . $enabled;
  314. } else {
  315. $enabled = -1;
  316. }
  317. $this->enabled = $enabled;
  318. $list = M()->query('SELECT id,content,displayorder,enabled FROM ' .
  319. C('DB_PREFIX')."lionfish_comshop_notice
  320. WHERE 1=1 " . $condition . ' order by displayorder desc, id desc
  321. limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  322. $total = M('lionfish_comshop_notice')->where( "1=1 ".$condition )->count();
  323. $pager = pagination2($total, $pindex, $psize);
  324. $this->list = $list;
  325. $this->pager = $pager;
  326. $this->display();
  327. }
  328. /**
  329. * 添加公告
  330. */
  331. public function addnotice()
  332. {
  333. $id = I('request.id');
  334. if (!empty($id)) {
  335. $item = M('lionfish_comshop_notice')->where( array('id' => $id) )->find();
  336. $this->item = $item;
  337. }
  338. if (IS_POST) {
  339. $data = I('request.data');
  340. D('Seller/Notice')->update($data);
  341. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  342. }
  343. $this->display();
  344. }
  345. /**
  346. * 改变公告状态
  347. */
  348. public function changenotice()
  349. {
  350. $id = I('request.id');
  351. //ids
  352. if (empty($id)) {
  353. $ids = I('request.ids');
  354. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  355. }
  356. if (empty($id)) {
  357. show_json(0, array('message' => '参数错误'));
  358. }
  359. $type = I('request.type');
  360. $value = I('request.value');
  361. if (!(in_array($type, array('enabled', 'displayorder')))) {
  362. show_json(0, array('message' => '参数错误'));
  363. }
  364. $items = M('lionfish_comshop_notice')->where( array('id' => array('in', $id)) )->select();
  365. foreach ($items as $item) {
  366. M('lionfish_comshop_notice')->where( array('id' => $item['id']) )->save( array($type => $value) );
  367. }
  368. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  369. }
  370. /**
  371. * 删除公告
  372. */
  373. public function deletenotice()
  374. {
  375. $id = I('request.id');
  376. if (empty($id)) {
  377. $ids = I('request.ids');
  378. $id = (is_array($ids) ? implode(',', $ids) : 0);
  379. }
  380. $items = M('lionfish_comshop_notice')->field('id,content')->where( array('id' => array('in',$id)) )->select();
  381. if (empty($item)) {
  382. $item = array();
  383. }
  384. foreach ($items as $item) {
  385. M('lionfish_comshop_notice')->where( array('id' => $item['id']) )->delete();
  386. }
  387. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  388. }
  389. public function index()
  390. {
  391. if (IS_POST) {
  392. $data = I('request.parameter');
  393. $param = array();
  394. if(trim($data['wechat_apiclient_cert_pem'])) $param['wechat_apiclient_cert_pem'] = trim($data['wechat_apiclient_cert_pem']);
  395. if(trim($data['wechat_apiclient_key_pem'])) $param['wechat_apiclient_key_pem'] = trim($data['wechat_apiclient_key_pem']);
  396. if(trim($data['wechat_rootca_pem'])) $param['wechat_rootca_pem'] = trim($data['wechat_rootca_pem']);
  397. if(trim($data['weapp_apiclient_cert_pem'])) $param['weapp_apiclient_cert_pem'] = trim($data['weapp_apiclient_cert_pem']);
  398. if(trim($data['weapp_apiclient_key_pem'])) $param['weapp_apiclient_key_pem'] = trim($data['weapp_apiclient_key_pem']);
  399. if(trim($data['weapp_rootca_pem'])) $param['weapp_rootca_pem'] = trim($data['weapp_rootca_pem']);
  400. if(trim($data['app_apiclient_cert_pem'])) $param['app_apiclient_cert_pem'] = trim($data['app_apiclient_cert_pem']);
  401. if(trim($data['app_apiclient_key_pem'])) $param['app_apiclient_key_pem'] = trim($data['app_apiclient_key_pem']);
  402. if(trim($data['app_rootca_pem'])) $param['app_rootca_pem'] = trim($data['app_rootca_pem']);
  403. D('Seller/Config')->update($param);
  404. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  405. }
  406. $data = D('Seller/Config')->get_all_config();
  407. $this->data = $data;
  408. $this->display();
  409. }
  410. public function noticesetting()
  411. {
  412. if (IS_POST) {
  413. $data = I('request.parameter');
  414. $data['index_notice_horn_image'] = save_media($data['index_notice_horn_image']);
  415. D('Seller/Config')->update($data);
  416. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  417. }
  418. $data = D('Seller/Config')->get_all_config();
  419. $this->data = $data;
  420. $this->display();
  421. }
  422. public function qgtab()
  423. {
  424. if (IS_POST) {
  425. $data = I('request.parameter');
  426. $data['index_qgtab_one_select'] = save_media($data['index_qgtab_one_select']);
  427. $data['index_qgtab_one_selected'] = save_media($data['index_qgtab_one_selected']);
  428. $data['index_qgtab_two_select'] = save_media($data['index_qgtab_two_select']);
  429. $data['index_qgtab_two_selected'] = save_media($data['index_qgtab_two_selected']);
  430. D('Seller/Config')->update($data);
  431. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  432. }
  433. $data = D('Seller/Config')->get_all_config();
  434. $this->data = $data;
  435. $this->display();
  436. }
  437. /**
  438. * 图片魔方
  439. */
  440. public function cube()
  441. {
  442. $_GPC = I('request.');
  443. $condition = '';
  444. $pindex = max(1, intval($_GPC['page']));
  445. $psize = 20;
  446. if (!empty($_GPC['keyword'])) {
  447. $_GPC['keyword'] = trim($_GPC['keyword']);
  448. $condition .= ' and name like "%'.$_GPC['keyword'].'%"';
  449. }
  450. if (isset($_GPC['enabled']) && $_GPC['enabled'] >= 0) {
  451. $_GPC['enabled'] = trim($_GPC['enabled']);
  452. $condition .= ' and enabled = ' . $_GPC['enabled'];
  453. } else {
  454. $_GPC['enabled'] = -1;
  455. }
  456. $list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_cube
  457. WHERE 1 " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize );
  458. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX'). 'lionfish_comshop_cube WHERE 1 ' . $condition );
  459. $total = $total_arr['0']['count'];
  460. $pager = pagination2($total, $pindex, $psize);
  461. $this->list = $list;
  462. $this->pager = $pager;
  463. $this->_GPC =$_GPC;
  464. $this->display();
  465. }
  466. /**
  467. * 添加魔方图片
  468. */
  469. public function addcube()//
  470. {
  471. $_GPC = I('request.');
  472. $id = intval($_GPC['id']);
  473. if (!empty($id)) {
  474. $item = M('lionfish_comshop_cube')->where( array('id' => $id ) )->find();
  475. $item['thumb'] = unserialize($item['thumb']);
  476. $couponinfo = array();
  477. if($item['thumb'] && $item['thumb']['cover']) {
  478. $thumb = $item['thumb'];
  479. $cover = $item['thumb']['cover'];
  480. foreach ($cover as $k => $vv) {
  481. if($thumb['linktype'][$k]==6&&$thumb['link'][$k]) {
  482. $couponinfo[] = M('lionfish_comshop_coupon')->field('id, voucher_title')->where('id in( ' . $thumb['link'][$k] . ' ) ')->select();
  483. } else {
  484. $couponinfo[] = '';
  485. }
  486. }
  487. }
  488. $this->couponinfo = $couponinfo;
  489. $this->item = $item;
  490. }
  491. $category = D('Seller/GoodsCategory')->getFullCategory(false, true);
  492. $this->category = $category;
  493. if ( IS_POST ) {
  494. $data = $_GPC['data'];
  495. $thumb = $cover = $link = array();
  496. $cover[] = $data["thumb_0"];
  497. $cover[] = $data["thumb_1"];
  498. $cover[] = $data["thumb_2"];
  499. $cover[] = $data["thumb_3"];
  500. if($data["linktype_0"]==6) {
  501. $coupon_id_list_0 = $_GPC['coupon_id_0'];
  502. $link[] = implode(',', $coupon_id_list_0);
  503. } else {
  504. $link[] = $data["link_0"];
  505. }
  506. if($data["linktype_1"]==6) {
  507. $coupon_id_list_1 = $_GPC['coupon_id_1'];
  508. $link[] = implode(',', $coupon_id_list_1);
  509. } else {
  510. $link[] = $data["link_1"];
  511. }
  512. if($data["linktype_2"]==6) {
  513. $coupon_id_list_2 = $_GPC['coupon_id_2'];
  514. $link[] = implode(',', $coupon_id_list_2);
  515. } else {
  516. $link[] = $data["link_2"];
  517. }
  518. if($data["linktype_3"]==6) {
  519. $coupon_id_list_3 = $_GPC['coupon_id_3'];
  520. $link[] = implode(',', $coupon_id_list_3);
  521. } else {
  522. $link[] = $data["link_3"];
  523. }
  524. $linktype[] = $data["linktype_0"];
  525. $linktype[] = $data["linktype_1"];
  526. $linktype[] = $data["linktype_2"];
  527. $linktype[] = $data["linktype_3"];
  528. $webview[] = $data["webview_0"];
  529. $webview[] = $data["webview_1"];
  530. $webview[] = $data["webview_2"];
  531. $webview[] = $data["webview_3"];
  532. $cateid[] = $data["cateid_0"];
  533. $cateid[] = $data["cateid_1"];
  534. $cateid[] = $data["cateid_2"];
  535. $cateid[] = $data["cateid_3"];
  536. $appid[] = $data["appid_0"];
  537. $appid[] = $data["appid_1"];
  538. $appid[] = $data["appid_2"];
  539. $appid[] = $data["appid_3"];
  540. $outlink[] = $data["outlink_0"];
  541. $outlink[] = $data["outlink_1"];
  542. $outlink[] = $data["outlink_2"];
  543. $outlink[] = $data["outlink_3"];
  544. $num = $data['num'];
  545. if($num==4){
  546. $thumb['cover'] = $cover;
  547. $thumb['link'] = $link;
  548. $thumb['linktype'] = $linktype;
  549. $thumb['webview'] = $webview;
  550. $thumb['cateid'] = $cateid;
  551. $thumb['appid'] = $appid;
  552. $thumb['outlink'] = $outlink;
  553. } else {
  554. $coverArr = array_chunk($cover, $num);
  555. $linkArr = array_chunk($link, $num);
  556. $linktypeArr = array_chunk($linktype, $num);
  557. $webviewArr = array_chunk($webview, $num);
  558. $cateidArr = array_chunk($cateid, $num);
  559. $appidArr = array_chunk($appid, $num);
  560. $outlinkArr = array_chunk($outlink, $num);
  561. $thumb['cover'] = $coverArr[0];
  562. $thumb['link'] = $linkArr[0];
  563. $thumb['linktype'] = $linktypeArr[0];
  564. $thumb['webview'] = $webviewArr[0];
  565. $thumb['cateid'] = $cateidArr[0];
  566. $thumb['appid'] = $appidArr[0];
  567. $thumb['outlink'] = $outlinkArr[0];
  568. }
  569. $params = array();
  570. $params['name'] = $data['name'];
  571. $params['displayorder'] = $data['displayorder'];
  572. $params['enabled'] = $data['enabled'];
  573. $params['name'] = $data['name'];
  574. $params['type'] = $data['type'];
  575. $params['thumb'] = serialize($thumb);
  576. $params['num'] = $data['num'];
  577. $params['linktype'] = 1;
  578. $params['addtime'] = time();
  579. if( !empty($id) && $id > 0 )
  580. {
  581. unset($params['addtime']);
  582. M('lionfish_comshop_cube')->where( array('id' => $id) )->save( $params );
  583. $id = $data['id'];
  584. }else{
  585. $id = M('lionfish_comshop_cube')->add( $params );
  586. }
  587. $url2 =U("configindex/cube");
  588. show_json(1, array('url' => $url2));
  589. }
  590. $this->display();
  591. }
  592. /**
  593. * 切换魔方图显示隐藏 排序
  594. */
  595. public function changeCube()
  596. {
  597. $_GPC = I('request.');
  598. $id = intval($_GPC['id']);
  599. //ids
  600. if (empty($id)) {
  601. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  602. }
  603. if (empty($id)) {
  604. show_json(0, array('message' => '参数错误'));
  605. }
  606. $type = trim($_GPC['type']);
  607. $value = trim($_GPC['value']);
  608. if (!(in_array($type, array('enabled', 'displayorder')))) {
  609. show_json(0, array('message' => '参数错误'));
  610. }
  611. $items = M('lionfish_comshop_cube')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  612. foreach ($items as $item) {
  613. M('lionfish_comshop_cube')->where( array('id' => $item['id']) )->save( array($type => $value) );
  614. }
  615. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  616. }
  617. /**
  618. * 删除魔方图
  619. * @return [json] [description]
  620. */
  621. public function deleteCube()
  622. {
  623. $_GPC = I('request.');
  624. $id = intval($_GPC['id']);
  625. //ids
  626. if (empty($id)) {
  627. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  628. }
  629. if (empty($id)) {
  630. show_json(0, array('message' => '参数错误'));
  631. }
  632. $items = M('lionfish_comshop_cube')->field('id')->where( 'id in( ' . $id . ' ) ' )->select();
  633. foreach ($items as $item) {
  634. M('lionfish_comshop_cube')->where( array('id' => $item['id'] ) )->delete();
  635. }
  636. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  637. }
  638. /**
  639. * 首页视频
  640. * @return [Json] [description]
  641. */
  642. public function video()
  643. {
  644. $_GPC = I('request.');
  645. if ( IS_POST ) {
  646. $data = ((is_array($_GPC['parameter']) ? $_GPC['parameter'] : array()));
  647. $data['index_video_poster'] = save_media($data['index_video_poster']);
  648. $data['index_video_url'] = save_media($data['index_video_url']);
  649. $data['index_video_url'] = D('Seller/Goods')->check_douyin_video($data['index_video_url']);
  650. // var_dump($data['index_video_url']);
  651. // die();
  652. D('Seller/Config')->update($data);
  653. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  654. }
  655. $data = D('Seller/Config')->get_all_config();
  656. $this->data = $data;
  657. $this->display();
  658. }
  659. }
  660. ?>