dever 5 years ago
commit
ecb1016bf5
9 changed files with 2570 additions and 0 deletions
  1. 56 0
      assets/manage/html/magazine.html
  2. 154 0
      database/buy.php
  3. 292 0
      database/cate.php
  4. 682 0
      database/content.php
  5. 721 0
      database/info.php
  6. 153 0
      database/ranking.php
  7. 8 0
      index.php
  8. 421 0
      lib/Manage.php
  9. 83 0
      src/Api.php

+ 56 - 0
assets/manage/html/magazine.html

@@ -0,0 +1,56 @@
+<style>
+.layui-col-md2
+{
+    height: 250px;
+    border:1px solid #bababa;
+    margin:5px;
+}
+.layui-col-md2 .img
+{
+    text-align: center;overflow: hidden;text-align: center;
+}
+</style>
+<div class="layui-fluid layadmin-cmdlist-fluid">
+  <ul class="layui-row layui-col-space30" id="sortable">
+    <li class="layui-col-md2 layui-col-sm4" id="data" style="">
+        <div class="cmdlist-container">
+            <div href="javascript:;" class="img" style="height: 154px;">
+              <img src="../../layuiadmin/style/res/template/portrait.png">
+            </div>
+            <a href="javascript:;" >
+              <div class="cmdlist-text" style="text-align:center;">
+                <p class="info">2018春夏季新款港味短款白色T恤+网纱中长款chic半身裙套装两件套</p>
+                <div class="price">
+                    <b></b>
+                </div>
+
+                <div class="text"></div>
+                
+
+                <div style="margin-top:10px;text-align:center;">
+                <div class="layui-table-cell"><a href="javascript:;" class="edit" onclick=""><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">编辑</button></a>&nbsp;&nbsp;<a href="#" class="oper_delete"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-danger layui-btn-xs"><span class="am-icon-trash-o"></span>删除</button></a>&nbsp;&nbsp;</div>
+                </div>
+              </div>
+            </a>
+        </div>
+    </li>
+  </ul>
+</div>
+
+<script id="url">var url = ""</script>
+<script>
+  $( function() {
+    var sort = $( "#sortable" ).sortable({
+        opacity: 0.7,
+        stop:function(){
+          var arr = $( "#sortable" ).sortable('toArray');
+          arr = arr.join(',');
+          $.post(url, {data:arr}, function()
+          {
+
+          })
+        }
+    });
+    $( "#sortable" ).disableSelection();
+  } );
+  </script>

+ 154 - 0
database/buy.php

@@ -0,0 +1,154 @@
+<?php
+
+# 定义几个常用的选项
+$status = array
+(
+    1 => '在线',
+    2 => '下线',
+);
+
+return array
+(
+    # 表名
+    'name' => 'buy',
+    # 显示给用户看的名称
+    'lang' => '购买设置',
+    'order' => 100,
+    'menu' => false,
+    'ends' => array
+    (
+        'insert' => 'magazine/lib/manage.setBuyCache',
+        'update' => 'magazine/lib/manage.setBuyCache',
+    ),
+    # 数据结构
+    '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')
+        ),
+
+        'num'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买本数-直接填写购买的电子刊本数数字即可',
+            'default'   => '1',
+            'desc'      => '购买本数',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '购买名称-一般为“购买n本”,如购买1本,如果为空,则根据购买本数自动生成如“购买n本”',
+            'default'   => '',
+            'desc'      => '购买名称',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => 'Dever::load("magazine/lib/manage.getName", {id})',
+        ),
+
+        'price'     => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '购买时的标价-为空则自动根据电子杆的单本支付价格计算',
+            'default'   => '',
+            'desc'      => '购买时的标价',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => 'Dever::load("magazine/lib/manage.getPrice", {id})',
+        ),
+
+        'code'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '生成门票数量-直接填写购买当前本数所能得到的门票数,默认为1',
+            'default'   => '1',
+            'desc'      => '生成门票数量',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list_name' => '排序',
+            'list'      => true,
+            'order'     => 'desc',
+            '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
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'cdate' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);

+ 292 - 0
database/cate.php

@@ -0,0 +1,292 @@
+<?php
+# 获取分类权限
+$auth = Dever::tops();
+$status = Dever::config('base')->status;
+$type = array
+(
+    # 默认类型
+    3 => '图文内容',
+    1 => '全屏图',
+    
+    # 2019-03-27 增加两个类型
+    7 => '长图(文字)',
+    8 => '横屏图',
+
+    2 => '长图',
+    9 => '无边框图片',
+    10 => '四宫格图片',
+
+    # 2018-12-11 增加3个类型
+    4 => '全屏视频',
+    5 => '留言视频',
+    6 => '留言音频',
+
+    # 2019-03-27 增加三个类型
+    21 => '对话模板',
+
+    # 关联类型 > 10
+    //11 => '关联图文',
+    12 => '关联视频',
+    13 => '关联直播',
+
+    # 2019-07-26
+    31 => '电商产品',
+    32 => 'H5',
+);
+
+$type = array
+(
+    # 图文
+    1 => '图文内容',
+    2 => '全屏图+文字',
+    3 => '长图+文字',
+    4 => '横屏图+文字',
+
+    # 图片
+    11 => '长图',
+    12 => '无边框图片',
+    13 => '四宫格图片',
+
+    # 音视频
+    21 => '全屏视频',
+    22 => '留言视频',
+    23 => '留言音频',
+
+    # 交互
+    31 => '对话模板',
+
+    # 电商
+    41 => '电商产品',
+
+    # h5
+    51 => '链接地址',
+
+    # 关联
+    61 => '关联图文',
+    62 => '关联视频',
+    63 => '关联直播',
+);
+
+$list = array
+(
+    # 匹配的正则或函数 选填项
+    'option' => array
+    (
+
+        'name' => array('yes', 'like'),
+        'id' => array($auth, 'in'),
+        'state' => 'yes',
+    ),
+    'type' => 'all',
+    'order' => array('reorder' => 'desc', 'id' => 'desc'),
+    'page' => array(20, 'list'),
+    'col' => '*|id',
+);
+
+
+$id = Dever::input('where_id');
+return array
+(
+    # 表名
+    'name' => 'cate',
+    # 显示给用户看的名称
+    'lang' => '分类设置',
+    # 后台菜单排序
+    'order' => 9,
+    'gettype' => $type,
+    'end' => array
+    (
+        'update' => array
+        (
+            'passport/lib/manage.updateSystem',
+            'manage/top.sync',
+        ),
+        'insert' => array
+        (
+            'passport/lib/manage.updateSystem',
+            'manage/top.sync',
+        )
+    ),
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-32',
+            'name'      => '分类名称',
+            'default'   => '',
+            'desc'      => '请输入名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'type'     => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '内容类型-定义电子刊下的内页内容类型',
+            'default'   => '1,2,3,4,11,12,13,21,22,23,31,41',
+            'desc'      => '内容类型',
+            'match'     => 'is_numeric',
+            'update'    => 'checkbox',
+            'option'    => $type,
+        ),
+
+        'logo'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => 'logo图-图片尺寸100*100px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => 'logo图',
+            'match'     => 'option',
+            'update'  => 'image',
+            'key'       => '1',
+            'place'     => '100*100',
+        ),
+
+        'cover'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '封面图-图片尺寸460*759px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '封面图',
+            'match'     => 'option',
+            'update'  => 'image',
+            'key'       => '1',
+            'place'     => '460*759',
+        ),
+
+        'desc'     => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '简介',
+            'default'   => '',
+            'desc'      => '简介',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '上线状态',
+            'default'   => '2',
+            'desc'      => '上线状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            //'update'    => 'text',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+            '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,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    # 默认值
+    'default' => array
+    (
+        'col' => 'name,state,cdate',
+        'value' => array
+        (
+            '"默认分类",1,' . time(),
+        ),
+    ),
+
+    'manage' => array
+    (
+        //'insert' => false,
+        //'edit' => false,
+        'delete' => false,
+    ),
+
+    'top' => array
+    (
+        # 数据来源
+        'data' => 'state',
+        # 菜单名
+        'name' => '项目选择',
+        # 默认值
+        'value' => 1,
+        # 对应的字段值,设置这个之后,所有设置等于这个值的字段,都要遵循这个权限的控制
+        'key' => Dever::config('base')->top,
+        # 本表中代表名称的字段
+        'col' => 'name',
+    ),
+
+    'request' => array
+    (
+        'list' => $list,
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'state' => 1,
+                'status' => 2,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc','id' => 'desc'),
+            'col' => 'id,name,logo',
+        ),
+
+        'getIds' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'ids' => array('yes-id', 'in'),
+                'status' => 2,
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc','id' => 'desc'),
+            'col' => '*,id as value|id',
+        ),
+    ),
+);

