作者 王晓刚
1 个管道 的构建 通过 耗费 0 秒

·

  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: Administrator
  5 + * Date: 2019/1/3
  6 + * Time: 19:46
  7 + */
  8 +
  9 +namespace app\admin\controller;
  10 +
  11 +
  12 +use cmf\controller\AdminBaseController;
  13 +
  14 +use think\Db;
  15 +use think\Validate;
  16 +
  17 +class AboutController extends AdminBaseController
  18 +{
  19 + public function index(){
  20 + $data=Db::name('page')
  21 + ->where('id',4)
  22 + ->paginate(10);
  23 + $this->assign([
  24 + 'data'=>$data,
  25 + 'page'=>$data->render(),
  26 + ]);
  27 + return $this->fetch();
  28 + }
  29 + //编辑
  30 + public function edit(){
  31 + $id=$this->request->param('id', 0, 'intval');
  32 + if($this->request->isPost()){
  33 + $param=$this->request->param();
  34 + $validate = new Validate([
  35 + 'thumbnail' => 'require',
  36 + 'content' => 'require',
  37 + ]);
  38 + $validate->message([
  39 + 'thumbnail'=>'请上传缩略图!',
  40 + 'content' => '请输入页面内容!',
  41 + ]);
  42 + if (!$validate->check($param)) {
  43 + $this->error($validate->getError());
  44 + }
  45 + $param['update_time']=time();
  46 + Db::name('about')
  47 + ->where('id',$id)
  48 + ->update($param);
  49 + $this->success('更新成功!');
  50 + }else{
  51 + $data=Db::name('about')
  52 + ->where("id",$id)
  53 + ->find();
  54 + $this->assign([
  55 + 'data'=>$data,
  56 + ]);
  57 + return $this->fetch();
  58 + }
  59 + }
  60 +}
  1 +<include file="public@header"/>
  2 +</head>
  3 +<body>
  4 +<!--<script type="text/html" id="photos-item-tpl">-->
  5 +<!--<li id="saved-image{id}">-->
  6 +<!--<input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">-->
  7 +<!--<input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"-->
  8 +<!--style="width: 200px;" title="图片名称">-->
  9 +<!--<img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"-->
  10 +<!--onclick="imagePreviewDialog(this.src);">-->
  11 +<!--<a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>-->
  12 +<!--<a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>-->
  13 +<!--</li>-->
  14 +<!--</script>-->
  15 +<div class="wrap js-check-wrap">
  16 + <ul class="nav nav-tabs">
  17 + <li><a href="{:url('about/index')}">关于我们</a></li>
  18 + <li class="active"><a href="#">编辑</a></li>
  19 + </ul>
  20 + <form action="{:url('about/edit')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
  21 + <div class="row">
  22 + <div class="col-md-9">
  23 + <table class="table table-bordered">
  24 + <input type="hidden" name="id" value="{$data.id}">
  25 + <tr>
  26 + <th width="110">页面内容<span class="form-required">*</span></th>
  27 + <td>
  28 + <script type="text/plain" id="content" name="content">{:cmf_replace_content_file_url(htmlspecialchars_decode($data.content))}</script>
  29 + </td>
  30 + </tr>
  31 + <!--<tr>-->
  32 + <!--<th>相册</th>-->
  33 + <!--<td>-->
  34 + <!--<ul id="photos" class="pic-list list-unstyled form-inline">-->
  35 + <!--<notempty name="product.more.photos">-->
  36 + <!--<foreach name="product.more.photos" item="vo">-->
  37 + <!--<li id="saved-image{$key}">-->
  38 + <!--<input id="photo-{$key}" type="hidden" name="photo_urls[]"-->
  39 + <!--value="{$vo.url}">-->
  40 + <!--<input class="form-control" id="photo-{$key}-name" type="text"-->
  41 + <!--name="photo_names[]"-->
  42 + <!--value="{$vo.name|default=''}" style="width: 200px;" title="图片名称">-->
  43 + <!--<img id="photo-{$key}-preview"-->
  44 + <!--src="{:cmf_get_image_preview_url($vo['url'])}"-->
  45 + <!--style="height:36px;width: 36px;"-->
  46 + <!--onclick="parent.imagePreviewDialog(this.src);">-->
  47 + <!--<a href="javascript:uploadOneImage('图片上传','#photo-{$key}');">替换</a>-->
  48 + <!--<a href="javascript:(function(){$('#saved-image{$key}').remove();})();">移除</a>-->
  49 + <!--</li>-->
  50 + <!--</foreach>-->
  51 + <!--</notempty>-->
  52 + <!--</ul>-->
  53 + <!--<a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"-->
  54 + <!--class="btn btn-sm btn-default">选择图片</a>-->
  55 + <!--</td>-->
  56 + <!--</tr>-->
  57 + </table>
  58 + <div class="form-group">
  59 + <div class="col-sm-offset-2 col-sm-10">
  60 + <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
  61 + <a class="btn btn-default" href="{:url('about/index')}">{:lang('BACK')}</a>
  62 + </div>
  63 + </div>
  64 + </div>
  65 + <div class="col-md-3">
  66 + <table class="table table-bordered">
  67 + <tr>
  68 + <th>缩略图<span class="form-required">*</span></th>
  69 + </tr>
  70 + <tr>
  71 + <td>
  72 + <div style="text-align: center;">
  73 + <input type="hidden" name="thumbnail" id="thumbnail"
  74 + value="{$data.thumbnail|default=''}">
  75 + <a href="javascript:uploadOneImage('image upload','#thumbnail');">
  76 + <if condition="empty($data['thumbnail'])">
  77 + <img src="__TMPL__/public/assets/images/default-thumbnail.png"
  78 + id="thumbnail-preview"
  79 + width="135" style="cursor: pointer"/>
  80 + <else/>
  81 + <img src="{:cmf_get_image_url($data.thumbnail)}"
  82 + id="thumbnail-preview"
  83 + width="135" style="cursor: pointer"/>
  84 + </if>
  85 + </a>
  86 + <input type="button" class="btn btn-sm btn-cancel-thumbnail"
  87 + value="取消图片">
  88 + </div>
  89 + </td>
  90 + </tr>
  91 + </table>
  92 + </div>
  93 + </div>
  94 + </form>
  95 +</div>
  96 +<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
  97 +<script type="text/javascript">
  98 + //编辑器路径定义
  99 + var editorURL = GV.WEB_ROOT;
  100 +</script>
  101 +<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
  102 +<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
  103 +<script type="text/javascript">
  104 + $(function () {
  105 +
  106 + editorcontent = new baidu.editor.ui.Editor();
  107 + editorcontent.render('content');
  108 + try {
  109 + editorcontent.sync();
  110 + } catch (err) {
  111 + }
  112 +
  113 + $('.btn-cancel-thumbnail').click(function () {
  114 + $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
  115 + $('#thumbnail').val('');
  116 + });
  117 +
  118 + });
  119 +</script>
  120 +</body>
  121 +</html>
  1 +<include file="public@header" />
  2 +</head>
  3 +<body>
  4 +<div class="wrap js-check-wrap">
  5 + <ul class="nav nav-tabs">
  6 + <li class="active"><a href="{:url('about/index')}">关于我们</a></li>
  7 + </ul>
  8 + <form class="js-ajax-form" action="" method="post">
  9 + <table class="table table-hover table-bordered">
  10 + <div class="table-actions">
  11 + <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"-->
  12 + <!--data-action="{:url('Appraise/sort')}">{:lang('SORT')}-->
  13 + <!--</button>-->
  14 + <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"-->
  15 + <!--data-action="{:url('Appraise/publish',array('yes'=>1))}" data-subcheck="true">发布-->
  16 + <!--</button>-->
  17 + <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"-->
  18 + <!--data-action="{:url('Appraise/publish',array('no'=>1))}" data-subcheck="true">取消发布-->
  19 + <!--</button>-->
  20 + <!--<button class="btn btn-danger btn-sm js-ajax-submit"-->
  21 + <!--data-action="{:url('Logistics/delete')}" data-subcheck="true" data-msg="你确定删除吗?">-->
  22 + <!--{:lang('DELETE')}-->
  23 + <!--</button>-->
  24 + </div>
  25 + <thead>
  26 + <tr>
  27 + <!--<th width="20">ID</th>-->
  28 + <th width="20">缩略图</th>
  29 + <th width="50">页面内容</th>
  30 + <th width="30">更新时间</th>
  31 + <th width="30">操作</th>
  32 + </tr>
  33 + </thead>
  34 + <tbody>
  35 + <foreach name="data" item="vo">
  36 + <tr>
  37 + <!--<td>{$vo.id}</td>-->
  38 + <td>
  39 + <notempty name="$vo.thumbnail">
  40 + <a href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo.thumbnail)}');">
  41 + <i class="fa fa-photo fa-fw"></i>
  42 + </a>
  43 + </notempty>
  44 + </td>
  45 + <td>{:cmf_replace_content_file_url(htmlspecialchars_decode($vo.content))}</td>
  46 + <td>{:date('Y-m-d H:i:s',$vo['update_time'])}</td>
  47 + <td>
  48 + <a href='{:url("about/edit",array("id"=>$vo["id"]))}'>{:lang('EDIT')}</a>
  49 + </td>
  50 + </tr>
  51 + </foreach>
  52 + </tbody>
  53 + </table>
  54 + <div class="pagination">{$page|default=''}</div>
  55 + </form>
  56 +</div>
  57 +<script src="__STATIC__/js/admin.js"></script>
  58 +</body>
  59 +</html>