Sellernavigation.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. /**
  3. * 导航栏
  4. * Date: 2017/6/27
  5. * Time: 17:01
  6. */
  7. namespace app\home\controller;
  8. use think\facade\View;
  9. /**
  10. * ============================================================================
  11. * DSMall多用户商城
  12. * ============================================================================
  13. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  14. * 网站地址: http://www.csdeshang.com
  15. * ----------------------------------------------------------------------------
  16. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  17. * 不允许对程序代码以任何形式任何目的的再发布。
  18. * ============================================================================
  19. * 控制器
  20. */
  21. class Sellernavigation extends BaseSeller
  22. {
  23. public function initialize()
  24. {
  25. parent::initialize(); // TODO: Change the autogenerated stub
  26. }
  27. /**
  28. *导航列表
  29. */
  30. public function index()
  31. {
  32. $storenavigation_model = model('storenavigation');
  33. $navigation_list = $storenavigation_model->getStorenavigationList(array('storenav_store_id' => session('store_id')));
  34. View::assign('navigation_list', $navigation_list);
  35. /* 设置卖家当前菜单 */
  36. $this->setSellerCurMenu('seller_navigation');
  37. /* 设置卖家当前栏目 */
  38. $this->setSellerCurItem('store_navigation');
  39. return View::fetch($this->template_dir.'index');
  40. }
  41. public function navigation_add()
  42. {
  43. /* 设置卖家当前菜单 */
  44. $this->setSellerCurMenu('seller_navigation');
  45. /* 设置卖家当前栏目 */
  46. $this->setSellerCurItem('navigation_add');
  47. /* 所见即所得编辑器 */
  48. View::assign('build_editor', build_editor(array(
  49. 'name' => 'storenav_content',
  50. )));
  51. $sn_info = array(
  52. 'storenav_id' => '',
  53. 'storenav_title' => '',
  54. 'storenav_sort' => '',
  55. 'storenav_url' => '',
  56. );
  57. View::assign('sn_info', $sn_info);
  58. return View::fetch($this->template_dir.'navigation_form');
  59. }
  60. public function navigation_edit()
  61. {
  62. $storenav_id = intval(input('param.storenav_id'));
  63. if ($storenav_id <= 0) {
  64. $this->error(lang('param_error'));
  65. }
  66. $storenavigation_model = model('storenavigation');
  67. $sn_info = $storenavigation_model->getStorenavigationInfo(array('storenav_id' => $storenav_id));
  68. if (empty($sn_info) || intval($sn_info['storenav_store_id']) !== intval(session('store_id'))) {
  69. $this->error(lang('param_error'));
  70. }
  71. View::assign('sn_info', $sn_info);
  72. /* 所见即所得编辑器 */
  73. View::assign('build_editor', build_editor(array(
  74. 'name' => 'storenav_content',
  75. 'content' => htmlspecialchars_decode($sn_info['storenav_content']),
  76. )));
  77. $this->setSellerCurMenu('seller_navigation');
  78. /* 设置卖家当前栏目 */
  79. $this->setSellerCurItem('navigation_edit');
  80. return View::fetch($this->template_dir.'navigation_form');
  81. }
  82. public function navigation_save()
  83. {
  84. $sn_info = array(
  85. 'storenav_title' => input('post.storenav_title'),
  86. 'storenav_content' => input('post.storenav_content'),
  87. 'storenav_sort' => empty(input('post.storenav_sort')) ? 255 : input('post.storenav_sort'),
  88. 'storenav_url' => input('post.storenav_url'),
  89. 'storenav_store_id' => session('store_id'),
  90. );
  91. $storenavigation_model = model('storenavigation');
  92. $storenav_id = input('post.storenav_id');
  93. if (!empty($storenav_id) && intval($storenav_id) > 0) {
  94. $condition = array('storenav_id' => $storenav_id);
  95. $result = $storenavigation_model->editStorenavigation($sn_info, $condition);
  96. } else {
  97. $result = $storenavigation_model->addStorenavigation($sn_info);
  98. }
  99. if ($result) {
  100. ds_json_encode(10000,lang('ds_common_op_succ'));
  101. } else {
  102. ds_json_encode(10001,lang('ds_common_op_fail'));
  103. }
  104. }
  105. public function navigation_del()
  106. {
  107. $storenav_id = intval(input('param.storenav_id'));
  108. if ($storenav_id > 0) {
  109. $condition = array(
  110. 'storenav_id' => $storenav_id,
  111. 'storenav_store_id' => session('store_id'),
  112. );
  113. $storenavigation_model = model('storenavigation');
  114. $storenavigation_model->delStorenavigation($condition);
  115. ds_json_encode(10000,lang('ds_common_op_succ'));
  116. } else {
  117. ds_json_encode(10001,lang('ds_common_op_fail'));
  118. }
  119. }
  120. /**
  121. * 用户中心右边,小导航
  122. *
  123. * @param string $menu_key 当前导航的menu_key
  124. * @return
  125. */
  126. function getSellerItemList()
  127. {
  128. $menu_array = array();
  129. $menu_array[] = array(
  130. 'name' => 'store_navigation',
  131. 'text' => lang('store_navigation'),
  132. 'url' => (string)url('Sellernavigation/index')
  133. );
  134. if (request()->action() == 'navigation_add') {
  135. $menu_array[] = array(
  136. 'name' => 'navigation_add',
  137. 'text' => lang('ds_new'),
  138. 'url' => (string)url('Sellernavigation/navigation_add')
  139. );
  140. }
  141. if (request()->action() == 'navigation_edit') {
  142. $menu_array[] = array(
  143. 'name' => 'navigation_edit',
  144. 'text' => lang('ds_edit'),
  145. 'url' => (string)url('Sellernavigation/navigation_edit')
  146. );
  147. }
  148. return $menu_array;
  149. }
  150. }