+ 682 - 0
database/content.php

@@ -0,0 +1,682 @@
+<?php
+
+$id = Dever::input('search_option_info_id');
+$cate = array();
+if ($id) {
+    $magazine = Dever::db('magazine/info')->one($id);
+    $cate = Dever::db('magazine/cate')->one($magazine['cate_id']);
+}
+
+$type_default = 3;
+$type_config = Dever::db('magazine/cate')->config['gettype'];
+if ($cate) {
+    $type = array();
+    $cate_type = explode(',', $cate['type']);
+    $i = 0;
+    foreach ($cate_type as $k => $v) {
+        if (isset($type_config[$v])) {
+            if ($i == 0) {
+                $type_default = $v;
+            }
+            $type[$v] = $type_config[$v];
+            $i++;
+        }
+    }
+} else {
+    $type = $type_config;
+}
+
+$product = function()
+{
+    $array = array();
+    $info = Dever::db('product/info')->state();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$is_button = array
+(
+    1 => '显示',
+    2 => '不显示',
+);
+
+$text = array
+(
+    1 => '上左',
+    2 => '上中',
+    3 => '上右',
+    4 => '中左',
+    5 => '正中',
+    6 => '中右',
+    7 => '下左',
+    8 => '下中',
+    9 => '下右',
+    //10 => '自定义',
+);
+
+
+$palaces = array
+(
+    1 => '上左',
+    2 => '上右',
+    3 => '下左',
+    4 => '下右',
+);
+
+$bgcolor_type = array
+(
+    1 => '设置背景颜色',
+    2 => '不设置背景颜色',
+);
+$talk_type = array
+(
+    1 => '文字',
+    2 => '图片',
+    3 => '音频',
+);
+
+$talk_location = array
+(
+    1 => '显示在左侧',
+    2 => '显示在右侧',
+);
+
+$author = function()
+{
+    $array = array();
+    $info = Dever::db('content/author')->state();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+return array
+(
+    # 表名
+    'name' => 'content',
+    # 显示给用户看的名称
+    'lang' => '内页管理',
+    'menu' => false,
+    'gettype' => $type,
+    'text' => $text,
+    'end' => array
+    (
+        'insert' => 'magazine/lib/manage.addContent',
+    ),
+    # 数据结构
+    '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')
+        ),
+
+        'type'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '类型',
+            'default'   => $type_default,
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'control'   => 'type',
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '标题',
+            'default'   => '',
+            'desc'      => '标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+            //增加预览
+            'preview'   => true,
+            'show'      => 'type=1,22,23,51',      
+        ),
+
+        'url'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '链接地址',
+            'default'   => '',
+            'desc'      => '链接地址',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+            //增加预览
+            'preview'   => true,
+            'show'      => 'type=51',      
+        ),
+
+        'video'     => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '上传视频-视频格式mp4,上传大小不能超过4G',
+            'default'   => '',
+            'desc'      => '上传点播视频',
+            'match'     => 'is_string',
+            'update'    => 'upload',
+            'key'       => '3',
+            'place'     => '150',
+            'upload'    => 'qiniu',
+            'large'     => true,
+            //不覆盖原文件,生成新文件
+            'cover'     => 2,
+            'show'      => 'type=21,22',      
+        ),
+
+        'video_info'        => array
+        (
+            'type'      => 'text-255',
+            'name'      => '视频信息',
+            'default'   => '',
+            'desc'      => '视频信息',
+            'match'     => 'is_string',
+        ),
+
+        'music'     => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '上传音频-视频格式mp3,上传大小不能超过100M',
+            'default'   => '',
+            'desc'      => '上传音频',
+            'match'     => 'is_string',
+            'update'    => 'upload',
+            'key'       => '2',
+            'place'     => '150',
+            'upload'    => 'qiniu',
+            'large'     => true,
+            //不覆盖原文件,生成新文件
+            'cover'     => 2,
+            'show'      => 'type=23',      
+        ),
+
+        'cover'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '封面图-全屏视频的封面图图片尺寸750*1386px或等比尺寸,留言视频的封面图图片尺寸750*422px或等比尺寸,留言音频的封面图图片尺寸750*422px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '封面图',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '150',
+            'show'      => 'type=21,22,23',      
+        ),
+
+        'focus'     => array
+        (
+            'type'      => 'text-255',
+            'name'      => '焦点图',
+            'default'   => '',
+            'desc'      => '焦点图',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '150',
+            'show'      => 'type=1',      
+        ),
+
+        'author_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '作者',
+            'default'   => '1',
+            'desc'      => '作者',
+            'match'     => 'is_numeric',
+            //'update'    => 'select',
+            //'option'    => $author,
+            //'search'    => 'select',
+            'show'      => 'type=1',      
+        ),
+
+        'content'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '内容',
+            'default'   => '',
+            'desc'      => '请输入内容',
+            'match'     => 'is_string',
+            'update'    => 'editor',
+            'show'      => 'type=1',
+            //自定义编辑器右侧按钮
+            'editor'    => array
+            (
+                'name' => '选择插入模块',
+                'button' => array
+                (
+                    array
+                    (
+                        # 名称
+                        'name' => '图片',
+                        # 资源库id
+                        'key' => 1,
+                        # 类型
+                        'type' => 'image',
+                    ),
+                    array
+                    (
+                        'name' => '音频',
+                        'key' => 2,
+                        'type' => 'media',
+                    ),
+                    array
+                    (
+                        'name' => '视频',
+                        'key' => 'video/lib/core.vod',
+                    ),
+                    array
+                    (
+                        'name' => '直播',
+                        'key' => 'video/lib/core.live',
+                    ),
+                    array
+                    (
+                        'name' => '小程序',
+                        'key' => 'content/lib/applet.update',
+                        'type' => 'update',
+                    ),
+                ),
+            ),
+        ),
+
+        'pic'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '图片-全屏图图片尺寸750*1386px或等比尺寸,长屏图图片尺寸750*高度不限或等比尺寸,横屏图图片尺寸宽度不限*1386px或等比尺寸,长图图片尺寸750*高度不限或等比尺寸,无边框图片尺寸长和宽均没有限制,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '图片',
+            'match'     => 'option',
+            'update'  => 'image',
+            'key'       => '1',
+            'place'     => '150',
+            'show'      => 'type=2,3,4,11,12',      
+        ),
+
+        'pic_info'        => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '图片信息',
+            'default'   => '',
+            'desc'      => '图片信息',
+            'match'     => 'is_string',
+            'update'    => 'hidden',
+        ),
+
+        'is_button'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '是否显示保存按钮',
+            'default'   => '1',
+            'desc'      => '是否显示保存按钮',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $is_button,
+           // 'search'    => 'select',
+            'show'      => 'type=2,3,4',      
+            'control'   => 'is_button',
+        ),
+
+        'button_name'     => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '保存按钮文字内容',
+            'default'   => '保存图片',
+            'desc'      => '保存按钮文字内容',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            'show'      => 'type=2,3,4',      
+        ),
+
+        'button_color'     => array
+        (
+            'type'      => 'varchar-10',
+            'name'      => '保存按钮文字颜色',
+            'default'   => '#000000',
+            'desc'      => '保存按钮文字颜色',
+            'match'     => 'option',
+            'update'    => 'color',
+            'show'      => 'type=2,3,4',      
+        ),
+
+        'product_id'     => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '关联商品',
+            'default'   => '',
+            'desc'      => '关联商品',
+            'match'     => 'option',
+            'update'    => 'checkbox',
+            'show'      => 'type=41',
+            //'option'    => $product,
+        ),
+
+        'article_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '关联图文',
+            'default'   => '',
+            'desc'      => '关联图文',
+            'match'     => 'option',
+            'update'    => 'select',
+            'show'      => 'type=61',
+            'update_search' => 'magazine/lib/manage.search_article',
+        ),
+
+        'vod_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '关联视频',
+            'default'   => '',
+            'desc'      => '关联视频',
+            'match'     => 'option',
+            'update'    => 'select',
+            'show'      => 'type=62',
+            'update_search' => 'magazine/lib/manage.search_vod',
+        ),
+
+        'live_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '关联直播',
+            'default'   => '',
+            'desc'      => '关联直播',
+            'match'     => 'option',
+            'update'    => 'select',
+            'show'      => 'type=63',
+            'update_search' => 'magazine/lib/manage.search_live',
+        ),
+
+        'text'       => array
+        (
+            'type'      => 'text-1000',
+            'name'      => '文字设置',
+            'default'   => '',
+            'desc'      => '文字设置',
+            'match'     => 'is_string',
+            'option'    => $text,
+            'show'      => 'type=2,3,4',
+            'update'    => array
+            (
+                array
+                (
+                    'col'       => 'name',
+                    'name'      => '文字内容',
+                    'default'   => '',
+                    'desc'      => '文字内容',
+                    'match'     => 'is_string',
+                    'update'    => 'textarea',
+                ),
+
+                array
+                (
+                    'col'       => 'color',
+                    'name'      => '文字颜色',
+                    'default'   => '#000000',
+                    'desc'      => '文字颜色',
+                    'match'     => 'is_string',
+                    'update'    => 'color',
+                ),
+
+                array
+                (
+                    'col'       => 'bgcolor_type',
+                    'name'      => '是否设置背景颜色',
+                    'default'   => '2',
+                    'desc'      => '是否设置背景颜色',
+                    'match'     => 'is_string',
+                    'update'    => 'radio',
+                    'option'    => $bgcolor_type,
+                    'control'   => 'bgcolor_type',
+                ),
+
+                array
+                (
+                    'col'       => 'bgcolor',
+                    'name'      => '背景颜色',
+                    'default'   => '#000000',
+                    'desc'      => '背景颜色',
+                    'match'     => 'is_string',
+                    'update'    => 'color',
+                    'show'      => 'bgcolor_type=1'
+                ),
+
+                array
+                (
+                    'col'       => 'size',
+                    'name'      => '文字大小-直接输入像素数字',
+                    'default'   => '16',
+                    'desc'      => '结果描述',
+                    'match'     => 'is_numeric',
+                    'update'    => 'text',
+                ),
+            ),
+        ),
+
+        'palaces'       => array
+        (
+            'type'      => 'text-1000',
+            'name'      => '四宫格图片',
+            'default'   => '',
+            'desc'      => '四宫格图片',
+            'match'     => 'is_string',
+            'option'    => $palaces,
+            'show'      => 'type=13',
+            'update'    => array
+            (
+                array
+                (
+                    'col'       => 'pic',
+                    'name'      => '图片',
+                    'default'   => '',
+                    'desc'      => '图片',
+                    'match'     => 'is_string',
+                    'update'    => 'image',
+                    'key'       => 1,
+                ),
+            ),
+        ),
+
+        'talk_pic'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '置顶图片-图片尺寸750*1386px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式。为空则不显示',
+            'default'   => '',
+            'desc'      => '图片',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '150',
+            'show'      => 'type=31',      
+        ),
+
+        'talk'       => array
+        (
+            'type'      => 'text-1000',
+            'name'      => '对话设置',
+            'default'   => '',
+            'desc'      => '对话设置',
+            'match'     => 'is_string',
+            'show'      => 'type=31',
+            'update'    => array
+            (
+                array
+                (
+                    'col'       => 'talk_location',
+                    'name'      => '对话位置',
+                    'default'   => '1',
+                    'desc'      => '对话位置',
+                    'match'     => 'is_string',
+                    'update'    => 'radio',
+                    'option'    => $talk_location,
+                ),
+
+                array
+                (
+                    'col'       => 'avatar',
+                    'name'      => '头像-图片尺寸120*120px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式。',
+                    'default'   => '',
+                    'desc'      => '头像',
+                    'match'     => 'option',
+                    'update'    => 'image',
+                    'key'       => 1,
+                ),
+
+                array
+                (
+                    'col'       => 'talk_type',
+                    'name'      => '对话类型',
+                    'default'   => '1',
+                    'desc'      => '对话类型',
+                    'match'     => 'is_string',
+                    'update'    => 'radio',
+                    'option'    => $talk_type,
+                    'control'   => 'talk_type',
+                ),
+
+                array
+                (
+                    'col'       => 'text',
+                    'name'      => '文字内容-为空则不显示',
+                    'default'   => '',
+                    'desc'      => '文字内容',
+                    'match'     => 'option',
+                    'update'    => 'textarea',
+                    'show'      => 'talk_type=1'
+                ),
+
+                array
+                (
+                    'col'       => 'pic',
+                    'name'      => '图片-图片尺寸750*1386px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式,可以上传GIF格式。为空则不显示',
+                    'default'   => '',
+                    'desc'      => '图片',
+                    'match'     => 'option',
+                    'update'    => 'image',
+                    'key'       => 1,
+                    'show'      => 'talk_type=2'
+                ),
+
+                array
+                (
+                    'col'       => 'audio',
+                    'name'      => '音频-音频格式mp3,上传大小不能超过100M,为空则不显示',
+                    'default'   => '',
+                    'desc'      => '音频',
+                    'match'     => 'option',
+                    'update'    => 'upload',
+                    'key'       => 2,
+                    'show'      => 'talk_type=3'
+                ),
+            ),
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '页号',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            //'update'    => 'text',
+            'search'    => 'order',
+            '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
+    (
+        'insert' => false,
+        'edit' => false,
+        //'delete' => false,
+        'num' => false,
+        'page_list_table' => 'magazine',
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增内页' => array('location', 'add'),
+            '预览' => array('fast', 'main/preview.get?type=4&id=' . Dever::input('search_option_info_id')),
+        ),
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'asc', 'id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+
+        'getAllByReorder' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => '*',
+        ),
+    )
+);

