Sellernavigation.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. *
  12. * ============================================================================
  13. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  14. * 网站地址: https://www.valimart.net/
  15. * ----------------------------------------------------------------------------
  16. *
  17. * ============================================================================
  18. * 控制器
  19. */
  20. class Sellernavigation extends BaseSeller
  21. {
  22. public function initialize()
  23. {
  24. parent::initialize(); // TODO: Change the autogenerated stub
  25. }
  26. /**
  27. *导航列表
  28. */
  29. public function index()
  30. {
  31. $storenavigation_model = model('storenavigation');
  32. $navigation_list = $storenavigation_model->getStorenavigationList(array('storenav_store_id' => session('store_id')));
  33. View::assign('navigation_list', $navigation_list);
  34. /* 设置卖家当前菜单 */
  35. $this->setSellerCurMenu('seller_navigation');
  36. /* 设置卖家当前栏目 */
  37. $this->setSellerCurItem('store_navigation');
  38. return View::fetch($this->template_dir.'index');
  39. }
  40. public function navigation_add()
  41. {
  42. /* 设置卖家当前菜单 */
  43. $this->setSellerCurMenu('seller_navigation');
  44. /* 设置卖家当前栏目 */
  45. $this->setSellerCurItem('navigation_add');
  46. /* 所见即所得编辑器 */
  47. View::assign('build_editor', build_editor(array(
  48. 'name' => 'storenav_content',
  49. )));
  50. $sn_info = array(
  51. 'storenav_id' => '',
  52. 'storenav_title' => '',
  53. 'storenav_sort' => '',
  54. 'storenav_url' => '',
  55. );
  56. View::assign('sn_info', $sn_info);
  57. return View::fetch($this->template_dir.'navigation_form');
  58. }
  59. public function navigation_edit()
  60. {
  61. $storenav_id = intval(input('param.storenav_id'));
  62. if ($storenav_id <= 0) {
  63. $this->error(lang('param_error'));
  64. }
  65. $storenavigation_model = model('storenavigation');
  66. $sn_info = $storenavigation_model->getStorenavigationInfo(array('storenav_id' => $storenav_id));
  67. if (empty($sn_info) || intval($sn_info['storenav_store_id']) !== intval(session('store_id'))) {
  68. $this->error(lang('param_error'));
  69. }
  70. View::assign('sn_info', $sn_info);
  71. /* 所见即所得编辑器 */
  72. View::assign('build_editor', build_editor(array(
  73. 'name' => 'storenav_content',
  74. 'content' => htmlspecialchars_decode($sn_info['storenav_content']),
  75. )));
  76. $this->setSellerCurMenu('seller_navigation');
  77. /* 设置卖家当前栏目 */
  78. $this->setSellerCurItem('navigation_edit');
  79. return View::fetch($this->template_dir.'navigation_form');
  80. }
  81. public function navigation_save()
  82. {
  83. $sn_info = array(
  84. 'storenav_title' => input('post.storenav_title'),
  85. 'storenav_content' => input('post.storenav_content'),
  86. 'storenav_sort' => empty(input('post.storenav_sort')) ? 255 : input('post.storenav_sort'),
  87. 'storenav_url' => input('post.storenav_url'),
  88. 'storenav_store_id' => session('store_id'),
  89. );
  90. $storenavigation_model = model('storenavigation');
  91. $storenav_id = input('post.storenav_id');
  92. if (!empty($storenav_id) && intval($storenav_id) > 0) {
  93. $condition = array('storenav_id' => $storenav_id);
  94. $result = $storenavigation_model->editStorenavigation($sn_info, $condition);
  95. } else {
  96. $result = $storenavigation_model->addStorenavigation($sn_info);
  97. }
  98. if ($result) {
  99. ds_json_encode(10000,lang('ds_common_op_succ'));
  100. } else {
  101. ds_json_encode(10001,lang('ds_common_op_fail'));
  102. }
  103. }
  104. public function navigation_del()
  105. {
  106. $storenav_id = intval(input('param.storenav_id'));
  107. if ($storenav_id > 0) {
  108. $condition = array(
  109. 'storenav_id' => $storenav_id,
  110. 'storenav_store_id' => session('store_id'),
  111. );
  112. $storenavigation_model = model('storenavigation');
  113. $storenavigation_model->delStorenavigation($condition);
  114. ds_json_encode(10000,lang('ds_common_op_succ'));
  115. } else {
  116. ds_json_encode(10001,lang('ds_common_op_fail'));
  117. }
  118. }
  119. /**
  120. * 用户中心右边,小导航
  121. *
  122. * @param string $menu_key 当前导航的menu_key
  123. * @return
  124. */
  125. function getSellerItemList()
  126. {
  127. $menu_array = array();
  128. $menu_array[] = array(
  129. 'name' => 'store_navigation',
  130. 'text' => lang('store_navigation'),
  131. 'url' => (string)url('Sellernavigation/index')
  132. );
  133. if (request()->action() == 'navigation_add') {
  134. $menu_array[] = array(
  135. 'name' => 'navigation_add',
  136. 'text' => lang('ds_new'),
  137. 'url' => (string)url('Sellernavigation/navigation_add')
  138. );
  139. }
  140. if (request()->action() == 'navigation_edit') {
  141. $menu_array[] = array(
  142. 'name' => 'navigation_edit',
  143. 'text' => lang('ds_edit'),
  144. 'url' => (string)url('Sellernavigation/navigation_edit')
  145. );
  146. }
  147. return $menu_array;
  148. }
  149. }