dever 4 years ago
parent
commit
8b9db6bd56

+ 97 - 0
app/content/database/creater_xuniren.php

@@ -0,0 +1,97 @@
+<?php
+
+$status = array(
+    1 => '已登场',
+    2 => '未登场',
+);
+
+return array
+(
+    # 表名
+    'name' => 'creater_xuniren',
+    # 显示给用户看的名称
+    'lang' => '造物主虚拟人关联表',
+    'order' => 1,
+    'menu'  => false,
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'list'      => true,
+        ),
+        
+        'cid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '造物主id',
+            'default'   => '',
+            'desc'      => '造物主id',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'xid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '虚拟人id',
+            'default'   => '',
+            'desc'      => '虚拟人id',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            '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,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+            'search'    => 'date',
+        ),
+    ),
+    
+    # 管理功能
+    'manage' => array
+    (
+
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'cid' => 'yes',
+                'xid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);

+ 23 - 1
app/content/database/xuniren.php

@@ -44,6 +44,20 @@ return array
         'update' => 'content/lib/manage.updateXnr',
     ),
 
+    # 同步更新另外一个或多个表的多条关联数据,以逗号隔开
+    'sync' => array
+    (
+        'content/creater_xuniren' => array
+        (
+            # 更新时的条件,另外一个表的字段 => 本表的字段
+            'where' => array('xid', 'id'),
+            # 要更新的数据
+            'update' => array('cid' => 'creater_ids'),
+            # 同步更新的类型,delete为先删再插入,update为先查询是否存在,存在直接更新,不存在则插入, only为仅更新
+            'type' => 'delete',
+        )
+    ),
+
     # 数据结构
     'struct' => array
     (
@@ -157,8 +171,16 @@ return array
             'desc'      => '造物主',
             'match'     => 'option',
             'update'    => 'text',
-            'option'    => $creater,
+            
             'search'    => 'select',
+            'search'    => array
+            (
+                'api' => 'content/creater_xuniren-all',//接口地址,最好是获取多条数据的地址
+                'col' => 'cid',//要查询的字段
+                'result' => 'xid',//返回的字段
+                'search' => 'id',//本表的字段,默认为当前的字段
+                'option'    => $creater,
+            ),
             //如果要输入带有自动提示的,就打开这个,update=>'text'即可
             'autocomplete' => array('content/lib/manage.getByCreaterName', 'id', 'content/creater-getData'),
             //'list'        => true,

+ 29 - 9
app/content/lib/Xuniren.php

@@ -28,19 +28,26 @@ class Xuniren
     {
         $where = array();
 
-        $where['creater_id'] = $creater_id;
-        $data = Dever::db('content/xuniren')->getDataByCreater($where);
+        //$where['creater_id'] = $creater_id;
+        //$data = Dever::db('content/xuniren')->getDataByCreater($where);
+        $where['cid'] = $creater_id;
+        $data = Dever::db('content/creater_xuniren')->getAll($where);
 
+        $result = array();
         if ($data) {
             foreach ($data as $k => $v) {
-                $data[$k]['sname'] = $v['name'] . ' / ' . $v['ename'];
-                $data[$k]['link'] = Dever::url('main/xnr-detail?id=' . $v['id']);
-                $data[$k]['info'] = '<span>简介</span> ' . $v['info'];
-                $data[$k] = $this->getPic($v);
+                $info = Dever::db('content/xuniren')->one($v['xid']);
+                if ($info) {
+                    $info['sname'] = $info['name'] . ' / ' . $info['ename'];
+                    $info['link'] = Dever::url('main/xnr-detail?id=' . $info['id']);
+                    $info['info'] = '<span>简介</span> ' . $info['info'];
+                    $info = $this->getPic($info);
+                    $result[] = $info;
+                }
             }
         }
 
-        return $data;
+        return $result;
     }
 
     private function getPic($data)
@@ -82,8 +89,21 @@ class Xuniren
 
             $data['pdate'] = date('Y/m/d', $data['pdate']);
 
-            $data['creater'] = Dever::db('content/creater')->one($data['creater_id']);
-            $data['creater_name'] = $data['creater']['desc'];
+            $data['creater_name'] = '';
+            $creater_name = array();
+            $where['xid'] = $data['id'];
+            $info = Dever::db('content/creater_xuniren')->getAll($where);
+            if ($info) {
+                foreach ($info as $k => $v) {
+                    $creater = Dever::db('content/creater')->one(array('id' => $v['cid']));
+                    if ($creater) {
+                        $creater_name[] = $creater['desc'];
+                    }
+                }
+                if ($creater_name) {
+                    $data['creater_name'] = implode(' & ', $creater_name);
+                }
+            }
         }
 
         return $data;

+ 9 - 1
app/push/lib/Data.php

