BottomMenu.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class BottomMenu extends Model
  5. {
  6. protected $connection = 'mysql';
  7. protected $pk = 'id';
  8. protected $name = 'bottom_menu';
  9. public static function datainitial($mo, $tid = 0)
  10. {
  11. $weid = weid();
  12. $datalist = BottomMenu::where(['weid' => $weid, 'tid' => (int)$tid, 'module' => $mo])->select()->toArray();
  13. if (empty($datalist)) {
  14. $query = BottomMenuOriginal::where(['weid' => '0', 'tid' => (int)$tid, 'is_base' => 1, 'module' => $mo]);
  15. if (config('database.app_name') == config('my.app_v2')) {
  16. $query->where('is_v2', 1);
  17. }
  18. if (config('database.app_name') == config('my.app_v3')) {
  19. $query->where('is_v3', 1);
  20. }
  21. if (config('database.app_name') == config('my.app_v6')) {
  22. $query->where('is_v6', 1);
  23. }
  24. $list = $query->order('sort asc')->select()->toArray();
  25. if (!empty($list)) {
  26. foreach ($list as &$vo) {
  27. unset($vo['id']);
  28. $vo['weid'] = $weid;
  29. $vo['tid'] = (int) $tid;
  30. }
  31. $BottomMenu = new BottomMenu;
  32. $BottomMenu->saveAll($list);
  33. }
  34. }
  35. }
  36. static function getBottommenu($userInfo)
  37. {
  38. $mo = input('post.mo', '', 'serach_in');
  39. if (empty($mo)) {
  40. $mo = 'bottom';
  41. }
  42. $pageid = input('post.pageid', '', 'serach_in');
  43. if ($pageid == '-1') {
  44. $Bottommenutype = $userInfo['Bottommenutype'];
  45. } else {
  46. $diywhere['weid'] = weid();
  47. $diywhere['version'] = '2';
  48. if (!empty($pageid)) {
  49. $diywhere['id'] = $pageid;
  50. }
  51. $DiyPage = DiyPage::where($diywhere)->order('is_index desc')->find();
  52. if (!empty($DiyPage)) {
  53. $DiyPage = $DiyPage->toArray();
  54. $data['pagebase'] = iunserializer($DiyPage['pagebase'])[0];
  55. if ($mo == 'bottom') {
  56. $Bottommenutype = $data['pagebase']['base']['Bottommenutype'];
  57. }
  58. }
  59. }
  60. $where['weid'] = weid();
  61. $where['module'] = $mo;
  62. $where['tid'] = (int) $Bottommenutype;
  63. if (\app\model\Uploadminiprogram::getaudit(input('get.v', '', 'serach_in'))) {
  64. $where['is_submitaudit'] = 0;
  65. }
  66. $where['status'] = 1;
  67. $listdata = BottomMenu::where($where)
  68. ->order('sort asc')
  69. ->select()
  70. ->toArray();
  71. $config = Config::getconfig('pagestyle');
  72. if (!empty(trim($config['bottommenucolor']))) {
  73. $data['color'] = trim($config['bottommenucolor']);
  74. } else {
  75. $data['color'] = '#999';
  76. }
  77. if (!empty(trim($config['bottommenuselectedColor']))) {
  78. $data['selectedColor'] = trim($config['bottommenuselectedColor']);
  79. } else {
  80. $data['selectedColor'] = '#EB0909';
  81. }
  82. if (!empty(trim($config['bottommenubackgroundColor']))) {
  83. $data['backgroundColor'] = trim($config['bottommenubackgroundColor']);
  84. } else {
  85. $data['backgroundColor'] = '#fff';
  86. }
  87. $data['borderStyle'] = '#fff';
  88. $data['thisurl'] = input('post.thisurl');
  89. foreach ($listdata as $key => $vo) {
  90. $list[$key]['iconPath'] = toimg($vo['icon']);
  91. $list[$key]['selectedIconPath'] = toimg($vo['iconactive']);
  92. $list[$key]['ptype'] = $vo['url'];
  93. $list[$key]['zdyLinktype'] = $vo['zdyLinktype'];
  94. $list[$key]['zdyappid'] = $vo['zdyappid'];
  95. $list[$key]['hump'] = $vo['hump'];
  96. if ($vo['url'] == 'customurl') {
  97. $list[$key]['pagePath'] = $vo['customurl'];
  98. } else {
  99. if (!empty($vo['url'])) {
  100. $list[$key]['pagePath'] = $vo['url'];
  101. if ($vo['params']) {
  102. $tmppath = explode('?', $vo['url']);
  103. if ($tmppath[1]) {
  104. $list[$key]['pagePath'] = $list[$key]['pagePath'] . '&' . $vo['params'];
  105. } else {
  106. $list[$key]['pagePath'] = $list[$key]['pagePath'] . '?' . $vo['params'];
  107. }
  108. }
  109. }
  110. }
  111. $list[$key]['text'] = $vo['title'];
  112. }
  113. $data['list'] = $list;
  114. $data['lan'] = Author()::getlan();
  115. return $data;
  116. }
  117. }