dever 4 år sedan
förälder
incheckning
237eaa762e
5 ändrade filer med 68 tillägg och 16 borttagningar
  1. 6 4
      app/collection/lib/Core.php
  2. 27 11
      app/collection/src/Api.php
  3. 10 0
      app/user/database/ticket.php
  4. 13 0
      app/user/lib/Ticket.php
  5. 12 1
      app/user/src/Api.php

+ 6 - 4
app/collection/lib/Core.php

@@ -53,7 +53,7 @@ class Core
     # 检查内容
     protected function checkInfo()
     {
-        $this->info = $this->get($this->id);
+        $this->info = $this->getOne($this->id);
         if (!$this->info) {
             Dever::alert('内容还没有准备好');
         }
@@ -61,7 +61,7 @@ class Core
     }
 
     # 获取内容
-    protected function get($id)
+    protected function getOne($id)
     {
         $info = Dever::load('collection/lib/info')->num($id);
         if ($info) {
@@ -147,7 +147,9 @@ class Core
     {
         if (Dever::project('invite')) {
             $invite = Dever::input('invite');
-            $uid = Dever::load('invite/api')->getUid($invite);
+            if ($invite) {
+                $uid = Dever::load('invite/api')->getUid($invite);
+            }
         }
         if (!$day) {
             $day = $this->day;
@@ -201,7 +203,7 @@ class Core
         }
 
         # 获取code
-        $code = $this->getCode($this->id, $parent_page_id, $page_id, $index, $times, $day);
+        $code = $this->getCode($this->id, $parent_page_id, $page_id, $index, $times, $day, $this->uid);
 
         return $code;
     }

+ 27 - 11
app/collection/src/Api.php

@@ -49,7 +49,7 @@ class Api extends Core
         $collection = Dever::load('user/lib/collection')->getList($this->uid);
         if ($collection) {
             foreach ($collection as $k => $v) {
-                $data['info'][] = $this->get($v['info_id']);
+                $data['info'][] = $this->getOne($v['info_id']);
             }
         }
 
@@ -62,7 +62,7 @@ class Api extends Core
         return $url;
     }
 
-    # 获取分享的内容
+    # 获取合集里分享的内容
     public function getShare()
     {
         $url = Dever::input('url');
@@ -195,9 +195,32 @@ class Api extends Core
         # 获取按钮样式
         $data['button'] = $this->button($data['info']);
 
-        # 获取code
+        # 获取阅读code
         $data['code'] = $this->getInfoCode();
 
+        # 获取合集分享信息
+        $data['share'] = $this->getInfoShare($data['info']);
+
+        return $data;
+    }
+
+    private function getInfoShare($info)
+    {
+        $data['title'] = $info['share_title'] ? $info['share_title'] : '{username}邀请你看{name}';
+
+        $data['title'] = str_replace('{username}', $this->user['username'], $data['title']);
+        $data['title'] = str_replace('{name}', $info['name'], $data['title']);
+
+        $data['content'] = $info['share_content'] ? $info['share_content'] : $info['desc'];
+
+        $data['pic'] = $info['share_pic'] ? $info['share_pic'] : $info['pic_cover'];
+
+        $url = Dever::input('url');
+
+        $url = $this->getUrl($url);
+
+        $data['link'] = $url;
+
         return $data;
     }
 
@@ -244,14 +267,7 @@ class Api extends Core
 
         $data['ticket'] = Dever::load('user/lib/ticket')->check($this->uid, $data['info']['id']);
 
-        $data['info']['share_title'] = $data['info']['share_title'] ? $data['info']['share_title'] : '{username}邀请你看{name}';
-
-        $data['info']['share_title'] = str_replace('{username}', $this->user['username'], $data['info']['share_title']);
-        $data['info']['share_title'] = str_replace('{name}', $data['info']['name'], $data['info']['share_title']);
-
-        $data['info']['share_content'] = $data['info']['share_content'] ? $data['info']['share_content'] : $data['info']['desc'];
-
-        $data['info']['share_pic'] = $data['info']['share_pic'] ? $data['info']['share_pic'] : $data['info']['pic_cover'];
+        $data['share'] = $this->getInfoShare($data['info']);
 
         return $data;
     }

+ 10 - 0
app/user/database/ticket.php

@@ -71,6 +71,16 @@ return array
             'update'    => 'text',
         ),
 
+        'desc'      => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '一句话介绍',
+            'default'   => '',
+            'desc'      => '一句话介绍',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',

+ 13 - 0
app/user/lib/Ticket.php

@@ -25,6 +25,19 @@ class Ticket
         }
     }
 
+    # 保存说明信息
+    public function save($uid, $id, $desc)
+    {
+        $where['uid'] = $uid;
+        $where['id'] = $id;
+        $info = Dever::db('user/ticket')->one($where);
+        if ($info) {
+            $update['where_id'] = $id;
+            $update['desc'] = $desc;
+            Dever::db('user/ticket')->update($update);
+        }
+    }
+
     # 验证是否购买
     public function check($uid, $info_id)
     {

+ 12 - 1
app/user/src/Api.php

@@ -126,6 +126,17 @@ class Api extends Core
             Dever::db('user/record')->insert($where);
         }
 
-        return 'yes';
+        return 'ok';
+    }
+
+    # 保存门票说明信息
+    public function ticketSave()
+    {
+        $ticket_id = Dever::input('ticket_id');
+        $desc = Dever::input('desc');
+
+        $data = Dever::load('user/lib/ticket')->save($this->uid, $ticket_id, $desc);
+
+        return 'ok';
     }
 }