浏览代码

轮播跳转链接

lizhen_gitee 4 天之前
父节点
当前提交
86e59f6412

+ 30 - 3
application/admin/controller/Banner.php

@@ -32,10 +32,37 @@ class Banner extends Backend
     }
 
     /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     * 查看
      */
+    public function index()
+    {
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+            $list = $this->model
+                ->where($where)
+                ->order($sort, $order)
+                ->paginate($limit);
+
+            $list2 = collection($list->items())->toArray();
+            foreach($list2 as $key => &$val){
+                if(!empty($val['url'])){
+                    $val['url'] = config('pay_notify_url').'/index/index/banner?id='.$val['url'];
+                }
+            }
+
+            $result = array("total" => $list->total(), "rows" => $list2);
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
     
 
 }

+ 1 - 1
application/admin/lang/zh-cn/banner.php

@@ -4,7 +4,7 @@ return [
     'Id'         => '主键ID',
     'Title'      => '标题',
     'Image'      => '图片',
-    'Url'        => '链接地址',
+    'Url'        => '跳转基础协议ID',
     'Type'       => '类型',
     'Type 1'     => '首页',
     'Type 2'     => '消息页',

+ 2 - 2
application/admin/view/banner/add.html

@@ -20,12 +20,12 @@
             <ul class="row list-inline faupload-preview" id="p-image"></ul>
         </div>
     </div>
-    <!--<div class="form-group">
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Url')}:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-url" data-rule="required" class="form-control" name="row[url]" type="text" value="">
         </div>
-    </div>-->
+    </div>
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
         <div class="col-xs-12 col-sm-8">

+ 2 - 2
application/admin/view/banner/edit.html

@@ -20,12 +20,12 @@
             <ul class="row list-inline faupload-preview" id="p-image"></ul>
         </div>
     </div>
-    <!--<div class="form-group">
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Url')}:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-url" data-rule="required" class="form-control" name="row[url]" type="text" value="{$row.url|htmlentities}">
         </div>
-    </div>-->
+    </div>
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
         <div class="col-xs-12 col-sm-8">

+ 8 - 1
application/api/controller/Index.php

@@ -130,11 +130,18 @@ class Index extends Api
 
     //轮播图
     public function banner() {
-        $type = input('type', 0, 'intval'); //类型:0=交友轮播图,1=动态轮播图
+        $type = input('type', 1, 'intval');
 
         $list = Db::name('banner')->field('id, title, image, url')->where(['status' => 1, 'type' => $type])->order('weigh', 'desc')->select();
 
         $list = list_domain_image($list, ['image']);
+
+        foreach($list as $key => &$val){
+            if(!empty($val['url'])){
+                $val['url'] = config('pay_notify_url').'/index/index/banner?id='.$val['url'];
+            }
+        }
+
         $this->success('轮播图', $list);
     }
 

+ 11 - 0
application/index/controller/Index.php

@@ -114,5 +114,16 @@ class Index extends Frontend
         $this->assign('content',$content['content']);
         return $this->fetch();
     }
+    //基础文档网页
+    //给轮播用的
+    public function banner(){
+        $key = input('id','');
+        if(!$key){
+            exit;
+        }
+        $content = Db::name('basedata')->where('id',$key)->find();
+        $this->assign('content',$content['content']);
+        return $this->fetch('basedata');
+    }
 
 }

+ 1 - 1
public/assets/js/backend/banner.js

@@ -28,7 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'id', title: __('Id')},
                         {field: 'title', title: __('Title'), operate: 'LIKE'},
                         {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
-//                        {field: 'url', title: __('Url'), operate: 'LIKE', formatter: Table.api.formatter.url},
+                        {field: 'url', title: __('Url'), operate: 'LIKE'},
                         {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
                         {field: 'weigh', title: __('Weigh'), operate: false},
                         {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},