作者 jinglong

增加首页内容管理

<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use app\portal\model\AboutModel;
use app\portal\model\PortalPostModel;
use cmf\controller\AdminBaseController;
class AdminAboutController extends AdminBaseController
{
//关于我们
//编辑页面
public function edit(){
$aboutModel = new AboutModel();
$post = $aboutModel->where('id',1)->find();
$contentModel = new PortalPostModel();
$post['detail'] = $contentModel->getPostContentAttr($post['detail']);
$post['detail_en'] = $contentModel->getPostContentAttr($post['detail_en']);
$this->assign('post',$post);
return $this->fetch();
}
//编辑提交
public function editPost(){
$data = $this->request->param();
$result = $this->validate($data, 'AdminAbout.edit');
if ($result !== true) {
$this->error($result);
}
$aboutModel = new AboutModel();
// 显式指定更新数据操作
$contentModel = new PortalPostModel();
$data['detail'] = $contentModel->setPostContentAttr($data['detail']);
$data['detail_en'] = $contentModel->setPostContentAttr($data['detail_en']);
$res = $aboutModel->isUpdate(true)->save($data);
if($res){
$this->success('保存成功!');
}else{
$this->error('失败');
}
}
}
... ...
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use app\portal\model\AdvantageModel;
use cmf\controller\AdminBaseController;
use think\Db;
class AdminAdvantageController extends AdminBaseController
{
//我们优势
//列表
public function index(){
$res = Db::name('advantage')
->order('id desc')
->paginate(10);
$data = $res->toArray();
$data = $data['data'];
$page = $res->render();
$this->assign('list',$data);
$this->assign('page',$page);
return $this->fetch();
}
//添加页面
public function add(){
return $this->fetch();
}
//添加提交
public function addPost(){
$data = $this->request->param();
$result = $this->validate($data, 'AdminAdvantage.add');
if ($result !== true) {
$this->error($result);
}
$advantageModel = new AdvantageModel();
$res = $advantageModel->create($data);
if($res){
$this->success('添加成功!', url('AdminAdvantage/index'));
}else{
$this->error('失败');
}
}
//编辑页面
public function edit(){
$id = $this->request->param('id');
$post = Db::name('advantage')
->where(['id'=>$id])
->find();
$this->assign('post',$post);
return $this->fetch();
}
//编辑提交
public function editPost(){
$data = $this->request->param();
$result = $this->validate($data, 'AdminAdvantage.edit');
if ($result !== true) {
$this->error($result);
}
$advantageModel = new AdvantageModel();
// 显式指定更新数据操作
$res = $advantageModel->isUpdate(true)->save($data);
if($res){
$this->success('保存成功!', url('AdminAdvantage/index'));
}else{
$this->error('失败');
}
}
//删除
public function delete(){
$id = $this->request->param('id');
$advantageModel = new AdvantageModel();
$res = $advantageModel->where(['id'=>$id])->delete();
if($res){
$this->success('删除成功!');
}else{
$this->error('失败');
}
}
}
... ...
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use app\portal\model\RotationModel;
use cmf\controller\AdminBaseController;
use think\Db;
class AdminRotationController extends AdminBaseController
{
//轮播图
//列表
public function index(){
$res = Db::name('rotation')
->order('id desc')
->paginate(10);
$data = $res->toArray();
$data = $data['data'];
$page = $res->render();
$this->assign('list',$data);
$this->assign('page',$page);
return $this->fetch();
}
//添加页面
public function add(){
return $this->fetch();
}
//添加提交
public function addPost(){
$data = $this->request->param();
$result = $this->validate($data, 'AdminRotation.add');
if ($result !== true) {
$this->error($result);
}
$rotationModel = new RotationModel();
$res = $rotationModel->create($data);
if($res){
$this->success('添加成功!', url('AdminRotation/index'));
}else{
$this->error('失败');
}
}
//编辑页面
public function edit(){
$id = $this->request->param('id');
$post = Db::name('rotation')
->where(['id'=>$id])
->find();
$this->assign('post',$post);
return $this->fetch();
}
//编辑提交
public function editPost(){
$data = $this->request->param();
$result = $this->validate($data, 'AdminRotation.edit');
if ($result !== true) {
$this->error($result);
}
$rotationModel = new RotationModel();
// 显式指定更新数据操作
$res = $rotationModel->isUpdate(true)->save($data);
if($res){
$this->success('保存成功!', url('AdminRotation/index'));
}else{
$this->error('失败');
}
}
//删除
public function delete(){
$id = $this->request->param('id');
$rotationModel = new RotationModel();
$res = $rotationModel->where(['id'=>$id])->delete();
if($res){
$this->success('删除成功!');
}else{
$this->error('失败');
}
}
}
... ...
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\model;
use think\Model;
class AboutModel extends Model
{
protected $autoWriteTimestamp = true;
}
\ No newline at end of file
... ...
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\model;
use think\Model;
class AdvantageModel extends Model
{
protected $autoWriteTimestamp = true;
}
\ No newline at end of file
... ...
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\model;
use think\Model;
class RotationModel extends Model
{
protected $autoWriteTimestamp = true;
}
\ No newline at end of file
... ...
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\validate;
use think\Validate;
class AdminAboutValidate extends Validate
{
protected $rule = [
'thumbnail' => 'require',
'introduce' => 'require',
'introduce_en' => 'require',
'detail' => 'require',
'detail_en' => 'require',
'video' => 'require',
];
protected $message = [
'thumbnail.require' => '请上传缩略图',
'introduce.require' => '简介不能为空',
'introduce_en.require' => '简介(英文)不能为空',
'detail.require' => '详情不能为空',
'detail_en.require' => '详情(英文)不能为空',
'video.require' => '请上传视频',
];
protected $scene = [
'edit' => ['thumbnail','introduce','introduce_en','detail','detail_en','video'],
];
}
\ No newline at end of file
... ...
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\validate;
use think\Validate;
class AdminAdvantageValidate extends Validate
{
protected $rule = [
'title' => 'require|max:40',
'title_en' => 'require|max:40',
'introduce' => 'require|max:500',
'introduce_en' => 'require|max:500',
];
protected $message = [
'title.require' => '标题不能为空',
'title.max' => '标题不能超多40个字符',
'title_en.require' => '标题(英文)不能为空',
'title_en.max' => '标题(英文)不能超多40个字符',
'introduce.require' => '简介不能为空',
'introduce.max' => '简介不能超多500个字符',
'introduce_en.require' => '简介(英文)不能为空',
'introduce_en.max' => '简介(英文)不能超多500个字符',
];
protected $scene = [
'add' => ['title','title_en','introduce','introduce_en'],
'edit' => ['title','title_en','introduce','introduce_en'],
];
}
\ No newline at end of file
... ...
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\validate;
use think\Validate;
class AdminRotationValidate extends Validate
{
protected $rule = [
'link' => 'require',
'thumbnail' => 'require',
];
protected $message = [
'link.require' => '链接不能为空',
'thumbnail.require' => '请上传轮播图',
];
protected $scene = [
'add' => ['link','thumbnail'],
'edit' => ['link','thumbnail'],
];
}
\ No newline at end of file
... ...
<include file="public@header"/>
<style type="text/css">
.pic-list li {
margin-bottom: 5px;
}
</style>
<script type="text/html" id="photos-item-tpl">
<li id="saved-image{id}">
<input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
<input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
style="width: 200px;" title="图片名称">
<img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
onclick="imagePreviewDialog(this.src);">
<a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
<a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
</li>
</script>
<script type="text/html" id="files-item-tpl">
<li id="saved-file{id}">
<input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
<input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
style="width: 200px;" title="文件名称">
<a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
<a href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
<a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
</li>
</script>
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li class="active"><a href="#">编辑关于我们</a></li>
</ul>
<form action="{:url('AdminAbout/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
<div class="row">
<div class="col-md-9">
<table class="table table-bordered">
<tr>
<th width="150">简介<span class="form-required">*</span></th>
<td>
<input id="post-id" type="hidden" name="id" value="{$post.id}">
<textarea rows="5" class="form-control" name="introduce" required placeholder="请输入简介">{$post.introduce}</textarea>
</td>
</tr>
<tr>
<th>简介(英文)<span class="form-required">*</span></th>
<td>
<textarea rows="5" class="form-control" name="introduce_en" required placeholder="请输入简介">{$post.introduce_en}</textarea>
</td>
</tr>
<tr>
<th>详情<span class="form-required">*</span></th>
<td>
<script type="text/plain" id="content" name="detail">{$post.detail}</script>
</td>
</tr>
<tr>
<th>详情(英文)<span class="form-required">*</span></th>
<td>
<script type="text/plain" id="content_en" name="detail_en">{$post.detail_en}</script>
</td>
</tr>
<tr>
<th>视频<span class="form-required">*</span></th>
<td class="form-inline">
<input id="file-video" class="form-control" type="text" name="video" value="{$post.video|default=''}" placeholder="请上传视频文件" style="width: 400px;">
<notempty name="post.video">
<a id="file-video-preview" href="{:cmf_get_file_download_url($post.video)}"
target="_blank">下载</a>
</notempty>
<a href="javascript:uploadOne('文件上传','#file-video','video');">上传</a>
</td>
</tr>
</table>
</div>
<div class="col-md-3">
<table class="table table-bordered">
<tr>
<th>缩略图<span class="form-required">*</span></th>
</tr>
<tr>
<td>
<div style="text-align: center;">
<input type="hidden" name="thumbnail" id="thumbnail" value="{$post.thumbnail|default=''}">
<a href="javascript:uploadOneImage('图片上传','#thumbnail');">
<if condition="empty($post.thumbnail)">
<img src="__TMPL__/public/assets/images/default-thumbnail.png" id="thumbnail-preview" width="135" style="cursor: pointer"/>
<else/>
<img src="{:cmf_get_image_preview_url($post.thumbnail)}" id="thumbnail-preview" width="135" style="cursor: pointer"/>
</if>
</a>
<input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
</div>
</td>
</tr>
</table>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
</div>
</div>
</form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
//编辑器路径定义
var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
$(function () {
editorcontent = new baidu.editor.ui.Editor();
editorcontent.render('content');
try {
editorcontent.sync();
} catch (err) {
}
editorcontent = new baidu.editor.ui.Editor();
editorcontent.render('content_en');
try {
editorcontent.sync();
} catch (err) {
}
$('.btn-cancel-thumbnail').click(function () {
$('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnail').val('');
});
});
</script>
</body>
</html>
... ...
<include file="public@header"/>
<style type="text/css">
.pic-list li {
margin-bottom: 5px;
}
</style>
<script type="text/html" id="photos-item-tpl">
<li id="saved-image{id}">
<input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
<input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
style="width: 200px;" title="图片名称">
<img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
onclick="imagePreviewDialog(this.src);">
<a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
<a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
</li>
</script>
<script type="text/html" id="files-item-tpl">
<li id="saved-file{id}">
<input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
<input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
style="width: 200px;" title="文件名称">
<a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
<a href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
<a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
</li>
</script>
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="{:url('AdminAdvantage/index')}">优势列表</a></li>
<li class="active"><a href="#">添加优势</a></li>
</ul>
<form action="{:url('AdminAdvantage/addPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
<div class="row">
<div class="col-md-9">
<table class="table table-bordered">
<tr>
<th width="150">标题<span class="form-required">*</span></th>
<td>
<input class="form-control" type="text" name="title" required placeholder="请输入标题"/>
</td>
</tr>
<tr>
<th>标题(英文)<span class="form-required">*</span></th>
<td>
<input class="form-control" type="text" name="title_en" required placeholder="请输入标题(英文)"/>
</td>
</tr>
<tr>
<th>简介<span class="form-required">*</span></th>
<td>
<textarea class="form-control" rows="3" name="introduce" required placeholder="请输入简介"></textarea>
</td>
</tr>
<tr>
<th>简介(英文)<span class="form-required">*</span></th>
<td>
<textarea class="form-control" rows="3" name="introduce_en" required placeholder="请输入简介(英文)"></textarea>
</td>
</tr>
</table>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
<a class="btn btn-default" href="{:url('AdminAdvantage/index')}">{:lang('BACK')}</a>
</div>
</div>
</div>
</div>
</form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
//编辑器路径定义
var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
$(function () {
editorcontent = new baidu.editor.ui.Editor();
editorcontent.render('content');
try {
editorcontent.sync();
} catch (err) {
}
$('.btn-cancel-thumbnail').click(function () {
$('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnail').val('');
});
});
</script>
</body>
</html>
... ...
<include file="public@header"/>
<style type="text/css">
.pic-list li {
margin-bottom: 5px;
}
</style>
<script type="text/html" id="photos-item-tpl">
<li id="saved-image{id}">
<input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
<input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
style="width: 200px;" title="图片名称">
<img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
onclick="imagePreviewDialog(this.src);">
<a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
<a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
</li>
</script>
<script type="text/html" id="files-item-tpl">
<li id="saved-file{id}">
<input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
<input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
style="width: 200px;" title="文件名称">
<a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
<a href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
<a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
</li>
</script>
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="{:url('AdminAdvantage/index')}">优势列表</a></li>
<li class="active"><a href="#">编辑优势</a></li>
</ul>
<form action="{:url('AdminAdvantage/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
<div class="row">
<div class="col-md-9">
<table class="table table-bordered">
<tr>
<th width="150">标题<span class="form-required">*</span></th>
<td>
<input type="hidden" name="id" required value="{$post.id}"/>
<input class="form-control" type="text" name="title" required placeholder="请输入标题" value="{$post.title}"/>
</td>
</tr>
<tr>
<th>标题(英文)<span class="form-required">*</span></th>
<td>
<input class="form-control" type="text" name="title_en" required placeholder="请输入标题(英文)" value="{$post.title_en}"/>
</td>
</tr>
<tr>
<th>简介<span class="form-required">*</span></th>
<td>
<textarea class="form-control" rows="3" name="introduce" required placeholder="请输入简介">{$post.introduce}</textarea>
</td>
</tr>
<tr>
<th>简介(英文)<span class="form-required">*</span></th>
<td>
<textarea class="form-control" rows="3" name="introduce_en" required placeholder="请输入简介(英文)">{$post.introduce_en}</textarea>
</td>
</tr>
</table>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
</div>
</div>
</form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
//编辑器路径定义
var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
$(function () {
editorcontent = new baidu.editor.ui.Editor();
editorcontent.render('content');
try {
editorcontent.sync();
} catch (err) {
}
$('.btn-cancel-thumbnail').click(function () {
$('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnail').val('');
});
});
</script>
</body>
</html>
... ...
<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li class="active"><a href="javascript:;">优势列表</a></li>
<li><a href="{:url('AdminAdvantage/add')}">添加优势</a></li>
</ul>
<form class="well form-inline margin-top-20" method="get" action="{:url('AdminAdvantage/index')}">
<!--时间:-->
<!--<input type="text" class="form-control js-bootstrap-datetime" name="start_time"-->
<!--value="{$start_time|default=''}"-->
<!--style="width: 140px;" autocomplete="off">- -->
<!--<input type="text" class="form-control js-bootstrap-datetime" name="end_time"-->
<!--value="{$end_time|default=''}"-->
<!--style="width: 140px;" autocomplete="off"> &nbsp; &nbsp;-->
<!--关键字:-->
<!--<input type="text" class="form-control" name="keyword" style="width: 200px;"-->
<!--value="{$keyword|default=''}" placeholder="请输入关键字...">-->
<!--<input type="submit" class="btn btn-primary" value="搜索"/>-->
<!--<a class="btn btn-danger" href="{:url('AdminAdvantage/index')}">清空</a>-->
</form>
<form class="js-ajax-form" action="" method="post">
<table class="table table-hover table-bordered table-list">
<thead>
<tr>
<th width="50">
<label>
<input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
</label>
</th>
<th>ID</th>
<th>标题</th>
<th>创建时间</th>
<th>操作</th>
</tr>
</thead>
<foreach name="list" item="vo">
<tr>
<td>
<input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
value="{$vo.id}" title="ID:{$vo.id}">
</td>
<td>{$vo.id}</td>
<td>
{$vo.title}
</td>
<td>
{:date('Y-m-d H:i:s',$vo['create_time'])}
</td>
<td>
<a class="btn btn-xs btn-primary" href="{:url('AdminAdvantage/edit',array('id'=>$vo['id']))}">{:lang('EDIT')}</a>
<a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('AdminAdvantage/delete',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>
</td>
</tr>
</foreach>
</table>
<ul class="pagination">{$page|default=''}</ul>
</form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
function reloadPage(win) {
win.location.reload();
}
</script>
</body>
</html>
\ No newline at end of file
... ...
<include file="public@header"/>
<style type="text/css">
.pic-list li {
margin-bottom: 5px;
}
</style>
<script type="text/html" id="photos-item-tpl">
<li id="saved-image{id}">
<input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
<input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
style="width: 200px;" title="图片名称">
<img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
onclick="imagePreviewDialog(this.src);">
<a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
<a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
</li>
</script>
<script type="text/html" id="files-item-tpl">
<li id="saved-file{id}">
<input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
<input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
style="width: 200px;" title="文件名称">
<a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
<a href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
<a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
</li>
</script>
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="{:url('AdminRotation/index')}">轮播图管理</a></li>
<li class="active"><a href="{:url('AdminRotation/add')}">添加轮播图</a></li>
</ul>
<form action="{:url('AdminRotation/addPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
<div class="row">
<div class="col-md-9">
<table class="table table-bordered">
<tr>
<th width="100">链接<span class="form-required">*</span></th>
<td>
<input class="form-control" type="url" name="link" required placeholder="请输入链接"/>
</td>
</tr>
</table>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
<a class="btn btn-default" href="{:url('AdminRotation/index')}">{:lang('BACK')}</a>
</div>
</div>
</div>
<div class="col-md-3">
<table class="table table-bordered">
<tr>
<th>轮播图<span class="form-required">*</span></th>
</tr>
<tr>
<td>
<div style="text-align: center;">
<input type="hidden" name="thumbnail" id="thumbnail">
<a href="javascript:uploadOneImage('图片上传','#thumbnail');">
<img src="__TMPL__/public/assets/images/default-thumbnail.png"
id="thumbnail-preview"
width="135" style="cursor: pointer"/>
</a>
<input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
</div>
</td>
</tr>
</table>
</div>
</div>
</form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
//编辑器路径定义
var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
$(function () {
editorcontent = new baidu.editor.ui.Editor();
editorcontent.render('content');
try {
editorcontent.sync();
} catch (err) {
}
$('.btn-cancel-thumbnail').click(function () {
$('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnail').val('');
});
});
</script>
</body>
</html>
... ...
<include file="public@header"/>
<style type="text/css">
.pic-list li {
margin-bottom: 5px;
}
</style>
<script type="text/html" id="photos-item-tpl">
<li id="saved-image{id}">
<input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
<input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
style="width: 200px;" title="图片名称">
<img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
onclick="imagePreviewDialog(this.src);">
<a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
<a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
</li>
</script>
<script type="text/html" id="files-item-tpl">
<li id="saved-file{id}">
<input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
<input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
style="width: 200px;" title="文件名称">
<a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
<a href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
<a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
</li>
</script>
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="{:url('AdminRotation/index')}">轮播图管理</a></li>
<li class="active"><a href="#">编辑轮播图</a></li>
</ul>
<form action="{:url('AdminRotation/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
<div class="row">
<div class="col-md-9">
<table class="table table-bordered">
<tr>
<th width="100">链接<span class="form-required">*</span></th>
<td>
<input id="post-id" type="hidden" name="id" value="{$post.id}">
<input class="form-control" type="url" name="link" required value="{$post.link}" placeholder="请输入链接"/>
</td>
</tr>
</table>
</div>
<div class="col-md-3">
<table class="table table-bordered">
<tr>
<th>轮播图<span class="form-required">*</span></th>
</tr>
<tr>
<td>
<div style="text-align: center;">
<input type="hidden" name="thumbnail" id="thumbnail" value="{$post.thumbnail|default=''}">
<a href="javascript:uploadOneImage('图片上传','#thumbnail');">
<if condition="empty($post.thumbnail)">
<img src="__TMPL__/public/assets/images/default-thumbnail.png" id="thumbnail-preview" width="135" style="cursor: pointer"/>
<else/>
<img src="{:cmf_get_image_preview_url($post.thumbnail)}" id="thumbnail-preview" width="135" style="cursor: pointer"/>
</if>
</a>
<input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
</div>
</td>
</tr>
</table>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
</div>
</div>
</form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
//编辑器路径定义
var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
$(function () {
editorcontent = new baidu.editor.ui.Editor();
editorcontent.render('content');
try {
editorcontent.sync();
} catch (err) {
}
$('.btn-cancel-thumbnail').click(function () {
$('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnail').val('');
});
});
</script>
</body>
</html>
... ...
<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li class="active"><a href="javascript:;">轮播列表</a></li>
<li><a href="{:url('AdminRotation/add')}">添加轮播</a></li>
</ul>
<form class="well form-inline margin-top-20" method="get" action="{:url('AdminRotation/index')}">
<!--时间:-->
<!--<input type="text" class="form-control js-bootstrap-datetime" name="start_time"-->
<!--value="{$start_time|default=''}"-->
<!--style="width: 140px;" autocomplete="off">- -->
<!--<input type="text" class="form-control js-bootstrap-datetime" name="end_time"-->
<!--value="{$end_time|default=''}"-->
<!--style="width: 140px;" autocomplete="off"> &nbsp; &nbsp;-->
<!--关键字:-->
<!--<input type="text" class="form-control" name="keyword" style="width: 200px;"-->
<!--value="{$keyword|default=''}" placeholder="请输入关键字...">-->
<!--<input type="submit" class="btn btn-primary" value="搜索"/>-->
<!--<a class="btn btn-danger" href="{:url('AdminRotation/index')}">清空</a>-->
</form>
<form class="js-ajax-form" action="" method="post">
<table class="table table-hover table-bordered table-list">
<thead>
<tr>
<th width="50">
<label>
<input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
</label>
</th>
<th>ID</th>
<th>轮播图</th>
<th>链接</th>
<th>创建时间</th>
<th>操作</th>
</tr>
</thead>
<foreach name="list" item="vo">
<tr>
<td>
<input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
value="{$vo.id}" title="ID:{$vo.id}">
</td>
<td>{$vo.id}</td>
<td>
<notempty name="vo.thumbnail">
<a href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo.thumbnail)}');">
<i class="fa fa-photo fa-fw"></i>
</a>
<else/>
<i class="fa fa-close fa-fw"></i>
</notempty>
</td>
<td>
{$vo.link}
</td>
<td>
{:date('Y-m-d H:i:s',$vo['create_time'])}
</td>
<td>
<a class="btn btn-xs btn-primary" href="{:url('AdminRotation/edit',array('id'=>$vo['id']))}">{:lang('EDIT')}</a>
<a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('AdminRotation/delete',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>
</td>
</tr>
</foreach>
</table>
<ul class="pagination">{$page|default=''}</ul>
</form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
function reloadPage(win) {
win.location.reload();
}
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -326,6 +326,8 @@ class Upload
session_write_close();
$result = $storage->upload($arrInfo["file_path"], './upload/' . $arrInfo["file_path"], $fileType);
if (!empty($result)) {
//我加的
unlink('./upload/' . $arrInfo["file_path"]);
return array_merge([
'filepath' => $arrInfo["file_path"],
"name" => $arrInfo["filename"],
... ...