dever 4 роки тому
батько
коміт
5e759e6014

+ 19 - 0
app/collection/database/function.php

@@ -20,6 +20,12 @@ $status = array
     2 => '关闭',
 );
 
+$times_set = array
+(
+    1 => '否',
+    2 => '是',
+);
+
 $direction = array
 (
 	'left' => '左侧展开',
@@ -96,6 +102,19 @@ return array
             'update'    => 'radio',
             'option'    => $type,
             'list'      => true,
+            'control'   => 'type',
+        ),
+
+        'times_set'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '时光对应-如果选择是,则切换时光时,将自动进入当前正在浏览的相同的页号,要求所有时光下的内容页数必须相同,否则进入第一页。',
+            'default'   => '1',
+            'desc'      => '时光对应',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $times_set,
+            'show'      => 'type=times',
         ),
 
         'color'      => array

+ 24 - 13
app/collection/lib/Core.php

@@ -19,7 +19,6 @@ class Core
     protected $parent_page_id;
     protected $page_id;
     protected $info;
-    protected $key = '';
     /*
     # 定义全局的系统类型
     'system_source' => array
@@ -45,12 +44,6 @@ class Core
         $this->system_source = Dever::input('system_source', 1);
     }
 
-    protected function key()
-    {
-        $this->key = Dever::config('base', 'project')->encode_key;
-        return $this->key;
-    }
-
     # 获取用户信息
     protected function getUser($uid, $collection_id)
     {
@@ -97,7 +90,7 @@ class Core
         unset($info['cdate']);
         unset($info['score_type']);
         unset($info['score_name']);
-        $this->id_code = $info['id_code'] = Dever::encode($info['id'], $this->key());
+        $this->id_code = $info['id_code'] = Dever::load('collection/lib/common')->encode($info['id']);
     }
 
     # 检查是否可以查看
@@ -124,7 +117,7 @@ class Core
     {
         $this->code = Dever::input('code');
         if ($this->code) {
-            $code = Dever::decode($this->code, $this->key());
+            $code = Dever::load('collection/lib/common')->decode($this->code);
             $code = explode('_', $code);
             $this->id = $code[1];
             $this->parent_page_id = $code[2];
@@ -150,7 +143,7 @@ class Core
             if ($this->id_code == -1) {
                 $this->id = $this->id_code;
             } else {
-                $this->id = Dever::decode($this->id_code, $this->key());
+                $this->id = Dever::load('collection/lib/common')->decode($this->id_code);
             }
         }
         if ($this->share_uid == $this->uid) {
@@ -159,7 +152,7 @@ class Core
     }
 
     # 获取邀请码
-    protected function getCode($id, $parent_page_id, $page_id, $index, $times_id, $day = 0, $uid = 0, $ticket_id = 0)
+    protected function getCode($id, $parent_page_id, $page_id, $index, $times_id, $day = 0, $uid = 0, $ticket_id = 0, $encode = true)
     {
         if (Dever::project('invite')) {
             $invite = Dever::input('invite');
@@ -179,12 +172,30 @@ class Core
             $day = 0;
         }
 
-        $key = 'dlv1_' . $id. '_' . $parent_page_id . '_' . $page_id . '_' . $index . '_' . $times_id . '_' . $day . '_' . $uid . '_' . $ticket_id;
-        $code = Dever::encode($key, $this->key());
+        $code = 'dlv1_' . $id. '_' . $parent_page_id . '_' . $page_id . '_' . $index . '_' . $times_id . '_' . $day . '_' . $uid . '_' . $ticket_id;
+        
+        if ($encode) {
+            $code = Dever::load('collection/lib/common')->encode($code);
+        }
 
         return $code;
     }
 
+    #获取短域名
+    public function getUrl($url, $param)
+    {
+        if (Dever::project('short')) {
+            # 转成短域名
+            if (isset($param['code']) && $param['code']) {
+                $param['code'] .= '|collection/lib/common.encode';
+            }
+            $url = Dever::load('short/lib/handle')->get(1, $url, $param);
+        } else {
+            $url .= http_build_query($param);
+        }
+        return $url;
+    }
+
     protected function getInfoCode()
     {
         # 获取最新的用户记录

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

@@ -57,12 +57,6 @@ class Api extends Core
         return $data;
     }
 
-    public function getUrl($url)
-    {
-        # 转成短域名
-        return $url;
-    }
-
     # 获取合集里分享的内容
     public function getShare()
     {
@@ -77,11 +71,13 @@ class Api extends Core
         $data['info']['platform_name'] = $info['name'];
         $data['info']['qrcode'] = $data['info']['name'] = $data['info']['price'] = $data['info']['s_price'] = '';
 
-        $code = $this->getCode($this->id, $this->parent_page_id, $this->page_id, $index, $this->times, $this->day, $this->uid);
+        $code = $this->getCode($this->id, $this->parent_page_id, $this->page_id, $index, $this->times, $this->day, $this->uid, false, false);
 
-        $url .= '?code=' . $code . '&name=' . $info['name'];
+        //$url .= '?code=' . $code . '&name=' . $info['name'];
+        $param['code'] = $code;
+        $param['name'] = $info['name'];
 
-        $url = $this->getUrl($url);
+        $url = $this->getUrl($url, $param);
 
         $data['info']['url'] = $url;
 
@@ -451,13 +447,28 @@ class Api extends Core
     # 根据时光id获取pageid
     public function getPageId()
     {
+        $set = Dever::input('set', 1);
+        $index = 0;
+        if ($set == 2) {
+            $index = $this->index;
+        }
+
         $where['info_id'] = $this->id;
         $where['times_id'] = Dever::input('times_id');
         $page = Dever::db('collection/page')->getOne($where);
         if ($page) {
             # 获取code
-            $this->day = $day = Dever::input('day', 0);
-            $data['code'] = $this->getCode($this->id, $page['page_id'], $page['id'], 0, $page['times_id'], $day);
+            $day = Dever::input('day', 0);
+            if ($this->times == $where['times_id']) {
+                $index = $this->index;
+                if ($day == $this->day) {
+                    $data['code'] = '';
+                    return $data;
+                }
+            }
+
+            $this->day = $day;
+            $data['code'] = $this->getCode($this->id, $page['page_id'], $page['id'], $index, $page['times_id'], $day);
 
             # 记录选择的时光id和日期
             Dever::load('user/lib/times')->up($this->id, $this->uid, $page['times_id'], $day);
@@ -499,6 +510,10 @@ class Api extends Core
                         'color' => $v['color'],
                     ),
                 );
+
+                if ($v['type'] == 'times') {
+                    $result[$v['type']]['set'] = $v['times_set'];
+                }
             }
         }
 

+ 8 - 6
app/community/lib/Moment.php

@@ -81,16 +81,15 @@ class Moment
         $where['uid'] = $uid;
         $where['type_id'] = $id;
         $where['type'] = $type;
+        if ($day) {
+            $where['day'] = $day;
+        }
         $where['state'] = 1;
         $table = $this->table;
         $info = Dever::db($table)->one($where);
 
         $where['content'] = $content;
 
-        if ($info) {
-            Dever::alert('已发布过动态,仅能发布一次,可删除旧动态后再添加');
-        }
-        //$info = false;
         if ($pic) {
             $where['pic'] = $pic;
         }
@@ -100,9 +99,12 @@ class Moment
         if ($to_uid) {
             $where['to_uid'] = $to_uid;
         }
-        if ($day) {
-            $where['day'] = $day;
+
+        if ($info && !$to_id) {
+            Dever::alert('已发布过动态,仅能发布一次,可删除旧动态后再添加');
         }
+        //$info = false;
+        
         $data_table = $this->table($type);
         if (!$info) {
             $data = Dever::db($data_table)->one($id);

+ 1 - 1
app/community/src/Api.php

@@ -68,7 +68,7 @@ class Api extends Core
     public function comment()
     {
         $user = Dever::input('user', false);
-        $data = Dever::load('community/lib/comment')->getData('getData', $this->uid, $this->type, $this->type_id, $user, $this->id);
+        $data = Dever::load('community/lib/comment')->getData('getData', $this->uid, $this->type, $this->type_id, $user, $this->id, $this->times, $this->day);
         return $data;
     }
 

+ 4 - 0
package/short/index.php

@@ -0,0 +1,4 @@
+<?php
+define('DEVER_PACKAGE',  'short');
+define('DEVER_APP_SETUP', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../boot.php');