dever 4 年之前
父節點
當前提交
11ae1147c8

+ 156 - 0
app/collection/database/button.php

@@ -0,0 +1,156 @@
+<?php
+
+# 定义几个常用的选项
+$status = Dever::config('base')->status;
+
+$type = array
+(
+	1 => '进入合集',
+	2 => '购买门票',
+	3 => '查看排行榜',
+	10 => '链接',
+);
+
+return array
+(
+    # 表名
+    'name' => 'button',
+    # 显示给用户看的名称
+    'lang' => '首页按钮配置',
+    'order' => 100,
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'info_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '合集',
+            'default'   => '',
+            'desc'      => '合集',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id')
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '按钮名称',
+            'default'   => '',
+            'desc'      => '按钮名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '类型',
+            'default'   => '1',
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            'update'  => 'select',
+            'option'    => $type,
+            'search'    => 'select',
+            'list'      => true,
+            'edit'      => true,
+            'control'	=> 'type',
+        ),
+
+        'link'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '链接',
+            'default'   => '',
+            'desc'      => '链接',
+            'match'     => 'option',
+            'update'    => 'text',
+            'show'		=> 'type=10',
+        ),
+
+        'info'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '介绍',
+            'default'   => '',
+            'desc'      => '介绍',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+        ),
+
+        'icon'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '图标-图片尺寸150*150px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '图标',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '150*150',
+        ),
+
+        'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越小越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'asc',
+			'edit'		=> true,
+		),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '添加时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            //'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        
+    ),
+
+
+    'request' => array
+    (
+        
+    ),
+);

+ 24 - 7
app/collection/database/info.php

@@ -183,13 +183,13 @@ $config = array
         'pic_bg'        => array
         (
             'type'      => 'text-255',
-            'name'      => '全屏背景图-可以上传多张,展示在合集首页,图片尺寸750*1386px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'name'      => '首页头图-可以上传多张,展示在合集首页,图片尺寸414*374px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
             'default'   => '',
-            'desc'      => '全屏背景图',
+            'desc'      => '首页头图',
             'match'     => 'option',
             'update'    => 'images',
             'key'       => '1',
-            'place'     => '750*1386',
+            'place'     => '414*374',
         ),
 
         'bgmusic'       => array
@@ -220,6 +220,18 @@ $config = array
             'auth'      => '"{pdate}" > 0',
         ),
 
+        'content'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '内容介绍-内容介绍显示在合集首页',
+            'default'   => "",
+            'desc'      => '请输入内容',
+            'match'     => 'is_string',
+            'update'    => 'editor',
+            'key'       => 1,
+            //'show'      => 'buy=1',
+        ),
+
         'hr2'       => array
         (
             'name'      => '积分配置',
@@ -438,12 +450,14 @@ $config = array
             'edit'      => true,
         ),
 
+        /*
         'hr4'       => array
         (
             'name'      => '首页按钮配置',
             'class'     => '',//本项必须填写
             'attr'      => '',
         ),
+        */
 
         'button'      => array
         (
@@ -452,7 +466,7 @@ $config = array
             'default'   => '入口,排行榜',
             'desc'      => '首页按钮名称配置',
             'match'     => 'is_string',
-            'update'    => 'text',
+            //'update'    => 'text',
         ),
 
         'button_ftcolor'      => array
@@ -462,7 +476,7 @@ $config = array
             'default'   => '#ffffff',
             'desc'      => '首页按钮文字颜色',
             'match'     => 'is_string',
-            'update'    => 'color',
+            //'update'    => 'color',
         ),
 
         'button_bgcolor'      => array
@@ -472,7 +486,7 @@ $config = array
             'default'   => '#000000',
             'desc'      => '首页按钮背景颜色配置',
             'match'     => 'is_string',
-            'update'    => 'color',
+            //'update'    => 'color',
         ),
 
         'button_bgjcolor'      => array
@@ -482,7 +496,7 @@ $config = array
             'default'   => '#000000',
             'desc'      => '首页按钮背景渐变颜色配置',
             'match'     => 'option',
-            'update'    => 'color',
+            //'update'    => 'color',
         ),
 
         'hr5'       => array
@@ -626,6 +640,9 @@ $config = array
         (
             'update' => '编辑',
             'edit' => array('预览', str_replace('https://api.', 'http://www.', Dever::url('collection/lib/manage.preview?type=1'))),
+
+            'list0' => array('按钮', '"button&search_option_info_id={id}&oper_table=info"' , '{audit} == 1'),
+
             'br2' => array('<br />'),
 
             'list1' => array('功能', '"function&search_option_info_id={id}&oper_table=info"' , '{audit} == 1'),

+ 44 - 2
app/collection/src/Api.php

@@ -50,9 +50,40 @@ class Api extends Core
         }
         $data['user'] = $this->user;
 
