Ei kuvausta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NavigationLogic.php 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. /**
  3. * 易购CMS
  4. * ============================================================================
  5. * 版权所有 2016-2028 海南易而优科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.ebuycms.com
  7. * ----------------------------------------------------------------------------
  8. * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
  9. * ============================================================================
  10. * Author: 易而优团队 by 陈风任 <491085389@qq.com>
  11. * Date: 2019-11-28
  12. */
  13. namespace app\admin\logic;
  14. use think\Model;
  15. use think\Db;
  16. /**
  17. * 栏目逻辑定义
  18. * @package common\Logic
  19. */
  20. class NavigationLogic extends Model
  21. {
  22. /**
  23. * 全部栏目
  24. */
  25. public function GetAllArctype($type_id = 0)
  26. {
  27. $where = [
  28. 'weapp_code' => '',
  29. 'is_del' => 0,
  30. 'status' => 1,
  31. 'lang' => get_current_lang(),
  32. ];
  33. $field = 'id, parent_id, typename, dirname, litpic';
  34. // 查询所有可投稿的栏目
  35. $ArcTypeData = Db::name('arctype')->field($field)->where($where)->select();
  36. $ids = array_column($ArcTypeData, 'id');
  37. $id_arr = [];
  38. $parent_ids = array_column($ArcTypeData, 'parent_id');
  39. foreach ($parent_ids as $k => $v){
  40. if (0 == $v){
  41. $id_arr[] = $ids[$k];
  42. }
  43. }
  44. $ParentIds = array_unique($parent_ids);
  45. if (!empty($id_arr)){
  46. foreach ($id_arr as $k){
  47. if (!in_array($k,$parent_ids)){
  48. $ParentIds[] = $k;
  49. }
  50. }
  51. }
  52. // 读取上级ID并去重读取上级栏目 $ParentIds
  53. $PidData = Db::name('arctype')->field($field)->where('id', 'IN', $ParentIds)->select();
  54. static $seo_pseudo = null;
  55. if (null === $seo_pseudo) {
  56. $seoConfig = tpCache('seo');
  57. $seo_pseudo = !empty($seoConfig['seo_pseudo']) ? $seoConfig['seo_pseudo'] : config('ey_config.seo_pseudo');
  58. }
  59. // 下拉框拼装
  60. $HtmlCode = '<select name="type_id" id="type_id" onchange="SyncData(this);">';
  61. $HtmlCode .= '<option id="arctype_default" value="0">请选择栏目</option>';
  62. foreach ($PidData as $yik => $yiv) {
  63. /*栏目路径*/
  64. if (2 == $seo_pseudo) {
  65. // 生成静态
  66. $typeurl = ROOT_DIR . "/index.php?m=home&c=Lists&a=index&tid={$yiv['id']}";
  67. } else {
  68. // 动态或伪静态
  69. $typeurl = typeurl("home/Lists/index", $yiv, true, false, $seo_pseudo, null);
  70. $typeurl = auto_hide_index($typeurl);
  71. }
  72. /* END */
  73. /*是否选中*/
  74. $style1 = $type_id == $yiv['id'] ? 'selected' : '';
  75. /* END */
  76. if (0 == $yiv['parent_id']) {
  77. /*一级下拉框*/
  78. $HtmlCode .= '<option value="'.$yiv['id'].'" data-typeurl="'.$typeurl.'" data-typename="'.$yiv['typename'].'" '.$style1.'>'.$yiv['typename'].'</option>';
  79. /* END */
  80. $type = 0;
  81. } else {
  82. /*二级下拉框*/
  83. $HtmlCode .= '<option value="'.$yiv['id'].'" data-typeurl="'.$typeurl.'" data-typename="'.$yiv['typename'].'" '.$style1.'>&nbsp; &nbsp;'.$yiv['typename'].'</option>';
  84. /* END */
  85. $type = 1;
  86. }
  87. foreach ($ArcTypeData as $erk => $erv) {
  88. /*栏目路径*/
  89. if (2 == $seo_pseudo) {
  90. // 生成静态
  91. $typeurl = ROOT_DIR . "/index.php?m=home&c=Lists&a=index&tid={$erv['id']}";
  92. } else {
  93. // 动态或伪静态
  94. $typeurl = typeurl("home/Lists/index", $erv, true, false, $seo_pseudo, null);
  95. $typeurl = auto_hide_index($typeurl);
  96. }
  97. /* END */
  98. if ($erv['parent_id'] == $yiv['id']) {
  99. if (0 == $type) {
  100. /*是否选中*/
  101. $style1 = $type_id == $erv['id'] ? 'selected' : '';
  102. /* END */
  103. /*二级下拉框*/
  104. $HtmlCode .= '<option value="'.$erv['id'].'" data-typeurl="'.$typeurl.'" data-typename="'.$erv['typename'].'" '.$style1.'>&nbsp; &nbsp;'.$erv['typename'].'</option>';
  105. /* END */
  106. } else {
  107. /*三级下拉框*/
  108. $HtmlCode .= '<option value="'.$erv['id'].'" data-typeurl="'.$typeurl.'" data-typename="'.$erv['typename'].'">&nbsp; &nbsp; &nbsp; &nbsp;'.$erv['typename'].'</option>';
  109. /* END */
  110. }
  111. }
  112. }
  113. }
  114. $HtmlCode .= '</select>';
  115. return $HtmlCode;
  116. }
  117. // 前台功能列表
  118. public function ForegroundFunction()
  119. {
  120. return $ReturnData = [
  121. 0 => [
  122. 'title' => '首页',
  123. 'url' => "web_cmsurl"
  124. ],
  125. 1 => [
  126. 'title' => '个人中心',
  127. 'url' => "index"
  128. ],
  129. 2 => [
  130. 'title' => '我的信息',
  131. 'url' => "user_info"
  132. ],
  133. 3 => [
  134. 'title' => '我的收藏',
  135. 'url' => "my_collect"
  136. ],
  137. 4 => [
  138. 'title' => '财务明细',
  139. 'url' => "consumer_details"
  140. ],
  141. 5 => [
  142. 'title' => '购物车',
  143. 'url' => 'shop_cart_list'
  144. ],
  145. 6 => [
  146. 'title' => '收货地址',
  147. 'url' => "shop_address_list"
  148. ],
  149. 7 => [
  150. 'title' => '我的订单',
  151. 'url' => "shop_centre"
  152. ],
  153. 8 => [
  154. 'title' => '我的评价',
  155. 'url' => "my_comment"
  156. ],
  157. 9 => [
  158. 'title' => '投稿列表',
  159. 'url' => "release_centre"
  160. ],
  161. 10 => [
  162. 'title' => '我要投稿',
  163. 'url' => "article_add"
  164. ],
  165. ];
  166. }
  167. }