Theme.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. namespace app\admin\controller\ask;
  3. use app\common\controller\Backend;
  4. use think\Session;
  5. /**
  6. * 移动端主题
  7. *
  8. * @icon fa fa-gears
  9. */
  10. class Theme extends Backend
  11. {
  12. /**
  13. * 查看
  14. */
  15. public function index()
  16. {
  17. if ($this->request->isPost()) {
  18. $preview = $this->request->post('preview');
  19. $navbar = $this->request->post('navbar/a', []);
  20. $theme = $this->request->post('theme/a', []);
  21. $tabbar = $this->request->post('tabbar/a', []);
  22. $tabbar['midButton'] = (bool)$tabbar['midButton'];
  23. $tabbar['borderTop'] = (bool)$tabbar['borderTop'];
  24. if (isset($tabbar['list'])) {
  25. foreach ($tabbar['list'] as $index => &$item) {
  26. $item['midButton'] = isset($item['midButton']) && $item['midButton'] ? true : false;
  27. $item = array_merge($item, [
  28. 'count' => 0,
  29. 'isDot' => false,
  30. 'badgeColor' => $theme['color'], //字体颜色
  31. 'badgeBgColor' => $theme['bgColor'], //背景颜色
  32. ]);
  33. }
  34. $tabbar['list'] = array_values($tabbar['list']);
  35. }
  36. $theme = array_merge($theme, [
  37. 'ladder' => 10,//前景色和背景色的阶梯数
  38. 'number' => 9,//取第几个的阶梯颜色
  39. 'border' => 5,//边框取第几个阶梯数
  40. ]);
  41. $navbar['isshow'] = true;
  42. $tabbar['isshow'] = true;
  43. $config = [
  44. 'navbar' => $navbar,
  45. 'theme' => $theme,
  46. 'tabbar' => $tabbar,
  47. ];
  48. //如果是预览模式则写入session
  49. if ($preview) {
  50. Session::set("previewtheme-ask", $config);
  51. } else {
  52. \addons\ask\library\Theme::set($config);
  53. }
  54. $this->success();
  55. }
  56. $config = \addons\ask\library\Theme::get();
  57. $this->view->assign("themeConfig", $config);
  58. $this->assignconfig("themeConfig", $config);
  59. return $this->view->fetch();
  60. }
  61. public function get_page_list()
  62. {
  63. $pageList = [
  64. ['path' => 'https://www.baidu.com', 'name' => '外部链接'],
  65. ['path' => '/pages/question/index', 'name' => '问答'],
  66. ['path' => '/pages/question/detail?id=1', 'name' => '问答详情(问答ID)'],
  67. ['path' => '/pages/question/post', 'name' => '发布问题'],
  68. ['path' => '/pages/question/answer', 'name' => '完善回答'],
  69. ['path' => '/pages/article/index', 'name' => '文章'],
  70. ['path' => '/pages/article/detail?id=1', 'name' => '文章详情(文章ID)'],
  71. ['path' => '/pages/article/post', 'name' => '发布文章'],
  72. ['path' => '/pages/experts/index', 'name' => '专家'],
  73. ['path' => '/pages/experts/detail?id=1', 'name' => '专家详情(专家ID)'],
  74. ['path' => '/pages/experts/post', 'name' => '申请专家认证'],
  75. ['path' => '/pages/zone/index', 'name' => '专区'],
  76. ['path' => '/pages/my/index', 'name' => '个人中心'],
  77. ['path' => '/pages/my/question', 'name' => '我(他?user_id=1)的问题'],
  78. ['path' => '/pages/my/answer', 'name' => '我(他?user_id=1)的回答'],
  79. ['path' => '/pages/my/article', 'name' => '我(他?user_id=1)的文章'],
  80. ['path' => '/pages/my/follower', 'name' => '我(他?user_id=1)的粉丝'],
  81. ['path' => '/pages/my/attention', 'name' => '我(他?user_id=1)的关注'],
  82. ['path' => '/pages/my/collection', 'name' => '我的收藏'],
  83. ['path' => '/pages/my/notification', 'name' => '我的通知'],
  84. ['path' => '/pages/my/message', 'name' => '我的私信'],
  85. ['path' => '/pages/my/invite', 'name' => '邀请我回答'],
  86. ['path' => '/pages/my/recharge', 'name' => '余额充值'],
  87. ['path' => '/pages/user/index?user_id=1', 'name' => '个人主页(指定用户ID)'],
  88. ['path' => '/pages/zone/index', 'name' => '专区'],
  89. ['path' => '/pages/zone/detail?id=1', 'name' => '专区详情'],
  90. ['path' => '/pages/setting/setting', 'name' => '设置'],
  91. ['path' => '/pages/setting/myinfo', 'name' => '会员中心'],
  92. ['path' => '/pages/setting/editinfo', 'name' => '修改资料'],
  93. ['path' => '/pages/setting/editpwd', 'name' => '修改密码'],
  94. ['path' => '/pages/search/search', 'name' => '搜索'],
  95. ['path' => '/pages/tag/detail?id=1&type=question', 'name' => '话题(指定话题ID和类型)'],
  96. ['path' => '/pages/logs/money', 'name' => '余额日志'],
  97. ['path' => '/pages/logs/score', 'name' => '积分日志'],
  98. ['path' => '/pages/other/about', 'name' => '关于我们'],
  99. ['path' => '/pages/my/agreement', 'name' => '用户协议'],
  100. ['path' => '/pages/signin/signin', 'name' => '签到'],
  101. ['path' => '/pages/signin/ranking', 'name' => '签到排行榜'],
  102. ['path' => '/pages/signin/logs', 'name' => '签到日志'],
  103. ['path' => '/pages/login/login', 'name' => '登录(账号密码)'],
  104. ['path' => '/pages/login/mobilelogin', 'name' => '登录(手机号)'],
  105. ['path' => '/pages/login/register', 'name' => '注册'],
  106. ['path' => '/pages/login/forgetpwd', 'name' => '忘记密码'],
  107. ];
  108. $this->view->assign('pageList', $pageList);
  109. return $this->view->fetch('ask/theme/pages');
  110. }
  111. }