-        # 有多少余额
+        $data['row'] = array();
+
         $data['score'] = Dever::load('score/lib/core')->getUserScore($this->uid);
-        $data['score']['info'] = '';
+
+        $data['row'][] = array
+        (
+            'type' => 'yue',
+            'name' => $data['score']['name'],
+            'value' => $data['score']['score'],
+        );
+
+        $data['row'][] = array
+        (
+            'type' => 'quan',
+            'name' => '代金券',
+            'value' => 0,
+        );
+
+        $ticket = Dever::load('user/lib/ticket')->num($this->uid);
+
+        $data['row'][] = array
+        (
+            'type' => 'piao',
+            'name' => '门票',
+            'value' => $ticket,
+        );
+
+        $data['row'][] = array
+        (
+            'type' => 'sw',
+            'name' => '声望',
+            'value' => 0,
+        );
+
 
         # 基本配置
         $data['config'] = Dever::db('main/config')->one();
@@ -286,6 +317,17 @@ class Api extends Core
             }
         }
 
+        $data['button'] = Dever::db('collection/button')->state(array('info_id' => $data['info']['id']));
+
+        /*
+        $score = Dever::load('score/lib/core')->getUserScore($this->uid, $data['info']['score_id'], 'collection/info', $data['info']['id']);
+        if ($score) {
+            $data['info']['score'] = $score;
+        } else {
+            $data['info']['score'] = array();
+        }
+        */
+
         return $data;
     }
 

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

@@ -145,11 +145,26 @@ return array
             # 匹配的正则或函数 选填项
             'option' => array
             (
+                'uid' => 'yes',
                 'info_id' => 'yes',
                 //'state' => 1,
             ),
             'type' => 'one',
             'col' => 'sum(total) as  total',
         ),
+
+        # 查看数量
+        'num' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'uid' => 'yes',
+                'info_id' => 'yes',
+                //'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(num) as  num',
+        ),
     ),
 );

+ 1 - 1
app/user/lib/Info.php

@@ -78,7 +78,7 @@ class Info
 		            $result['avatar'] = $user['avatar'];
 		            $result['info'] = $user['info'];
 		            $result['sex'] = $user['sex'];
-		            $result['title'] = '';
+		            $result['title'] = $user['title'];
 		        } else {
 		        	!$result['username'] && $result['username'] = $user['username'];
 		        	!$result['avatar'] && $result['avatar'] = $user['avatar'];

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

@@ -60,6 +60,21 @@ class Ticket
         }
     }
 
+    # 获取数量
+    public function num($uid, $info_id = false)
+    {
+        $where['uid'] = $uid;
+        if ($info_id) {
+            $where['info_id'] = $info_id;
+        }
+        
+        $num = Dever::db('user/ticket')->num($where);
+        if ($num) {
+            return $num['num'];
+        }
+        return 0;
+    }
+
     # 验证是否购买
     public function check($uid, $info_id)
     {

+ 2 - 2
app/user/src/Api.php

@@ -44,9 +44,9 @@ class Api extends Core
         }
 
         # 有多少门票
-        $ticket = Dever::load('user/lib/ticket')->check($this->uid, $info['id']);
+        $ticket = Dever::load('user/lib/ticket')->num($this->uid, $info['id']);
         if ($ticket) {
-            $data['num'][] = array($ticket['num'], '', $info['ticket_name'], 'ticket');
+            $data['num'][] = array($ticket, '', $info['ticket_name'], 'ticket');
         }
 
         //$data['num'][] = array('10', '', '好友');

+ 5 - 0
config/env/localhost/default.php

@@ -22,6 +22,11 @@ $local = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $ip;
 # 数据库配置
 $config['database'] = array
 (
+    # 是否开启mysql自助优化功能,开启后,会记录所有where条件和order的字段,可以方便的在后台进行分析、增加索引,必须安装manage组件
+    'opt' => true,
+
+    # 是否开启sql自动优化,将sql中的select * 转换为 select a,b形式,将sql中的where条件按照索引从左到右自动排序,必须打开上述的opt选项,数据量大时建议打开。
+    'sqlOp' => true,
     'create' => $create,
 	# 默认数据库配置
 	'default' => array