Api.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <?php
  2. namespace Main\Src;
  3. use Dever;
  4. use Main\Lib\Core;
  5. class Api
  6. {
  7. # 基本配置
  8. public function config()
  9. {
  10. $data = Dever::db('main/config')->find();
  11. if (!strstr($data['phone'], '电话')) {
  12. $data['phone'] = '电话:' . $data['phone'];
  13. }
  14. $sell_config = Dever::db('main/sell_config')->find();
  15. $manage_config = Dever::db('main/manage_config')->find();
  16. $factory_config = Dever::db('main/factory_config')->find();
  17. $data['sell_link'] = 'javascript:;';
  18. $data['sell_name'] = $sell_config['name'];
  19. $data['sell_applet'] = $sell_config['applet'];
  20. $data['lingshou_name'] = $sell_config['lingshou_name'];
  21. $data['lingshou_applet'] = $sell_config['lingshou_applet'];
  22. $data['manage_link'] = 'javascript:;';
  23. $data['manage_name'] = $manage_config['name'];
  24. $data['manage_applet'] = $manage_config['applet'];
  25. $data['factory_link'] = 'javascript:;';
  26. $data['factory_name'] = $factory_config['name'];
  27. $data['about_link'] = Dever::load('main/view')->getLink('about', '关于公司');
  28. $data['agreement_link'] = Dever::load('main/view')->getLink('agreement', '用户服务协议');
  29. $data['privacy_link'] = Dever::load('main/view')->getLink('privacy', '隐私政策');
  30. $data['news_link'] = Dever::url('news', 'main');
  31. $data['help_link'] = Dever::url('help', 'main');
  32. $data['home_link'] = Dever::url('home', 'main');
  33. $data['jd_link'] = Dever::url('jd', 'main');
  34. $data['contact_link'] = Dever::url('contact', 'main');
  35. $uri = Dever::uri();
  36. if (strstr($uri, 'home')) {
  37. $data['open_link'] = '#cities';
  38. } else {
  39. $data['open_link'] = Dever::url('home#cities', 'main');
  40. }
  41. $citys = Dever::split($data['citys']);
  42. $data['citys'] = array();
  43. if ($citys) {
  44. foreach ($citys as $k => $v) {
  45. $data['citys'][] = '<li><a href="javascript:;">'.$v.'</a></li>';
  46. }
  47. }
  48. $data['citys'] = implode('', $data['citys']);
  49. $data['worktime'] = str_replace(' ', '<br /><br />', $data['worktime']);
  50. $data['baidu'] = '<script>
  51. var _hmt = _hmt || [];
  52. (function() {
  53. var hm = document.createElement("script");
  54. hm.src = "https://hm.baidu.com/hm.js?4f5a8be51cf141219d4f6eb2c1efef73";
  55. var s = document.getElementsByTagName("script")[0];
  56. s.parentNode.insertBefore(hm, s);
  57. })();
  58. </script>
  59. ';
  60. return $data;
  61. }
  62. public function contact()
  63. {
  64. $data = Dever::db('main/config')->find();
  65. $data['contact'] = Dever::array_decode($data['contact']);
  66. return $data['contact'];
  67. }
  68. # 获取帮助列表
  69. public function help()
  70. {
  71. $type = Dever::input('type', 5);
  72. if (!$type) {
  73. Dever::alert('您访问的页面有误');
  74. }
  75. $where['type'] = $type;
  76. $data = Dever::db('main/help')->select_page($where);
  77. if ($data) {
  78. foreach ($data as $k => $v) {
  79. $data[$k]['link'] = Dever::url('help_view?id=' . $v['id'], 'main');
  80. }
  81. }
  82. return $data;
  83. }
  84. # 获取帮助详情
  85. public function help_view()
  86. {
  87. $id = Dever::input('id');
  88. $data = Dever::db('main/help')->find($id);
  89. return $data;
  90. }
  91. # 获取首页的企业动态
  92. public function getNews()
  93. {
  94. $data = Dever::db('main/news')->getList();
  95. if ($data) {
  96. foreach ($data as $k => $v) {
  97. $data[$k]['link'] = Dever::url('article?id=' . $v['id'], 'main');
  98. }
  99. }
  100. return $data;
  101. }
  102. # 获取动态分类
  103. public function news_cate()
  104. {
  105. $cate = Dever::input('cate', 4);
  106. $data = Dever::db('main/cate')->select();
  107. if ($data) {
  108. foreach ($data as $k => $v) {
  109. $data[$k]['link'] = Dever::url('news?cate=' . $v['id'], 'main');
  110. if ($cate == $v['id']) {
  111. $data[$k]['class'] = 'current';
  112. } else {
  113. $data[$k]['class'] = '';
  114. }
  115. }
  116. }
  117. return $data;
  118. }
  119. # 获取动态列表
  120. public function news()
  121. {
  122. $cate = Dever::input('cate', 4);
  123. if (!$cate) {
  124. Dever::alert('您访问的页面有误');
  125. }
  126. $where['cate_id'] = $cate;
  127. $data = Dever::db('main/news')->getAll($where);
  128. if ($data) {
  129. foreach ($data as $k => $v) {
  130. $data[$k]['link'] = Dever::url('article?id=' . $v['id'], 'main');
  131. $data[$k]['cdate'] = date('Y-m-d H:i', $v['pdate']);
  132. }
  133. }
  134. return $data;
  135. }
  136. # 获取动态详情
  137. public function news_view()
  138. {
  139. $id = Dever::input('id');
  140. $data = Dever::db('main/news')->one($id);
  141. if ($data) {
  142. $data['cdate'] = '发布:' . date('Y-m-d H:i', $data['pdate']);
  143. $cate = Dever::db('main/cate')->one($data['cate_id']);
  144. $data['cate_name'] = '文章类型: ' . $cate['name'];
  145. $source = Dever::db('main/source')->one($data['source_id']);
  146. $data['source_name'] = '文章来源: ' . $source['name'];
  147. $data['content'] = str_replace('width', 'ws', $data['content']);
  148. $data['content'] = str_replace('height', 'hs', $data['content']);
  149. }
  150. return $data;
  151. }
  152. # 获取上一篇文章
  153. public function news_prev()
  154. {
  155. $where['id'] = Dever::input('id');
  156. $data = Dever::db('main/news')->one($where);
  157. $where['cate_id'] = $data['cate_id'];
  158. $data = Dever::db('main/news')->findPrev($where);
  159. if ($data) {
  160. $data['link'] = Dever::url('article?id=' . $data['id'], 'main');
  161. $data['state'] = 'display:block';
  162. } else {
  163. $data['state'] = 'display:none';
  164. $data['link'] = '';
  165. $data['name'] = '';
  166. }
  167. return $data;
  168. }
  169. # 获取上一篇文章
  170. public function news_next()
  171. {
  172. $where['id'] = Dever::input('id');
  173. $data = Dever::db('main/news')->one($where);
  174. $where['cate_id'] = $data['cate_id'];
  175. $data = Dever::db('main/news')->findNext($where);
  176. if ($data) {
  177. $data['link'] = Dever::url('article?id=' . $data['id'], 'main');
  178. $data['state'] = 'display:block';
  179. } else {
  180. $data['state'] = 'display:none';
  181. $data['link'] = '';
  182. $data['name'] = '';
  183. }
  184. return $data;
  185. }
  186. # 招聘信息
  187. public function zhaopin()
  188. {
  189. $data = Dever::db('main/zhaopin')->select_page();
  190. if ($data) {
  191. $type = Dever::db('main/zhaopin')->config['config_type'];
  192. foreach ($data as $k => $v) {
  193. $data[$k]['group'] = Dever::db('main/group')->find($v['group_id']);
  194. $data[$k]['group_name'] = $data[$k]['group']['name'];
  195. $data[$k]['type_name'] = $type[$v['type']];
  196. $data[$k]['cdate'] = date('Y-m-d', $v['cdate']);
  197. }
  198. }
  199. return $data;
  200. }
  201. }