sgd521 2 years ago
parent
commit
cfd13fd8e1

+ 37 - 0
application/admin/controller/Xitong.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\common\controller\Backend;
+
+/**
+ * 系统文件管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Xitong extends Backend
+{
+
+    /**
+     * Xitong模型对象
+     * @var \app\admin\model\Xitong
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\Xitong;
+
+    }
+
+
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+
+
+}

+ 6 - 0
application/admin/lang/zh-cn/xitong.php

@@ -0,0 +1,6 @@
+<?php
+
+return [
+    'Title'   => '标题',
+    'Content' => '内容'
+];

+ 40 - 0
application/admin/model/Xitong.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class Xitong extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'xitong';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+}

+ 27 - 0
application/admin/validate/Xitong.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\admin\validate;
+
+use think\Validate;
+
+class Xitong extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'add'  => [],
+        'edit' => [],
+    ];
+    
+}

+ 22 - 0
application/admin/view/xitong/add.html

@@ -0,0 +1,22 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <textarea id="c-content" data-rule="required" class="form-control editor" rows="5" name="row[content]" cols="50"></textarea>
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 22 - 0
application/admin/view/xitong/edit.html

@@ -0,0 +1,22 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <textarea id="c-content" data-rule="required" class="form-control editor" rows="5" name="row[content]" cols="50">{$row.content|htmlentities}</textarea>
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 35 - 0
application/admin/view/xitong/index.html

@@ -0,0 +1,35 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('xitong/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('xitong/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('xitong/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        
+
+                        <div class="dropdown btn-group {:$auth->check('xitong/multi')?'':'hide'}">
+                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
+                            <ul class="dropdown-menu text-left" role="menu">
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
+                            </ul>
+                        </div>
+
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-edit="{:$auth->check('xitong/edit')}"
+                           data-operate-del="{:$auth->check('xitong/del')}"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 7 - 0
application/api/controller/Index.php

@@ -3,6 +3,7 @@
 namespace app\api\controller;
 
 use app\admin\model\Banner;
+use app\admin\model\Xitong;
 use app\common\controller\Api;
 
 /**
@@ -36,5 +37,11 @@ class Index extends Api
         $list = $banner->where('status', 1)->order('weigh', 'DESC')->select();
         $this->success('轮播图', $list);
     }
+    public function xieyi()
+    {
+        $xitong_model = new Xitong();
+        $info = $xitong_model->where('id',1)->find();
+        $this->success('用户协议',$info);
+    }
 }
 

+ 5 - 1
application/extra/addons.php

@@ -2,7 +2,11 @@
 
 return [
     'autoload' => false,
-    'hooks' => [],
+    'hooks' => [
+        'config_init' => [
+            'summernote',
+        ],
+    ],
     'route' => [],
     'priority' => [],
     'domain' => '',

+ 117 - 1
public/assets/js/addons.js

@@ -1,3 +1,119 @@
 define([], function () {
-    
+    require.config({
+    paths: {
+        'summernote': '../addons/summernote/lang/summernote-zh-CN.min'
+    },
+    shim: {
+        'summernote': ['../addons/summernote/js/summernote.min', 'css!../addons/summernote/css/summernote.css'],
+    }
+});
+require(['form', 'upload'], function (Form, Upload) {
+    var _bindevent = Form.events.bindevent;
+    Form.events.bindevent = function (form) {
+        _bindevent.apply(this, [form]);
+        try {
+            //绑定summernote事件
+            if ($(Config.summernote.classname || '.editor', form).size() > 0) {
+                var selectUrl = typeof Config !== 'undefined' && Config.modulename === 'index' ? 'user/attachment' : 'general/attachment/select';
+                require(['summernote'], function () {
+                    var imageButton = function (context) {
+                        var ui = $.summernote.ui;
+                        var button = ui.button({
+                            contents: '<i class="fa fa-file-image-o"/>',
+                            tooltip: __('Choose'),
+                            click: function () {
+                                parent.Fast.api.open(selectUrl + "?element_id=&multiple=true&mimetype=image/", __('Choose'), {
+                                    callback: function (data) {
+                                        var urlArr = data.url.split(/\,/);
+                                        $.each(urlArr, function () {
+                                            var url = Fast.api.cdnurl(this, true);
+                                            context.invoke('editor.insertImage', url);
+                                        });
+                                    }
+                                });
+                                return false;
+                            }
+                        });
+                        return button.render();
+                    };
+                    var attachmentButton = function (context) {
+                        var ui = $.summernote.ui;
+                        var button = ui.button({
+                            contents: '<i class="fa fa-file"/>',
+                            tooltip: __('Choose'),
+                            click: function () {
+                                parent.Fast.api.open(selectUrl + "?element_id=&multiple=true&mimetype=*", __('Choose'), {
+                                    callback: function (data) {
+                                        var urlArr = data.url.split(/\,/);
+                                        $.each(urlArr, function () {
+                                            var url = Fast.api.cdnurl(this, true);
+                                            var node = $("<a href='" + url + "'>" + url + "</a>");
+                                            context.invoke('insertNode', node[0]);
+                                        });
+                                    }
+                                });
+                                return false;
+                            }
+                        });
+                        return button.render();
+                    };
+                    $(Config.summernote.classname || '.editor', form).each(function () {
+                        $(this).summernote($.extend(true, {}, {
+                            height: 250,
+                            lang: 'zh-CN',
+                            fontNames: [
+                                'Arial', 'Arial Black', 'Serif', 'Sans', 'Courier',
+                                'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande',
+                                "Open Sans", "Hiragino Sans GB", "Microsoft YaHei",
+                                '微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆',
+                            ],
+                            fontNamesIgnoreCheck: [
+                                "Open Sans", "Microsoft YaHei",
+                                '微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆'
+                            ],
+                            toolbar: [
+                                ['style', ['style', 'undo', 'redo']],
+                                ['font', ['bold', 'underline', 'strikethrough', 'clear']],
+                                ['fontname', ['color', 'fontname', 'fontsize']],
+                                ['para', ['ul', 'ol', 'paragraph', 'height']],
+                                ['table', ['table', 'hr']],
+                                ['insert', ['link', 'picture', 'video']],
+                                ['select', ['image', 'attachment']],
+                                ['view', ['fullscreen', 'codeview', 'help']],
+                            ],
+                            buttons: {
+                                image: imageButton,
+                                attachment: attachmentButton,
+                            },
+                            dialogsInBody: true,
+                            followingToolbar: false,
+                            callbacks: {
+                                onChange: function (contents) {
+                                    $(this).val(contents);
+                                    $(this).trigger('change');
+                                },
+                                onInit: function () {
+                                },
+                                onImageUpload: function (files) {
+                                    var that = this;
+                                    //依次上传图片
+                                    for (var i = 0; i < files.length; i++) {
+                                        Upload.api.send(files[i], function (data) {
+                                            var url = Fast.api.cdnurl(data.url, true);
+                                            $(that).summernote("insertImage", url, 'filename');
+                                        });
+                                    }
+                                }
+                            }
+                        }, $(this).data("summernote-options") || {}));
+                    });
+                });
+            }
+        } catch (e) {
+
+        }
+
+    };
+});
+
 });

+ 51 - 0
public/assets/js/backend/xitong.js

@@ -0,0 +1,51 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'xitong/index' + location.search,
+                    add_url: 'xitong/add',
+                    edit_url: 'xitong/edit',
+                    del_url: 'xitong/del',
+                    multi_url: 'xitong/multi',
+                    import_url: 'xitong/import',
+                    table: 'xitong',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'title', title: __('Title'), operate: 'LIKE'},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});

+ 5 - 0
public/nginx.htaccess

@@ -0,0 +1,5 @@
+location / {
+   if (!-e $request_filename){
+      rewrite  ^(.*)$  /index.php?s=$1  last;   break;
+   }
+}