+ 721 - 0
database/info.php

@@ -0,0 +1,721 @@
+<?php
+$time = (7*86400);
+$audit = Dever::config('base')->audit;
+
+$status = Dever::config('base')->status;
+
+# 获取小刊分类权限
+$auth = Dever::tops();
+$cate = function() use ($auth)
+{
+	$array = array();
+	if ($auth) {
+		$info = Dever::db('magazine/cate')->getIds(array('ids' => $auth));
+	} else {
+		$info = Dever::db('magazine/cate')->state();
+	}
+	
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+
+$share = array
+(
+	1 => '显示',
+	2 => '不显示',
+);
+
+$ranking = array
+(
+	1 => '开启',
+	2 => '不开启',
+);
+
+$sell = array
+(
+	1 => '开启',
+	2 => '不开启',
+);
+
+$buy = array
+(
+	1 => '收费',
+	2 => '免费',
+);
+
+$hot = array
+(
+	1 => '热门',
+	2 => '普通',
+);
+
+
+$page = 15;
+
+# 常用的col
+$col = '*';
+
+$config = array
+(
+	# 表名
+	'name' => 'info',
+	# 显示给用户看的名称
+	'lang' => '电子刊管理',
+	'order' => 100,
+	'ends' => array
+	(
+		'insert' => 'magazine/lib/manage.setInfoCache',
+		'update' => 'magazine/lib/manage.setInfoCache',
+		'update_status' => 'magazine/lib/manage.setInfoCache',
+	),
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-180',
+			'name' 		=> '标题',
+			'default' 	=> '',
+			'desc' 		=> '标题',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'subname'		=> array
+		(
+			'type' 		=> 'varchar-80',
+			'name' 		=> '子标题-一般为电子刊的期数,如第1期',
+			'default' 	=> '',
+			'desc' 		=> '子标题',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'cate_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '分类',
+			'default' 	=> '1',
+			'desc' 		=> '分类',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $cate,
+			'search'	=> 'select',
+			//'list'		=> true,
+		),
+
+		'pic_cover'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '封面图-图片尺寸660*660px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '封面图',
+			'match' 	=> 'is_string',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '660*660',
+		),
+
+		'pic_bg'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '全屏背景图-图片尺寸750*1386px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '全屏背景图',
+			'match' 	=> 'is_string',
+			'update'	=> 'images',
+			'key' 		=> '1',
+			'place'		=> '750*1386',
+		),
+
+		'bgmusic'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '背景音乐-音频格式mp3,上传大小不能超过100M',
+			'default' 	=> '',
+			'desc' 		=> '背景音乐',
+			'match' 	=> 'option',
+			'update'	=> 'upload',
+			'key' 		=> '2',
+			'place'		=> '150',
+			'upload'	=> 'qiniu',
+			'large' 	=> true,
+			//不覆盖原文件,生成新文件
+			'cover'		=> 2,
+		),
+
+		'pdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '发售时间',
+			'match' 	=> array('is_numeric', time()),
+			'default'	=> '',
+			'desc' 		=> '',
+			'update'	=> 'date',
+			'callback'	=> 'maketime',
+			'insert'	=> true,
+			//'list'		=> 'date("Y-m-d H:i:s", {pdate})',
+			'auth'		=> '"{pdate}" > 0',
+		),
+
+		'buy'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '是否收费',
+			'default' 	=> '1',
+			'desc' 		=> '是否收费',
+			'match' 	=> 'option',
+			'update'	=> 'radio',
+			'option'	=> $buy,
+			'control'	=> 'buy',
+			//'list'		=> true,
+			'search'	=> 'select',
+		),
+
+		'num_ding'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '订阅数',
+			'default' 	=> '0',
+			'desc' 		=> '请填写订阅数',
+			'match' 	=> 'option',
+			'search'	=> 'order',
+		),
+
+		'num_ratio_ding'		=> array
+		(
+			'type' 		=> 'varchar-20',
+			'name' 		=> '订阅系数-系数不能小于等于0,支持两位小数,电子刊总订阅量=(用户当前订阅数+订阅基数)*订阅系数。',
+			'default' 	=> '1',
+			'desc' 		=> '手动增加订阅系数',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'show'		=> 'buy=1',
+		),
+
+		'num_add_ding'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '订阅基数',
+			'default' 	=> '0',
+			'desc' 		=> '手动增加阅读数',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'show'		=> 'buy=1',
+		),
+
+		'num_add_view'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '阅读数基数',
+			'default' 	=> '0',
+			'desc' 		=> '手动增加阅读数',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+		),
+
+		'num_view'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '阅读数',
+			'default' 	=> '0',
+			'desc' 		=> '请填写阅读数',
+			'match' 	=> 'option',
+			'search'	=> 'order',
+		),
+
+		'num_add_up'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '收藏基数',
+			'default' 	=> '0',
+			'desc' 		=> '收藏基数',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+		),
+		
+		'num_up'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '收藏数',
+			'default' 	=> '0',
+			'desc' 		=> '请填写收藏数',
+			'match' 	=> 'option',
+			//'search'	=> 'order',
+			'list'		=> 'Dever::load("magazine/lib/manage.num?id={id}")',
+			'list_name'	=> '统计数字',
+		),
+
+		'cash'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '单本支付价格-单位元,直接填写数字即可',
+            'default'   => '',
+            'desc'      => '支付价格',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'show'		=> 'buy=1',
+        ),
+
+        'buy_content'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '购买说明',
+            'default'   => "<p>
+	1、门票使用成功后可直接点击【入界】查看万界志内容;&nbsp;
+</p>
+<p>
+	2、万界志门票为虚拟商品,如无系统问题,使用后不可退款;
+</p>
+<p>
+	&nbsp;3、购买多少张就会生成多少门票,每个门票只能被激活一次;
+</p>
+<p>
+	&nbsp;4、当购买成功后,系统会自动使用一个门票;&nbsp;
+</p>
+<p>
+	5、若您购买了多张门票,可将剩余门票赠送好友;
+</p>
+<p>
+	&nbsp;6、如有其它问题可咨询在线客服。
+</p>",
+            'desc'      => '请输入内容',
+            'match'     => 'is_string',
+            'update'    => 'editor',
+            'key'       => 1,
+            'show'		=> 'buy=1',
+        ),
+
+        'score'         => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '购买增加积分数-直接填写购买单本电子刊的积分数,设置之后,积分规则里的设置将失效,如果设置为0,则按照积分规则进行增加积分',
+            'default'   => '20',
+            'desc'      => '增加积分数',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'show'		=> 'buy=1',
+        ),
+
+        'code_score'         => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '使用门票增加积分数-直接填写使用门票首次进入电子刊增加的积分数,设置之后,积分规则里的设置将失效,如果设置为0,则按照积分规则进行增加积分',
+            'default'   => '0',
+            'desc'      => '使用门票增加积分数',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'show'		=> 'buy=1',
+        ),
+
+        'code_parent_score'         => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '使用门票增加分享者积分数-直接填写使用门票首次进入电子刊增加的分享者的积分数,设置之后,积分规则里的设置将失效,如果设置为0,则按照积分规则进行增加积分',
+            'default'   => '10',
+            'desc'      => '使用门票增加分享者积分数',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'show'		=> 'buy=1',
+        ),
+
+        'audit'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '审核',
+			'default' 	=> '1',
+			'desc' 		=> '审核',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> $audit,
+			//'search'	=> 'select',
+			//'list'		=> true,
+			//'edit'		=> true,
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '上线状态',
+			'default' 	=> '1',
+			'desc' 		=> '上线状态',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> $status,
+			'search'	=> 'select',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+        'sell'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否开启分销',
+			'default' 	=> '1',
+			'desc' 		=> '是否开启分销',
+			'match' 	=> 'option',
+			'update'	=> 'radio',
+			'option'	=> $sell,
+			'list'		=> true,
+			'search'	=> 'select',
+			'edit'		=> true,
+		),
+
+        'ranking'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否开启排行榜',
+			'default' 	=> '1',
+			'desc' 		=> '是否开启排行榜',
+			'match' 	=> 'option',
+			'update'	=> 'radio',
+			'option'	=> $ranking,
+			'list'		=> true,
+			'search'	=> 'select',
+			'edit'		=> true,
+		),
+
+		'hot'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否热门电子刊',
+			'default' 	=> '2',
+			'desc' 		=> '是否热门电子刊',
+			'match' 	=> 'option',
+			//'update'	=> 'radio',
+			'option'	=> $hot,
+			'search'	=> 'select',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'share'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否显示分享按钮',
+			'default' 	=> '2',
+			'desc' 		=> '是否显示分享按钮',
+			'match' 	=> 'option',
+			'update'	=> 'radio',
+			'option'	=> $share,
+			'control'	=> 'share',
+		),
+
+		'share_title'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '分享标题',
+			'default' 	=> '',
+			'desc' 		=> '分享标题',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'show'		=> 'share=1',
+		),
+
+		'share_pic'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '分享图片-图片尺寸570*570px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '分享图片',
+			'match' 	=> 'is_string',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+			'show'		=> 'share=1',
+			//'upload'	=> 'qiniu',
+			//'large' 	=> true,
+		),
+
+		'share_content'		=> array
+		(
+			'type' 		=> 'varchar-200',
+			'name' 		=> '分享内容',
+			'default' 	=> '',
+			'desc' 		=> '分享内容',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'show'		=> 'share=1',
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+		'admin_founder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '创建人',
+			'default' 	=> '1',
+			'desc' 		=> '创建人',
+			'match' 	=> 'is_numeric',
+		),
+
+		'admin_editor'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '操作人',
+			'default' 	=> '1',
+			'desc' 		=> '操作人',
+			'match' 	=> 'is_numeric',
+		),
+
+		'udate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '更新时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+		),
+
+		'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,
+		),
+	),
+
+	'top' => Dever::config('base')->top,
+
+	# 增加这个,为了给当前的list增加一个option $admin = Dever::load('manage/auth.info');
+	'top_option' => array
+	(
+		array
+		(
+			'value' => $auth,
+			'col' => 'cate_id',
+		),
+		array
+		(
+			'value' => Dever::load('manage/auth.authData'),
+			'col' => 'id',
+		),
+	),
+	
+	# 管理功能
+	'manage' => array
+	(
+		//'insert' => false,
+		'delete' => false,
+		# 列表
+		'list_button' => array
+		(
+			'update' => '编辑',
+			'br1' => array('<br />'),
+			'edit' => array('预览', str_replace('https://api.', 'http://www.', Dever::url('main/preview.get?type=4'))),
+			'br2' => array('<br />'),
+			'list10' => array('排行榜', '"magazine_ranking&project=act&search_type=4&search_option_magazine_id={id}&oper_parent=info&oper_project=magazine"' , '{audit} == 1 && {buy} == 1'),
+			'add1' => array('排行榜设置', '"ranking&project=magazine&search_option_info_id={id}&oper_parent=info&oper_project=magazine&oper_save_jump=info&where_id={id}"', '{audit} == 1 && {buy} == 1'),
+
+			'list' => array('内页管理', '"content&search_option_info_id={id}&oper_parent=info&page_type=1"' , '{audit} == 1'),
+			
+			'list1' => array('购买本数管理', '"buy&search_option_info_id={id}&oper_parent=info"' , '{audit} == 1 && {buy} == 1'),
+		),
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+
+		'search' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'cate_id' => 'yes',
+				'name' => array('yes', 'like'),
+				'id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'pdate' => 'desc', 'id' => 'desc'),
+			'limit' => '0,1000',
+			'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
+		),
+
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				//'audit' => 2,
+				'buy' => 'yes',
+				'cate_id' => 'yes',
+				'status' => 2,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'pdate' => 'desc', 'id' => 'desc'),
+			//'page' => array(10, 'list'),
+			'col' => $col,
+		),
+
+		'getAllByPage' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				//'audit' => 2,
+				'cate_id_1' => array('yes-cate_id', '=', 'and('),
+				'time' => array('yes-pdate', '<=', 'or)'),
+				'buy' => 'yes',
+				'cate_id' => 'yes',
+				'status' => 2,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'pdate' => 'desc', 'id' => 'desc'),
+			'page' => array(10, 'list'),
+			'col' => $col,
+		),
+		
+		# 更新浏览量
+		'addView' => array
+		(
+			'type' => 'update',
+			'where' => array
+			(
+				'id' => 'yes',
+			),
+			'set' => array
+			(
+				'num_view' => array('1', '+='),
+			),
+		),
+
+		# 更新订阅量
+		'addDing' => array
+		(
+			'type' => 'update',
+			'where' => array
+			(
+				'id' => 'yes',
+			),
+			'set' => array
+			(
+				'num_up' => array('1', '+='),
+			),
+		),
+
+		'getIds' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'cate_id' => array('yes-cate_id', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'pdate' => 'desc','id' => 'desc'),
+            'col' => '*,id as value|id',
+        ),
+
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => $col,
+        ),
+
+        # 热门
+        'getHot' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				//'audit' => 2,
+				'hot' => 1,
+				'buy' => 'yes',
+				'time' => array('yes-pdate', '<=', 'or)'),
+				'cate_id' => 'yes',
+				'status' => 2,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'pdate' => 'desc', 'id' => 'desc'),
+			//'page' => array(10, 'list'),
+			'col' => $col,
+		),
+
+        'getNew' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+            	'cate_id_1' => array('yes-cate_id', '=', 'and('),
+				'time' => array('yes-pdate', '<=', 'or)'),
+				'cate_id' => 'yes',
+            	'status' => 2,
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'order' => array('ssdate' => 'desc'),
+            'col' => $col . ',case when cate_id = 1 then pdate else pdate-'.$time.' end as ssdate',
+        ),
+	),
+);
+
+/* 由top_option取代
+if ($auth) {
+	$config['request']['list'] = array
+	(
+		'type' => 'all',
+        'order' => array('id' => 'desc'),
+        'col' => '*|id',
+        'page' => array(15, 'list'),
+        'option' => array
+        (
+        	'cate_id' => array($auth, 'in'),
+        ),
+	);
+}
+*/
+
+return $config;

