Pārlūkot izejas kodu

6985 weixin share

zz 5 gadi atpakaļ
vecāks
revīzija
1c4a1e0210

+ 20 - 0
app/Http/Controllers/Wap/Book/ChapterController.php

@@ -83,6 +83,8 @@ class ChapterController extends BaseController
 
     private $is_first_book_order = 0;
 
+    private $domain;
+
     /**
      * @apiVersion 1.0.0
      * @apiDescription 章节列表不分页
@@ -317,6 +319,7 @@ class ChapterController extends BaseController
      */
     public function index(Request $request, $t, $domain, $bid, $cid)
     {
+        $this->domain = $domain;
         $special_user_log = env('SPECIAL_USER_LOG');
         //注意:内部约定用  有此参数不需要强关
         $inter_not_need_sub = $request->has('inter_not_need_sub') ? true : false;
@@ -875,6 +878,8 @@ class ChapterController extends BaseController
         $this->chapter->push_title = [];
         //分享
         $this->chapter->is_show_share_button = 0;
+        //6985的分享配置
+        $this->chapter->share_config = '';
         //阅读底部强关图片 只有123有
         $this->chapter->is_had_subscribe = 0;
         //广告
@@ -1048,6 +1053,21 @@ class ChapterController extends BaseController
         if ($this->is_had_subscribe && in_array($this->distribution_channel_id, [2, 14, 211,4025,4147,691,123]) && $this->user) {//,4147,691,123,4025
             $this->chapter->is_show_share_button = 1;
         }
+        if($this->distribution_channel_id == 6985 && $this->domain == 'leyuee'){
+            $appid = 'wx126331d1732978b0';
+            $appSecret = '76231c41c24d4363243866f5f9dee55f';
+            $config = new ChapterShareWechatConfigService($appid,$appSecret);
+            //$config->setAccessToken('');
+            $config->requestAccessToken();
+            $config->requestJsApiTicket();
+            $url = sprintf(
+                'https://site%s.leyuee.com/reader?bid=%s&cid=%s',
+                $this->en_distribution_channel_id,
+                $this->en_bid,
+                $this->cid
+            );
+            $this->chapter->share_config = $config->getJssdkConfig($url);
+        }
     }
 
     /**

+ 1 - 0
app/Http/Controllers/Wap/Book/Transformers/ChapterTransformer.php

@@ -36,6 +36,7 @@ class ChapterTransformer
             'is_visiable_ad'=>isset($chapter->is_visiable_ad)?$chapter->is_visiable_ad:0,
             'sign_version'=>isset($chapter->sign_version)?$chapter->sign_version:'',
             'sign_items'=>isset($chapter->sign_items)?$chapter->sign_items:'',
+            'share_config'=>$chapter->share_config
             //'is_had_subscribe'=>0
             //'is_need_subscirbe'   =>  $chapter->is_need_subscirbe,
         ];