@@ -60,6 +60,14 @@ class Data
             $id = $info[$id];
             unset($info[$id]);
             if ($id > 0) {
+                if ($info['type'] >= 3) {
+                    $info['link'] = Dever::url('main/article?type='.($info['type']-2).'&id=' . $id);
+                } elseif ($info['type'] == 1) {
+                    $info['link'] = Dever::url('main/xnr-detail?id=' . $id);
+                } elseif ($info['type'] == 2) {
+                    $info['link'] = Dever::url('main/zwz-detail?id=' . $id);
+                }
+
                 $info['id'] = $id;
                 $data = Dever::db($table)->$method($id);
                 if (isset($data) && $data) {
@@ -87,7 +95,7 @@ class Data
                         $info['pic'] = $data['pic'];
                     }
 
-                    if (isset($data['link']) && $data['link']) {
+                    if (isset($data['link']) && $data['link'] && !$info['link']) {
                         $info['link'] = $data['link'];
                     }
 

+ 4 - 4
app/push/lib/Manage.php

@@ -18,13 +18,13 @@ class Manage
         if ($info['type'] < 10) {
             $table = Dever::config('base')->table_name[$info['type']];
             $id = str_replace('content/', '', $table) . '_id';
-            $audit = array
+            $where = array
             (
-                'status' => 2,
+                'status' => 1,
                 'state' => 1,
             );
-            $audit['id'] = $info[$id];
-            $data = Dever::db($table)->one($audit);
+            $where['id'] = $info[$id];
+            $data = Dever::db($table)->one($where);
 
             if (isset($data) && $data && isset($data[$col])) {
                 return $data[$col];

+ 3 - 3
main/assets/xuniren/xnr-detail.html

@@ -89,17 +89,17 @@
 			<div class="swiper-container">
 				<div class="swiper-wrapper clearfix">
 					<div class="swiper-slide">
-						<a href="#" target="_blank" title="">
+						<a href="#" targets="_blank" title="">
 							<img src="images/profile.jpg?v=cdd9da6c" alt="" title="">
 						</a>
 					</div>
 					<div class="swiper-slide">
-						<a href="#" target="_blank" title="">
+						<a href="#" targets="_blank" title="">
 							<img src="images/profile.jpg?v=cdd9da6c" alt="" title="">
 						</a>
 					</div>
 					<div class="swiper-slide">
-						<a href="#" target="_blank" title="">
+						<a href="#" targets="_blank" title="">
 							<img src="images/profile.jpg?v=cdd9da6c" alt="" title="">
 						</a>
 					</div>

+ 16 - 2
main/src/Content.php

@@ -158,6 +158,7 @@ class Content
         }
 
         if ($data) {
+            $data[0]['sname'] = '<a href="'.$data[0]['link'].'">'.$data[0]['sname'].'</a>';
             return $data[0];
         }
 
@@ -232,6 +233,7 @@ class Content
         $data = Dever::load('main/content.view');
         $result = array();
         if ($data['tag']) {
+            $tag = '';
             if (strstr($data['tag'], ',')) {
                 $tag = explode(',', $data['tag']);
             } elseif (strstr($data['tag'], ',')) {
@@ -404,6 +406,18 @@ class Content
         return array();
     }
 
+    # 虚拟人信息 多个图片
+    public function getXnrOne_pic()
+    {
+        $data = Dever::load('main/content.getXnrOne');
+
+        if ($data && isset($data['pic_list']) && $data['pic_list']) {
+            return $data['pic_list'];
+        }
+
+        return array();
+    }
+
     # 获取虚拟人列表
     public function getXnr()
     {
@@ -415,7 +429,7 @@ class Content
             $html .= '<dl id="'.$k.'"><dt>' . $k . '</dt><dd>';
 
             foreach ($v as $k1 => $v1) {
-                $url = Dever::url('xnr-detail?id=' . $v1['id']);
+                $url = Dever::url('main/xnr-detail?id=' . $v1['id']);
                 $html .= '<a href="'.$url.'">'.$v1['name'].' / '.$v1['ename'].'</a>';
             }
 
@@ -436,7 +450,7 @@ class Content
             $html .= '<dl id="'.$k.'"><dt>' . $k . '</dt><dd>';
 
             foreach ($v as $k1 => $v1) {
-                $url = Dever::url('zwz-detail?id=' . $v1['id']);
+                $url = Dever::url('main/zwz-detail?id=' . $v1['id']);
                 $html .= '<a href="'.$url.'">'.$v1['name'].' / '.$v1['desc'].'</a>';
             }
 

+ 1 - 1
main/template/xuniren/inc/head.php

@@ -5,7 +5,7 @@ $view
 ->fetch('meta[name="Keywords"]@content',                    '<{isset($keywords) ? Dever::load("main/content.config#keywords") . "," . $keywords : Dever::load("main/content.config#keywords")}>')
 ->fetch('meta[name="Description"]@content',                    '<{isset($info) ? Dever::load("main/content.config#info") . "," . $info : Dever::load("main/content.config#info")}>')
 ->fetch('.logo img@src',                    'main/content.config#logo')
-->fetch('.logo img@style',                    'width:100px')
+//->fetch('.logo img@style',                    'width:100px')
 
 # 登录
 //->fetch('.menu', 'main/content.user')

+ 21 - 1
main/template/xuniren/xnr-detail.php

@@ -9,7 +9,27 @@ $view
 
 ->fetch('body@test', '1')
 
-->fetch(array('.avatar img@src', 0), 'main/content.getXnrOne#pic')
+//->fetch(array('.avatar img@src', 0), 'main/content.getXnrOne#pic')
+
+->loop
+(
+    '.swiper-container .swiper-slide',
+    'main/content.getXnrOne_pic',
+    array
+    (
+        'a' => array
+        (
+            'img' => array
+            (
+                'src' => '$v',
+            ),
+
+            'href' => 'javascript:;',
+        ),
+        
+    )
+)
+
 ->fetch(array('.xnr-profile dt', 0), 'main/content.getXnrOne#sname')
 
 ->fetch(array('.xnr-profile b', 0), 'main/content.getXnrOne#sex')