+ 153 - 0
database/ranking.php

@@ -0,0 +1,153 @@
+<?php
+
+$status = array
+(
+    1 => '开启',
+    2 => '关闭',
+);
+return array
+(
+    # 表名
+    'name' => 'ranking',
+    # 显示给用户看的名称
+    'lang' => '排行榜设置',
+    'menu' => false,
+    'ends' => array
+    (
+        'insert' => 'magazine/lib/manage.setRankingCache',
+        'update' => 'magazine/lib/manage.setRankingCache',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            'value'     => Dever::input('where_id')
+            //'list'        => true,
+        ),
+
+        'info_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id')
+        ),
+
+        'status'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排行榜状态',
+            'default'   => '1',
+            'desc'      => '排行榜状态',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $status,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '排行榜标题',
+            'default'   => '',
+            'desc'      => '排行榜标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'start'       => array
+        (
+            'type'      => 'int-11',
+            'default'   => '',
+            'name'      => '排行榜开始时间',
+            'match'     => 'option',
+            'desc'      => '排行榜开始时间',
+            'update'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {start})',
+            'callback'  => 'maketime',
+        ),
+
+        'end'       => array
+        (
+            'type'      => 'int-11',
+            'default'   => '',
+            'name'      => '排行榜结束时间',
+            'match'     => 'option',
+            'desc'      => '排行榜结束时间',
+            'update'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {end})',
+            'callback'  => 'maketime',
+        ),
+
+        'desc'      => array
+        (
+            'type'      => 'text-255',
+            'name'      => '排行榜描述',
+            'default'   => '',
+            'desc'      => '排行榜描述',
+            'match'     => 'option',
+            'update'    => 'editor',
+            'key'       => 1,
+            //'search'  => 'fulltext',
+            //'list'        => 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
+    (
+        # 获取提交订单超过12个小时
+        'getDataByTime' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'end' => array('yes', '<='),
+                'ends' => array('yes-end', '>'),
+                'state' => 1,
+                'status' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);

+ 8 - 0
index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'magazine');
+define('DEVER_APP_LANG', '电子杂志');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 100);
+define('DEVER_MANAGE_ICON', 'glyphicon-shopping-cart layui-icon-cellphone-fine');
+include(DEVER_APP_PATH . '../boot.php');

