_link(); $this->_seoSearch(); //微信分享 $config = [ 'app_id' => env('WX_APPID'), 'secret' => env('WX_APPSECRET'), // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 'response_type' => 'array', ]; try { if (is_weixin()) { $app = Factory::officialAccount($config); $signPackage = $app->jssdk->buildConfig([ 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareQZone', ]); } }catch (\Exception $e) { // show_bug($e->getMessage()); Log::write($e->getMessage()); } // $this->share_img=HTTP_PROTOCOL.'://'.SITE_URL.'/'.asset('img/share_img.jpg'); $this->assign('signPackage', $signPackage); } private function _link() { $links = D('Links')->where(['status'=>DBCont::NORMAL_STATUS])->order('sort asc,id desc')->select(); if (!empty($links)) { $this->links = $links; } } private function _seoSearch() { if(CONTROLLER_NAME==='News'&&ACTION_NAME==='detail') { $id = I('get.id'); $news = D('News')->where(['id' => $id])->find(); if (!empty($news)) { foreach (explode(',',$news['keywords_id']) as &$item){ $words= D('Keywords')->where(['id'=>$item])->getField('name'); if(!empty($words)) $keywords_arr[]=$words; } $this->keywords_seo=!empty($keywords_arr) ? implode(',', $keywords_arr) : ''; $this->description=cutLength($news['content_res'],'50'); } } } }