1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace app\client\controller;
- use think\facade\Request;
- use app\event\FootPrints;
- use app\model\AgentArticle;
- use xiaohongwu\Vr;
- class Agent extends Base
- {
- /**
- * 获取详情
- */
- public function info($article_id)
- {
- $token = request()->token;
- $article = AgentArticle::field('id,title,content,file,type')->where(['root_id'=>$token['root_org'],'id' => $article_id, 'disable' => 0])->find();
- if (empty($article)) {
- $article = [
- 'title' => '该文章不存在',
- 'content' => '您访问的内容不存在',
- 'file' => '',
- 'type' => ''
- ];
- return json(['code' => 0, 'msg' => '获取成功', 'data' => $article]);
- }
- // 添加足迹
- if (!empty($token['uid']) && !$token['isEmployee']) {
- event(new FootPrints($token['uid'], $token['share_employee'] ?? 0, $token['share_org'] ?? 0, $article, 'agentArticle'));
- }
- $vrObj = new Vr();
- $article['file_img'] = $article['files'] = '';
- if($article['type']==3){
- $article['files'] = !empty($article['file'][0]) ? str_replace('https://'.config('app.ali_oss_bindurl').'/','',$article['file'][0]) :'';
- $article['file_img'] = !empty($article['file'][0]) ? $vrObj->getFirstImg(str_replace('https://'.config('app.ali_oss_bindurl').'/','',$article['file'][0])) : '';
- }
- return json(['code' => 0, 'msg' => '获取成功', 'data' => $article]);
- }
- }
|