123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <?php
- namespace Main\Src;
- use Dever;
- use Main\Lib\Core;
- class Api
- {
- # 基本配置
- public function config()
- {
- $data = Dever::db('main/config')->find();
- if (!strstr($data['phone'], '电话')) {
- $data['phone'] = '电话:' . $data['phone'];
- }
- $sell_config = Dever::db('main/sell_config')->find();
- $manage_config = Dever::db('main/manage_config')->find();
- $factory_config = Dever::db('main/factory_config')->find();
- $data['sell_link'] = 'javascript:;';
- $data['sell_name'] = $sell_config['name'];
- $data['sell_applet'] = $sell_config['applet'];
- $data['lingshou_name'] = $sell_config['lingshou_name'];
- $data['lingshou_applet'] = $sell_config['lingshou_applet'];
- $data['manage_link'] = 'javascript:;';
- $data['manage_name'] = $manage_config['name'];
- $data['manage_applet'] = $manage_config['applet'];
- $data['factory_link'] = 'javascript:;';
- $data['factory_name'] = $factory_config['name'];
- $data['about_link'] = Dever::load('main/view')->getLink('about', '关于公司');
- $data['agreement_link'] = Dever::load('main/view')->getLink('agreement', '用户服务协议');
- $data['privacy_link'] = Dever::load('main/view')->getLink('privacy', '隐私政策');
- $data['news_link'] = Dever::url('news', 'main');
- $data['help_link'] = Dever::url('help', 'main');
- $data['home_link'] = Dever::url('home', 'main');
- $data['jd_link'] = Dever::url('jd', 'main');
- $data['contact_link'] = Dever::url('contact', 'main');
- $uri = Dever::uri();
- if (strstr($uri, 'home')) {
- $data['open_link'] = '#cities';
- } else {
- $data['open_link'] = Dever::url('home#cities', 'main');
- }
- $citys = Dever::split($data['citys']);
- $data['citys'] = array();
- if ($citys) {
- foreach ($citys as $k => $v) {
- $data['citys'][] = '<li><a href="javascript:;">'.$v.'</a></li>';
- }
- }
- $data['citys'] = implode('', $data['citys']);
- $data['worktime'] = str_replace(' ', '<br /><br />', $data['worktime']);
- $data['baidu'] = '<script>
- var _hmt = _hmt || [];
- (function() {
- var hm = document.createElement("script");
- hm.src = "https://hm.baidu.com/hm.js?4f5a8be51cf141219d4f6eb2c1efef73";
- var s = document.getElementsByTagName("script")[0];
- s.parentNode.insertBefore(hm, s);
- })();
- </script>
- ';
- return $data;
- }
- public function contact()
- {
- $data = Dever::db('main/config')->find();
- $data['contact'] = Dever::array_decode($data['contact']);
- return $data['contact'];
- }
- # 获取帮助列表
- public function help()
- {
- $type = Dever::input('type', 5);
- if (!$type) {
- Dever::alert('您访问的页面有误');
- }
- $where['type'] = $type;
- $data = Dever::db('main/help')->select_page($where);
- if ($data) {
- foreach ($data as $k => $v) {
- $data[$k]['link'] = Dever::url('help_view?id=' . $v['id'], 'main');
- }
- }
- return $data;
- }
- # 获取帮助详情
- public function help_view()
- {
- $id = Dever::input('id');
- $data = Dever::db('main/help')->find($id);
- return $data;
- }
- # 获取首页的企业动态
- public function getNews()
- {
- $data = Dever::db('main/news')->getList();
- if ($data) {
- foreach ($data as $k => $v) {
- $data[$k]['link'] = Dever::url('article?id=' . $v['id'], 'main');
- }
- }
- return $data;
- }
- # 获取动态分类
- public function news_cate()
- {
- $cate = Dever::input('cate', 4);
- $data = Dever::db('main/cate')->select();
- if ($data) {
- foreach ($data as $k => $v) {
- $data[$k]['link'] = Dever::url('news?cate=' . $v['id'], 'main');
- if ($cate == $v['id']) {
- $data[$k]['class'] = 'current';
- } else {
- $data[$k]['class'] = '';
- }
- }
- }
- return $data;
- }
- # 获取动态列表
- public function news()
- {
- $cate = Dever::input('cate', 4);
- if (!$cate) {
- Dever::alert('您访问的页面有误');
- }
- $where['cate_id'] = $cate;
- $data = Dever::db('main/news')->getAll($where);
- if ($data) {
- foreach ($data as $k => $v) {
- $data[$k]['link'] = Dever::url('article?id=' . $v['id'], 'main');
- $data[$k]['cdate'] = date('Y-m-d H:i', $v['pdate']);
- }
- }
- return $data;
- }
- # 获取动态详情
- public function news_view()
- {
- $id = Dever::input('id');
- $data = Dever::db('main/news')->one($id);
- if ($data) {
- $data['cdate'] = '发布:' . date('Y-m-d H:i', $data['pdate']);
- $cate = Dever::db('main/cate')->one($data['cate_id']);
- $data['cate_name'] = '文章类型: ' . $cate['name'];
- $source = Dever::db('main/source')->one($data['source_id']);
- $data['source_name'] = '文章来源: ' . $source['name'];
- $data['content'] = str_replace('width', 'ws', $data['content']);
- $data['content'] = str_replace('height', 'hs', $data['content']);
- }
- return $data;
- }
- # 获取上一篇文章
- public function news_prev()
- {
- $where['id'] = Dever::input('id');
- $data = Dever::db('main/news')->one($where);
- $where['cate_id'] = $data['cate_id'];
- $data = Dever::db('main/news')->findPrev($where);
- if ($data) {
- $data['link'] = Dever::url('article?id=' . $data['id'], 'main');
- $data['state'] = 'display:block';
- } else {
- $data['state'] = 'display:none';
- $data['link'] = '';
- $data['name'] = '';
- }
- return $data;
- }
- # 获取上一篇文章
- public function news_next()
- {
- $where['id'] = Dever::input('id');
- $data = Dever::db('main/news')->one($where);
- $where['cate_id'] = $data['cate_id'];
- $data = Dever::db('main/news')->findNext($where);
- if ($data) {
- $data['link'] = Dever::url('article?id=' . $data['id'], 'main');
- $data['state'] = 'display:block';
- } else {
- $data['state'] = 'display:none';
- $data['link'] = '';
- $data['name'] = '';
- }
- return $data;
- }
- # 招聘信息
- public function zhaopin()
- {
- $data = Dever::db('main/zhaopin')->select_page();
- if ($data) {
- $type = Dever::db('main/zhaopin')->config['config_type'];
- foreach ($data as $k => $v) {
- $data[$k]['group'] = Dever::db('main/group')->find($v['group_id']);
- $data[$k]['group_name'] = $data[$k]['group']['name'];
- $data[$k]['type_name'] = $type[$v['type']];
- $data[$k]['cdate'] = date('Y-m-d', $v['cdate']);
- }
- }
- return $data;
- }
- }
|