+ 421 - 0
lib/Manage.php

@@ -0,0 +1,421 @@
+<?php
+
+namespace Magazine\Lib;
+
+use Dever;
+
+class Manage
+{
+    public function getManageData()
+    {
+        $data = array();
+
+        $data = Dever::db('magazine/cate')->state();
+
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $data[$k]['child'] = Dever::db('magazine/info')->state(array('cate_id' => $v['id']));
+            }
+        }
+        return $data;
+    }
+
+    public function showOrderUserV1($id)
+    {
+        $info = Dever::db('act/order')->one($id);
+
+        $table = array();
+
+        $user = Dever::db('passport/user')->one($info['uid']);
+
+        $table['用户名'] = $user['username'] . '('.$info['uid'].')';
+        $table['手机号'] = $user['mobile'];
+        $table['产品名'] = $info['name'];
+        if ($info['type'] == 1) {
+            $table['支付方式'] = '购买小刊';
+            $table['支付金额'] = $info['cash'];
+        } elseif ($info['type'] == 3) {
+            $table['支付方式'] = '购买小刊兑换码';
+            $table['兑换码'] = $info['code'];
+            $table['支付金额'] = $info['cash'];
+        } elseif ($info['type'] == 2) {
+            $table['支付方式'] = '兑换小刊';
+            $table['兑换码'] = $info['code'];
+        } elseif ($info['type'] == 4) {
+            $table['支付方式'] = '使用通用兑换码';
+            $table['兑换码'] = $info['code'];
+        }
+        //$table['购买数量'] = $info['num'];
+        
+        if ($info['source_uid'] && $info['source_uid'] != $info['uid']) {
+            $user = Dever::db('passport/user')->one($info['source_uid']);
+            $table['邀请人'] = $user['username'];
+        }
+
+        if ($info['star_id']) {
+            $star = Dever::db('magazine/star')->one($info['star_id']);
+            $table['明星'] = $star['name'];
+        }
+
+        return Dever::table($table);
+    }
+
+    # 获取数据
+    public function num($id)
+    {
+        $data = Dever::db('magazine/info')->one($id);
+        $data = Dever::load('magazine/api')->ding($data);
+
+        $num_ding = $data['num_ding'];
+        $num_add_ding = $data['num_add_ding'];
+        $num_ratio_ding = $data['num_ratio_ding'];
+
+        $num_view = $data['num_view'];
+        $num_add_view = $data['num_add_view'];
+
+        $buy_num = $data['buy_num'];
+
+        //$html = '订阅本数:('.$buy_num.'+'.$num_add_ding.')*'.$num_ratio_ding.'='.$num_ding.'<br />阅读数:'.$num_view.'+'.$num_add_view.'<br />评论数:'.$num_comment.'<br />';
+
+        $cate = Dever::db('magazine/cate')->one($data['cate_id']);
+        $html = '《' . $cate['name'] . '》<br />';
+
+        if ($data['buy'] == 1) {
+            $html .= '<font style="color:red">收费电子刊</font><br />';
+            $html .= '订阅本数:('.$buy_num.'+'.$num_add_ding.')*'.$num_ratio_ding.'='.$num_ding;
+        } else {
+            $html .= '<font style="color:blue">免费电子刊</font><br />';
+            $html .= '订阅数:('.$buy_num.'+'.$num_add_ding.')*'.$num_ratio_ding.'='.$num_ding;
+        }
+        
+        return $html;
+    }
+
+    public function showOrderStatusV1($id)
+    {
+        $info = Dever::db('act/order')->one($id);
+        if ($info) {
+            if ($info['status'] == 1) {
+                #return '*已支付';
+                return '待支付';
+            } elseif ($info['status'] == 2) {
+                return '已支付';
+            } elseif ($info['status'] == 3) {
+                return '支付失败';
+            } elseif ($info['status'] == 5) {
+                $table['状态'] = '已退款';
+                $manage = Dever::db('manage/admin')->one($info['tk_admin']);
+                $table['备注'] = $info['tk_desc'];
+                $table['截图'] = '<a><img src="'.$info['tk_pic'].'" style="width:150px" /></a>';
+                //$table['退款时间'] = date('Y-m-d H:i:s', $info['tk_time']);
+                $table['操作人'] = $manage['username'];
+                return Dever::table($table);
+            }
+        }
+    }
+
+	private function search($table = 'content/article')
+	{
+		$keyword = Dever::input('keyword');
+
+        $yes = Dever::input('yes');
+
+        $where = array();
+
+        $cate = Dever::input('cate');
+        if ($cate) {
+            $where['cate_id'] = $cate;
+        }
+
+        if ($yes) {
+            $yes = Dever::db($table)->search(array('ids' => $yes));
+        }
+        if (!$keyword) {
+            $where['limit'] = '0,50';
+            $data = Dever::db($table)->search($where);
+        } else {
+            $where['name'] = $keyword;
+            $data = Dever::db($table)->search($where);
+        }
+
+        $result = array();
+        if ($yes) {
+            foreach ($yes as $k => $v) {
+                if (isset($data[$k])) {
+                    unset($data[$k]);
+                }
+                $yes[$k]['selected'] = 'selected';
+            }
+            $data = $yes + $data;
+
+            $data = array_merge($data, array());
+        } else {
+            $data = array_merge($data, array());
+        }
+
+        if (!$data) {
+            Dever::alert('暂无数据');
+        }
+
+        return $data;
+	}
+
+    # 搜索电子刊
+    public function search_journal_api()
+    {
+        return $this->search('magazine/info');
+    }
+
+    # 按照分类搜索电子刊
+    public function search_cate_journal_api()
+    {
+        $level_num = Dever::input('level_num');
+        $level_id = Dever::input('level_id');
+        
+        $auth = Dever::tops();
+        $where = array();
+        if ($level_num == 1) {
+            $default = array
+            (
+                'value' => -1,
+                'name' => '选择分类',
+            );
+            if ($auth) {
+                $where['ids'] = $auth;
+            }
+
+            $data = Dever::db('magazine/cate')->getIds($where);
+        } elseif ($level_num == 2 && $level_id > 0) {
+            $default = array
+            (
+                'value' => -1,
+                'name' => '选择电子刊',
+            );
+            if ($level_id > 0) {
+                $where['cate_id'] = $level_id;
+            } elseif ($auth) {
+                $where['cate_id'] = $auth;
+            }
+            
+            $data = Dever::db('magazine/info')->getIds($where);
+        } else {
+            return array();
+        }
+
+        
+        array_unshift($data, $default);
+        $result['level_total'] = 2;
+        $result['list'] = $data;
+        return $result;
+    }
+
+    # 显示内页
+    public function journalContent()
+    {
+        $where['info_id'] = Dever::input('search_option_info_id');
+        $where['state'] = Dever::input('search_option_state');
+        $data = Dever::db('magazine/content')->all($where);
+
+        $database = Dever::load('manage/database');
+        $type = Dever::db('magazine/content')->config['gettype'];
+        
+        if ($data) {
+            foreach ($data as $k => $v) {
+
+                $data[$k]['height'] = 'height: 154px;';
+                $data[$k]['info_height'] = 'height: auto;';
+                if ($v['type'] > 2) {
+                    $data[$k]['height'] = 'height: 104px;';
+                    $data[$k]['info_height'] = 'height: 47px;';
+                }
+                if ($v['type'] <= 2) {
+                    $data[$k]['name'] = '';
+                } elseif ($v['type'] == 3) {
+                    $data[$k]['pic'] = $v['focus'];
+                }
+
+                if ($v['type'] == 21 || $v['type'] == 22 || $v['type'] == 23) {
+                    $data[$k]['name'] = '';
+                    $data[$k]['pic'] = $v['cover'];
+                }
+
+                if ($v['type'] == 61) {
+                    # 图文
+                    $info = Dever::load('content/lib/article')->get($v['article_id']);
+                    if ($info) {
+                        $data[$k]['pic'] = $info['pic_cover'];
+                        $data[$k]['name'] = $info['name'];
+                    }
+                } elseif ($v['type'] == 62) {
+                    # 视频
+                    $info = Dever::load('video/lib/vod')->get($v['vod_id']);
+                    if ($info) {
+                        $data[$k]['pic'] = $info['pic_cover'];
+                        $data[$k]['name'] = $info['name'];
+                    }
+                } elseif ($v['type'] == 63) {
+                    # 直播
+                    $info = Dever::load('video/lib/live')->get($v['live_id']);
+                    if ($info) {
+                        $data[$k]['pic'] = $info['pic_cover'];
+                        $data[$k]['name'] = $info['name'];
+                    }
+                }
+
+                if ($v['type'] == 13) {
+                    $palaces = Dever::array_decode($v['palaces']);
+                    if (isset($palaces[0])) {
+                        $data[$k]['pic'] = $palaces[0]['pic'];
+                    }
+                }
+
+                if ($v['type'] == 41) {
+                    if ($data[$k]['talk_pic']) {
+                        $data[$k]['pic'] = $data[$k]['talk_pic'];
+                    } else {
+                        $talk = Dever::array_decode($v['talk']);
+                        if ($talk) {
+                            foreach ($talk as $tk => $tv) {
+                                if ($tv['pic']) {
+                                    $data[$k]['pic'] = $tv['pic'];
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                }
+
+                $data[$k]['typename'] = $type[$v['type']];
+
+                /*
+                if ($v['type'] == 1) {
+                    $data[$k]['text'] = $this->text($database, $v['id'], $where['info_id']);
+                } else {
+                    $data[$k]['text'] = '';
+                }
+                */
+                $data[$k]['text'] = '';
+
+                $link = $database->url('edit', $v['id']) . '&search_option_info_id=' . $where['info_id'];
+
+                $data[$k]['edit'] = "fastEdit($(this), '".$link."', '编辑内页', '', 1)";
+
+                $data[$k]['editurl'] = $link;
+
+                $data[$k]['delete'] = $database->url('delete', $v['id']);
+            }
+        }
+
+        return $data;
+    }
+
+    private function text_name($link, $content_id, $info_id, $location, $name)
+    {
+        $where['info_id'] = $info_id;
+        $where['content_id'] = $content_id;
+        $where['location'] = $location;
+        $info = Dever::db('magazine/content_text')->one($where);
+
+        $link .= '&search_option_info_id=' . $info_id. '&search_option_content_id=' . $content_id.'&table=content_text&search_option_location='.$location;
+
+        if ($info) {
+            $link .= '&where_id=' . $info['id'];
+        }
+
+        $html = '<a style="cursor:pointer;" href="javascript:;" onclick="fastEdit($(this), \''.$link.'\', \'编辑'.$name.'文字\', \'\')">'.$name.'</a>';
+
+        return $html;
+    }
+
+    public function text($database, $content_id, $info_id)
+    {
+        $link = $database->url('edit');
+
+        $location = Dever::db('magazine/content_text')->config['location'];
+
+        $html = '<table class="layui-table"><tbody><tr>';
+        $i = 0;
+        foreach ($location as $k => $v) {
+            $name = $this->text_name($link, $content_id, $info_id, $k, $v);
+            $html .= '<td>'.$name.'</td>';
+
+            if ($i == 2 || $i == 5) {
+                $html .= '</tr><tr>';
+            }
+
+            $i++;
+        }
+
+        $html .= '</tr></tbody></table>';
+
+        return $html;
+    }
+
+    public function updateJournalContent_api()
+    {
+        $data = Dever::input('data');
+
+        if ($data) {
+            $data = explode(',', str_replace('data-', '', $data));
+            foreach ($data as $k => $v) {
+                $k = $k + 1;
+                $where['where_id'] = $v;
+                $where['reorder'] = $k;
+                Dever::db('magazine/content')->update($where);
+            }
+
+        }
+
+        return $data;
+    }
+
+    public function addContent($id, $name, $data)
+    {
+        # 获取最新的reorder
+        $info_id = Dever::param('info_id', $data);
+        $data = Dever::db('magazine/content')->getAllByReorder(array('info_id' => $info_id));
+
+        if ($data) {
+            $update['where_id'] = $id;
+            $update['reorder'] = $data['reorder'] + 1;
+            Dever::db('magazine/content')->update($update);
+        }
+    }
+
+    public function getName($id)
+    {
+        $info = Dever::db('magazine/buy')->one($id);
+        if ($info && $info['name']) {
+            return $info['name'];
+        } else {
+            return '购买' . $info['num'] . '张';
+        }
+    }
+
+    public function getPrice($id)
+    {
+        $info = Dever::db('magazine/buy')->one($id);
+
+        $magazine = Dever::db('magazine/info')->one($info['info_id']);
+        if ($info && $info['price']) {
+            return $info['price'];
+        } else {
+            return $info['num'] * $magazine['cash'] . '元';
+        }
+    }
+
+    public function setJournalCache($id, $name, $param)
+    {
+        Dever::load('act/order')->setCache($id, 1);
+    }
+
+    public function setBuyCache($id, $name, $param)
+    {
+        Dever::load('act/order')->setCache($id, 2);
+    }
+
+    public function setRankingCache($id, $name, $param)
+    {
+        Dever::load('act/order')->setCache($id, 3);
+    }
+}

+ 83 - 0
src/Api.php

@@ -0,0 +1,83 @@
+<?php
+
+namespace Magazine\Src;
+
+use Dever;
+
+class Api
+{
+    public function data()
+    {
+        return Dever::db('magazine/info')->state();
+    }
+
+    public function ding($data)
+    {
+        if (isset($data['num_add_ding']) && isset($data['num_ratio_ding'])) {
+
+            if ($data['buy'] == 1) {
+            	/*
+                if (!$data['num_ding']) {
+                    $stat = Dever::db('stat/magazine')->getNumBymagazine(array('magazine_id' => $data['id']));
+                    if (!$stat) {
+                        $stat['buy_num'] = 0;
+                    }
+
+                    if (!$stat['buy_num']) {
+                        $stat['buy_num'] = 0;
+                    }
+                    $data['num_ding'] = $stat['buy_num'];
+                }
+                */
+
+                $data['num_up'] = 0;
+            }
+
+            $data['num_ding'] = $data['num_ding'] + $data['num_up'];
+            $data['buy_num'] = $data['num_ding'];
+            $data['num_ding'] = round(($data['num_ding']+$data['num_add_ding'])*$data['num_ratio_ding']);
+        }
+
+        return $data;
+    }
+
+    # 解析元信息
+    public function avinfo($data, $url = 'video', $table = 'video/vod')
+    {
+        # 解析视频元信息
+        if (!$data['video_info']) {
+            $video_info = Dever::curl($data[$url] . '?avinfo');
+            if ($video_info) {
+                Dever::db($table)->update(array('where_id' => $data['id'], 'video_info' => $video_info));
+            }
+            
+            $video_info = Dever::json_decode($video_info);
+        } else {
+            $video_info = Dever::json_decode($data['video_info']);
+        }
+
+        unset($data['video_info']);
+
+        $data['video_width'] = 0;
+        $data['video_height'] = 0;
+        # 默认横屏
+        $data['video_type'] = 1;
+        if (isset($video_info['streams']) && $video_info['streams']) {
+            foreach ($video_info['streams'] as $k => $v) {
+                if (isset($v['width']) && isset($v['height'])) {
+                    $data['video_width'] = $v['width'];
+                    $data['video_height'] = $v['height'];
+                    if ($data['video_width'] >= $data['video_height']) {
+                        $data['video_type'] = 1;
+                    } else {
+                        $data['video_type'] = 2;
+                    }
+                    
+                    break;
+                }
+            }
+        }
+
+        return $data;
+    }
+}