完成上传组件的开发
This commit is contained in:
@@ -176,6 +176,28 @@ function format_bytes($size, $delimiter = '') {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取附件信息
|
||||
* @param int $cover_id
|
||||
* @param string $field
|
||||
* @return 完整的数据 或者 指定的$field字段值
|
||||
*/
|
||||
function get_attach($id, $field = null) {
|
||||
$basePath = request()->domain();
|
||||
if (empty($id)) {
|
||||
return $basePath . '/static/images/default.png';
|
||||
}
|
||||
$picture = \think\facade\Db::name('Attach')->where(array('id' => $id))->find();
|
||||
if ($field == 'path') {
|
||||
if (!empty($picture['url'])) {
|
||||
$picture['path'] = $picture['url'] ? $$basePath . $picture['url'] : $$basePath . '/static/images/default.png';
|
||||
} else {
|
||||
$picture['path'] = $picture['path'] ? $$basePath . $picture['path'] : $$basePath . '/static/images/default.png';
|
||||
}
|
||||
}
|
||||
return empty($field) ? $picture : $picture[$field];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档封面图片
|
||||
* @param int $cover_id
|
||||
|
||||
@@ -51,6 +51,7 @@ class Upload extends Base {
|
||||
|
||||
public function server(){
|
||||
$param = $this->request->get();
|
||||
$map = [];
|
||||
if (!isset($param['name'])) {
|
||||
return $this->error('非法操作');
|
||||
}
|
||||
@@ -60,10 +61,11 @@ class Upload extends Base {
|
||||
'query' => $this->request->param()
|
||||
];
|
||||
if($param['type'] == 'file'){
|
||||
$list = Db::name('File')->paginate($pageConfig);
|
||||
$map[] = ['ext', '<>', 'image'];
|
||||
}else{
|
||||
$list = Db::name('Picture')->paginate($pageConfig);
|
||||
$map[] = ['ext', '=', 'image'];
|
||||
}
|
||||
$list = Db::name('Attach')->paginate($pageConfig);
|
||||
|
||||
$this->data = [
|
||||
'from' => $this->request->param('from'),
|
||||
@@ -79,15 +81,16 @@ class Upload extends Base {
|
||||
}
|
||||
|
||||
public function upload(){
|
||||
$upload_type = $this->request->get('filename', 'image', 'trim');
|
||||
$type = $this->request->param('type');
|
||||
$upload_type = (false !== strpos("image", $type)) ? "image" : 'file';
|
||||
$config = $this->$upload_type();
|
||||
// 获取表单上传文件 例如上传了001.jpg
|
||||
$file = request()->file('file');
|
||||
$file = $this->request->file('file');
|
||||
try {
|
||||
validate(['file'=>'filesize:10240|fileExt:jpg|image:200,200,jpg'])
|
||||
->check([$file]);
|
||||
$data['code'] = 1;
|
||||
$data['info'] = $this->save($file, $upload_type);
|
||||
$data['info'] = $this->save($this->request, $upload_type);
|
||||
} catch (think\exception\ValidateException $e) {
|
||||
$data['code'] = 0;
|
||||
$data['info'] = $e->getMessage();
|
||||
@@ -99,6 +102,10 @@ class Upload extends Base {
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function file(){
|
||||
return [];
|
||||
}
|
||||
|
||||
public function editor(){
|
||||
$fileType = $this->request->get('fileType', 'image', 'trim');
|
||||
$file = request()->file('imgFile');
|
||||
@@ -130,27 +137,20 @@ class Upload extends Base {
|
||||
return json($data);
|
||||
}
|
||||
|
||||
protected function save($file, $upload_type){
|
||||
protected function save($request, $upload_type){
|
||||
$data = [];
|
||||
$savename = Filesystem::disk('public')->putFile($upload_type, $file, 'md5');
|
||||
|
||||
$data['create_time'] = $file->getATime(); //最后访问时间
|
||||
$data['savename'] = $file->getBasename(); //获取无路径的basename
|
||||
$data['c_time'] = $file->getCTime(); //获取inode修改时间
|
||||
$data['ext'] = $file->getExtension(); //文件扩展名
|
||||
$data['name'] = $file->getFilename(); //获取文件名
|
||||
$data['m_time'] = $file->getMTime(); //获取最后修改时间
|
||||
$data['owner'] = $file->getOwner(); //文件拥有者
|
||||
$data['savepath'] = $file->getPath(); //不带文件名的文件路径
|
||||
$data['url'] = $data['path'] = '/uploads/' . $savename; //全路径
|
||||
$file= $request->file('file');
|
||||
$data['savename'] = $request->param('name');
|
||||
$data['mime'] = $request->param('type');
|
||||
$data['size'] = $file->getSize(); //文件大小,单位字节
|
||||
$data['is_file'] = $file->isFile(); //是否是文件
|
||||
$data['is_execut'] = $file->isExecutable(); //是否可执行
|
||||
$data['is_readable'] = $file->isReadable(); //是否可读
|
||||
$data['is_writable'] = $file->isWritable(); //是否可写
|
||||
$data['md5'] = md5_file($file->getPathname());
|
||||
$data['sha1'] = sha1_file($file->getPathname());
|
||||
$data['id'] = time();
|
||||
$data['ext'] = pathinfo($data['savename'], PATHINFO_EXTENSION); //文件扩展名
|
||||
$data['savepath'] = Filesystem::disk('public')->putFile($upload_type, $file, 'md5');
|
||||
$data['location'] = "/uploads/";
|
||||
$data['url'] = $data['location'] . $data['savepath'];
|
||||
$data['create_time'] = time();
|
||||
$data['id'] = Db::name('Attach')->insertGetId($data);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\model\Wechat as WechatM;
|
||||
use app\model\WechatPay;
|
||||
|
||||
/**
|
||||
* @title 微信模块
|
||||
@@ -19,14 +20,14 @@ class Wechat extends Base {
|
||||
|
||||
/**
|
||||
* @title 微信列表
|
||||
* @author huajie <banhuajie@163.com>
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
public function index() {
|
||||
$map = [];
|
||||
|
||||
$order = "id desc";
|
||||
//获取列表数据
|
||||
$list = WechatM::where($map)->order($order)->paginate($this->request->pageConfig);
|
||||
$list = WechatM::where($map)->order($order)->paginate($this->request->pageConfig)->append(['type_text']);
|
||||
|
||||
$this->data = array(
|
||||
'list' => $list,
|
||||
@@ -37,7 +38,7 @@ class Wechat extends Base {
|
||||
|
||||
/**
|
||||
* @title 添加微信
|
||||
* @author colin <colin@tensent.cn>
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
public function add() {
|
||||
if ($this->request->isPost()) {
|
||||
@@ -58,7 +59,7 @@ class Wechat extends Base {
|
||||
|
||||
/**
|
||||
* @title 修改微信
|
||||
* @author colin <colin@tensent.cn>
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
public function edit($id = null) {
|
||||
if ($this->request->isPost()) {
|
||||
@@ -83,108 +84,92 @@ class Wechat extends Base {
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 删除用户行为
|
||||
* @author colin <colin@tensent.cn>
|
||||
* @title 删除微信
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
public function del() {
|
||||
$id = $this->getArrayParam('id');
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!", '');
|
||||
public function delete() {
|
||||
$id = $this->request->param('id', '');
|
||||
|
||||
$map = [];
|
||||
if (!$id) {
|
||||
return $this->error('请选择要操作的数据!');
|
||||
}
|
||||
$map['id'] = array('IN', $id);
|
||||
$result = db('Action')->where($map)->delete();
|
||||
if ($result) {
|
||||
action_log('delete_action', 'Action', $id, session('user_auth.uid'));
|
||||
return $this->success('删除成功!');
|
||||
if (is_array($id)) {
|
||||
$map[] = ['id', 'IN', $id];
|
||||
}else{
|
||||
$map[] = ['id', '=', $id];
|
||||
}
|
||||
|
||||
$result = WechatM::where($map)->delete();
|
||||
if (false !== $result) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->error('删除失败!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 修改用户行为状态
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function setstatus() {
|
||||
$id = $this->getArrayParam('id');
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!", '');
|
||||
}
|
||||
$status = input('get.status', '', 'trim,intval');
|
||||
$message = !$status ? '禁用' : '启用';
|
||||
$map['id'] = array('IN', $id);
|
||||
$result = db('Action')->where($map)->setField('status', $status);
|
||||
if ($result !== false) {
|
||||
action_log('setstatus_action', 'Action', $id, session('user_auth.uid'));
|
||||
return $this->success('设置' . $message . '状态成功!');
|
||||
} else {
|
||||
return $this->error('设置' . $message . '状态失败!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 小程序列表
|
||||
* @author huajie <banhuajie@163.com>
|
||||
* @title 微信支付
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
public function pay() {
|
||||
return $this->fetch();
|
||||
}
|
||||
/**
|
||||
* @title 查看行为日志
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function detail($id = 0) {
|
||||
$model = model('ActionLog');
|
||||
if (empty($id)) {
|
||||
return $this->error('参数错误!');
|
||||
}
|
||||
$map = [];
|
||||
|
||||
$info = $model::get($id);
|
||||
$order = "id desc";
|
||||
//获取列表数据
|
||||
$list = WechatPay::where($map)->order($order)->paginate($this->request->pageConfig);
|
||||
|
||||
$info['title'] = get_action($info['action_id'], 'title');
|
||||
$info['user_id'] = get_username($info['user_id']);
|
||||
$info['action_ip'] = long2ip($info['action_ip']);
|
||||
$info['create_time'] = date('Y-m-d H:i:s', $info['create_time']);
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $model->keyList,
|
||||
$this->data = array(
|
||||
'list' => $list,
|
||||
'page' => '',
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('查看行为日志');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 删除日志
|
||||
* @param mixed $id
|
||||
* @author huajie <banhuajie@163.com>
|
||||
* @title 添加微信支付
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
public function dellog() {
|
||||
$id = $this->getArrayParam('id');
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!", '');
|
||||
}
|
||||
$map['id'] = array('IN', $id);
|
||||
$res = db('ActionLog')->where($map)->delete();
|
||||
if ($res !== false) {
|
||||
action_log('delete_actionlog', 'ActionLog', $id, session('user_auth.uid'));
|
||||
return $this->success('删除成功!');
|
||||
public function addpay() {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
$result = WechatPay::create($data);
|
||||
if (false != $result) {
|
||||
return $this->success('添加成功!', url('/admin/wechat/index'));
|
||||
} else {
|
||||
return $this->error('添加失败!');
|
||||
}
|
||||
} else {
|
||||
return $this->error('删除失败!');
|
||||
$this->data = array(
|
||||
'keyList' => WechatPay::$fieldlist
|
||||
);
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 清空日志
|
||||
* @title 修改微信支付
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
public function clear($id = '') {
|
||||
$res = db('ActionLog')->where('1=1')->delete();
|
||||
if ($res !== false) {
|
||||
//记录行为
|
||||
action_log('clear_actionlog', 'ActionLog', $id, session('user_auth.uid'));
|
||||
return $this->success('日志清空成功!');
|
||||
public function editpay($id = null) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
$result = WechatPay::update($data, ['id' => $data['id']]);
|
||||
if ($result !== false) {
|
||||
return $this->success('编辑成功!', url('/admin/wechat/index'));
|
||||
} else {
|
||||
return $this->error('修改失败!');
|
||||
}
|
||||
} else {
|
||||
return $this->error('日志清空失败!');
|
||||
$info = WechatPay::find($id);
|
||||
if (!$info) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$this->data = array(
|
||||
'info' => $info,
|
||||
'keyList' => WechatPay::$fieldlist
|
||||
);
|
||||
return $this->fetch('admin/public/edit');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ class Factory {
|
||||
protected $data = [];
|
||||
|
||||
public function __construct($field, $data){
|
||||
$field['is_must'] = isset($field['is_must']) ? $field['is_must'] : 0;
|
||||
$this->field = $field;
|
||||
$this->data = $data;
|
||||
$this->parseValue();
|
||||
|
||||
@@ -5,22 +5,17 @@
|
||||
{else/}
|
||||
<input type="hidden" name="{$name}" id="field_{$name}" value="">
|
||||
{/if}
|
||||
<div id="fileList_{$name}" class="upload-file-list-info" style="width:280px;">
|
||||
<div id="fileList_{$name}" class="file-list">
|
||||
{if $value}
|
||||
{php}
|
||||
$images = get_file($value);
|
||||
$file = get_attach($value);
|
||||
{/php}
|
||||
<li class="affix-list-item" id="WU_FILE_0">
|
||||
<div class="upload-file-info">
|
||||
<span class="webuploader-pick-file-close" data-queued-id="WU_FILE_0" data-id="{$value}" data-fileurl="{$images['path']}"><i class="close"></i></span>
|
||||
<span class="fname"></span>
|
||||
<span class="fsize">上传时间:{$images['create_time']}</span>
|
||||
<div class="clearfix"></div>
|
||||
<div class="item" data-id="{$file['id']}">
|
||||
<div class="attach">
|
||||
<div class="close"><i class="fa fa-close"></i></div>
|
||||
<span>{$file['savename']}</span>
|
||||
</div>
|
||||
<div class="filebox image">
|
||||
<img src="{:config('config.base_url')}{$images['path']}" class="img-responsive">
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1 +1 @@
|
||||
<input type="text" class="form-control" name="{$name}" id="{$name}" autocomplete="false" value="{$value}" {if isset($is_must) && $is_must}data-rule="required"{/if}>
|
||||
<input type="text" class="form-control" name="{$name}" id="{$name}" value="{$value}" data-rule="{if isset($is_must) && $is_must}required{/if}">
|
||||
@@ -15,10 +15,22 @@ namespace app\model;
|
||||
class Wechat extends \think\Model {
|
||||
|
||||
public static $fieldlist = [
|
||||
['name' => 'name', 'title' => '名称', 'type' => 'text', 'help' => '微信名称'],
|
||||
['name' => 'app_id', 'title' => '微信APPID', 'type' => 'text', 'help' => 'AppID'],
|
||||
['name' => 'title', 'title' => '名称', 'type' => 'text', 'is_must' => 1, 'help' => '微信名称'],
|
||||
['name' => 'type', 'title' => '微信类型', 'type' => 'select', 'is_must' => 1, 'option' => [['key' => 1, 'label' => '公众号'],['key' => 2, 'label' => '小程序'],['key' => 3, 'label' => '企业号']], 'help' => 'AppID'],
|
||||
['name' => 'app_id', 'title' => '微信APPID', 'type' => 'text', 'is_must' => 1, 'help' => 'AppID'],
|
||||
['name' => 'secret', 'title' => '微信秘钥', 'type' => 'text', 'help' => 'AppSecret'],
|
||||
['name' => 'token', 'title' => '微信Token', 'type' => 'text', 'help' => 'Token'],
|
||||
['name' => 'aes_key', 'title' => 'EncodingAESKey', 'type' => 'text', 'help' => 'EncodingAESKey,兼容与安全模式下请一定要填写!!!'],
|
||||
];
|
||||
|
||||
protected function getTypeTextAttr($value, $data){
|
||||
$type = self::$fieldlist[1]['option'];
|
||||
$type_text = "";
|
||||
foreach($type as $val){
|
||||
if($data['type'] && $data['type'] == $val['key']){
|
||||
$type_text = $val['label'];
|
||||
}
|
||||
}
|
||||
return $type_text;
|
||||
}
|
||||
}
|
||||
25
app/model/WechatPay.php
Normal file
25
app/model/WechatPay.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\model;
|
||||
|
||||
/**
|
||||
* 微信模型
|
||||
*/
|
||||
class WechatPay extends \think\Model {
|
||||
|
||||
public static $fieldlist = [
|
||||
['name' => 'app_id', 'title' => '微信APPID', 'type' => 'text', 'is_must' => 1, 'help' => 'AppID'],
|
||||
['name' => 'mch_id', 'title' => '商户ID', 'type' => 'text', 'is_must' => 1, 'help' => '商户ID'],
|
||||
['name' => 'key', 'title' => 'API秘钥', 'type' => 'text', 'is_must' => 1, 'help' => 'API秘钥'],
|
||||
['name' => 'cert_path_id', 'title' => '证书', 'type' => 'attach', 'help' => '如需使用敏感接口(如退款、发送红包等)需要配置 API 证书路径(登录商户平台下载 API 证书)'],
|
||||
['name' => 'key_path_id', 'title' => '证书秘钥', 'type' => 'attach', 'help' => ''],
|
||||
['name' => 'notify_url', 'title' => '回调地址', 'type' => 'text', 'help' => '你也可以在下单时单独设置来想覆盖它'],
|
||||
];
|
||||
}
|
||||
@@ -21,5 +21,7 @@ return [
|
||||
// 标签库标签开始标记
|
||||
'taglib_begin' => '{',
|
||||
// 标签库标签结束标记
|
||||
'taglib_end' => '}',
|
||||
'taglib_end' => '}',
|
||||
// 预先加载的标签库
|
||||
'taglib_pre_load' => 'com\Sent',
|
||||
];
|
||||
|
||||
153
extend/com/Sent.php
Normal file
153
extend/com/Sent.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace com;
|
||||
|
||||
/**
|
||||
* @title 自定义标签库
|
||||
* @description 自定义标签库
|
||||
*/
|
||||
class Sent extends \think\template\TagLib {
|
||||
|
||||
// 标签定义
|
||||
protected $tags = array(
|
||||
// 标签定义: attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次
|
||||
'nav' => array('attr' => 'name,pid', 'close' => 1), //获取导航
|
||||
'list' => array('attr' => 'table,where,order,limit,id,sql,field,key','level'=>3),//列表
|
||||
'doc' => array('attr' => 'model,field,limit,id,field,key,name','level'=>3),
|
||||
'recom' => array('attr' => 'doc_id,id'),
|
||||
'link' => array('attr' => 'type,limit' , 'close' => 1),//友情链接
|
||||
'prev' => array('attr' => 'id,cate' , 'close' => 1),//上一篇
|
||||
'next' => array('attr' => 'id,cate' , 'close' => 1),//下一篇
|
||||
);
|
||||
|
||||
public function tagnav($tag, $content){
|
||||
$pid = isset($tag['pid']) ? 'pid=' . $tag['pid'] : '';
|
||||
$tree = isset($tag['tree']) ? $tag['tree'] : 1;
|
||||
$parse = $parse = '<?php ';
|
||||
$parse .= '$__NAV__ = db(\'Channel\')->where("status=1")->where("'.$pid.'")->order("sort")->select();';
|
||||
if($tree == 1){
|
||||
$parse .= '$__NAV__ = list_to_tree($__NAV__, "id", "pid");';
|
||||
}
|
||||
$parse .= 'foreach ($__NAV__ as $key => $'.$tag['name'].') {';
|
||||
$parse .= '?>';
|
||||
$parse .= $content;
|
||||
$parse .= '<?php } ?>';
|
||||
return $parse;
|
||||
}
|
||||
|
||||
public function tagdoc($tag, $content){
|
||||
$model = !empty($tag['model']) ? $tag['model']:'';
|
||||
$cid = !empty($tag['cid']) ? $tag['cid']:'0';
|
||||
$field = empty($tag['field']) ? '*' : $tag['field'];
|
||||
$limit = empty($tag['limit']) ? 20 : $tag['limit'];
|
||||
$order = empty($tag['order']) ? 'id desc' : $tag['order'];
|
||||
$name = isset($tag['name']) ? $tag['name'] : 'item';
|
||||
|
||||
//获得当前栏目的所有子栏目
|
||||
$ids = get_category_child($cid);
|
||||
$ids = implode(',', $ids);
|
||||
$where = "category_id IN ({$ids})";
|
||||
$where .= " and status >= 1";
|
||||
|
||||
$parse = $parse = '<?php ';
|
||||
$parse .= '$__LIST__ = M(\''.$model.'\')->where(\''.$where.'\')->field(\''.$field.'\')->limit(\''.$limit.'\')->order(\''.$order.'\')->select();';
|
||||
$parse .= 'foreach ($__LIST__ as $key => $'.$tag['name'].') {';
|
||||
$parse .= '?>';
|
||||
$parse .= $content;
|
||||
$parse .= '<?php } ?>';
|
||||
return $parse;
|
||||
}
|
||||
|
||||
public function taglist($tag, $content){
|
||||
$name = !empty($tag['name']) ? $tag['name'] : '';
|
||||
$map = !empty($tag['map']) ? $tag['map'] : '';
|
||||
$field = empty($tag['field']) ? '*' : $tag['field'];
|
||||
$limit = empty($tag['limit']) ? 20 : $tag['limit'];
|
||||
$order = empty($tag['order']) ? 'id desc' : $tag['order'];
|
||||
|
||||
$where[] = "status > 0";
|
||||
if ($map) {
|
||||
$where[] = $map;
|
||||
}
|
||||
$map = implode(" and ", $where);
|
||||
|
||||
$parse = $parse = '<?php ';
|
||||
$parse .= '$__LIST__ = model(\''.$name.'\')->where(\''.$map.'\')->field(\''.$field.'\')->limit(\''.$limit.'\')->order(\''.$order.'\')->select();';
|
||||
$parse .= 'foreach ($__LIST__ as $key => $'.$tag['id'].') {';
|
||||
$parse .= '?>';
|
||||
$parse .= $content;
|
||||
$parse .= '<?php } ?>';
|
||||
return $parse;
|
||||
}
|
||||
|
||||
public function tagrecom($tag, $content){
|
||||
$model = empty($tag['model']) ? '' : $tag['model'];
|
||||
$field = empty($tag['field']) ? '*' : $tag['field'];
|
||||
$limit = empty($tag['limit']) ? 20 : $tag['limit'];
|
||||
$order = empty($tag['order']) ? 'id desc' : $tag['order'];
|
||||
if (!$model) {
|
||||
return '';
|
||||
}
|
||||
$parse = $parse = '<?php ';
|
||||
$parse .= '$__LIST__ = M(\''.$model.'\')->recom(\'' .$field. '\',' .$limit. ',\'' .$order. '\');';
|
||||
$parse .= 'foreach ($__LIST__ as $key => $'.$tag['id'].') {';
|
||||
$parse .= '?>';
|
||||
$parse .= $content;
|
||||
$parse .= '<?php } ?>';
|
||||
return $parse;
|
||||
}
|
||||
|
||||
public function taglink($tag, $content){
|
||||
$type = !empty($tag['type']) ? $tag['type'] : '';
|
||||
$limit = !empty($tag['limit']) ? $tag['limit'] : '';
|
||||
$field = empty($tag['field']) ? '*' : $tag['field'];
|
||||
$limit = empty($tag['limit']) ? 20 : $tag['limit'];
|
||||
$order = empty($tag['order']) ? "id desc" : $tag['order'];
|
||||
|
||||
$where[] = "status > 0";
|
||||
if ($type) {
|
||||
$where[] = "ftype = " . $type;
|
||||
}
|
||||
$map = implode(" and ", $where);
|
||||
|
||||
$parse = $parse = '<?php ';
|
||||
$parse .= '$__LIST__ = model(\'Link\')->where(\''.$map.'\')->field(\''.$field.'\')->limit(\''.$limit.'\')->order(\''.$order.'\')->select();';
|
||||
$parse .= 'foreach ($__LIST__ as $key => $'.$tag['name'].') {';
|
||||
$parse .= '?>';
|
||||
$parse .= $content;
|
||||
$parse .= '<?php } ?>';
|
||||
return $parse;
|
||||
}
|
||||
|
||||
public function tagprev($tag, $content){
|
||||
$id = !empty($tag['id']) ? $tag['id'] : '';
|
||||
$cate = !empty($tag['cate']) ? $tag['cate'] : '';
|
||||
$model = !empty($tag['model']) ? $tag['model'] : '';
|
||||
|
||||
$parse = '<?php ';
|
||||
$parse .= '$map = "category_id=" . ' . $cate . ' . " and id>" . ' . $id . ';';
|
||||
$parse .= '$prev = db(\''.$model.'\')->where($map)->order(\'id asc\')->find();if(!empty($prev)){ ?>';
|
||||
$parse .= $content;
|
||||
$parse .= '<?php } ?>';
|
||||
return $parse;
|
||||
}
|
||||
|
||||
public function tagnext($tag, $content){
|
||||
$id = !empty($tag['id']) ? ($tag['id']) : '';
|
||||
$cate = !empty($tag['cate']) ? $tag['cate'] : '';
|
||||
$model = !empty($tag['model']) ? $tag['model'] : '';
|
||||
|
||||
$parse = '<?php ';
|
||||
$parse .= '$map = "category_id=" . ' . $cate . ' . " and id<" . ' . $id . ';';
|
||||
$parse .= '$next = db(\''.$model.'\')->where($map)->order(\'id desc\')->find();if(!empty($next)){ ?>';
|
||||
$parse .= $content;
|
||||
$parse .= '<?php } ?>';
|
||||
return $parse;
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,6 @@
|
||||
.img-list .item{width: 20%;}
|
||||
.img-list .item .thumb{margin: 10px 10px 0 0 ; border: 1px solid #efefef; height: 120px; border-radius: 4px; position: relative; overflow: hidden;}
|
||||
.img-list .item .thumb img{width: 100%;}
|
||||
.img-list .item .close{position: absolute; right: 5px; top: 5px; opacity: 1; width: 20px; height: 20px; font-size: 10px; text-align: center; line-height: 20px; color: #ffffff; border-radius: 50%; background: #333333;}
|
||||
.img-list .item .thumb .close{position: absolute; right: 5px; top: 5px; opacity: 1; width: 20px; height: 20px; font-size: 10px; text-align: center; line-height: 20px; color: #ffffff; border-radius: 50%; background: #333333;}
|
||||
.file-list{padding: 10px 0; display: flex; flex-direction: column;}
|
||||
.file-list .attach{line-height: 35px; border-bottom: 1px dotted #333333; cursor: pointer;}
|
||||
@@ -3,14 +3,16 @@ define(['jquery', 'bootstrap', 'validator'], function ($, undefined, Validator)
|
||||
config: {
|
||||
editor: {
|
||||
"full":['source', 'undo', 'redo', 'code', 'quote', 'cut',
|
||||
'plainpaste', 'wordpaste', 'justifyleft', 'justifycenter', 'justifyright',
|
||||
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
|
||||
'superscript', 'clearhtml', 'quickformat', 'selectall', '/',
|
||||
'formatblock', 'fontname', 'fontsize', 'forecolor', 'hilitecolor', 'bold',
|
||||
'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', 'image', 'multiimage', 'media', 'insertfile', 'table', 'hr', 'baidumap',
|
||||
'anchor', 'link', 'unlink','fullscreen'],
|
||||
'plainpaste', 'wordpaste', 'justifyleft', 'justifycenter', 'justifyright',
|
||||
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
|
||||
'superscript', 'clearhtml', 'quickformat', 'selectall', '/',
|
||||
'formatblock', 'fontname', 'fontsize', 'forecolor', 'hilitecolor', 'bold',
|
||||
'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', 'image', 'multiimage', 'media', 'insertfile', 'table', 'hr', 'baidumap',
|
||||
'anchor', 'link', 'unlink','fullscreen'
|
||||
],
|
||||
"base":['undo', 'redo', 'quote', 'formatblock', 'fontname', 'fontsize', 'forecolor', 'hilitecolor', 'bold',
|
||||
'italic', 'underline', 'strikethrough', 'lineheight', 'image', 'media', 'table'],
|
||||
'italic', 'underline', 'strikethrough', 'lineheight', 'image', 'media', 'table'
|
||||
],
|
||||
},
|
||||
fieldlisttpl: '<dd class="form-inline"><input type="text" name="<%=name%>[<%=index%>][key]" class="form-control" value="<%=row.key%>" size="10" /> <input type="text" name="<%=name%>[<%=index%>][value]" class="form-control" value="<%=row.value%>" /> <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span></dd>'
|
||||
},
|
||||
@@ -96,7 +98,7 @@ define(['jquery', 'bootstrap', 'validator'], function ($, undefined, Validator)
|
||||
}, form.data("validator-options") || {}));
|
||||
|
||||
//移除提交按钮的disabled类
|
||||
$(".layer-footer [type=submit],.fixed-footer [type=submit],.normal-footer [type=submit]", form).removeClass("disabled");
|
||||
$("button.btn[type=submit]", form).removeClass("disabled");
|
||||
},
|
||||
editor: function (form) {
|
||||
//绑定编辑器元素事件
|
||||
@@ -307,6 +309,7 @@ define(['jquery', 'bootstrap', 'validator'], function ($, undefined, Validator)
|
||||
var value = $('.picker-box input[type=hidden]').val().split(",");
|
||||
value = value.filter(val => val != $(this).parents('.item').data('id'))
|
||||
$(this).parents('.item').remove();
|
||||
console.log(value)
|
||||
if(value.length > 0){
|
||||
$('.picker-box input[type=hidden]').val(value.join(','));
|
||||
}else{
|
||||
@@ -589,13 +592,22 @@ define(['jquery', 'bootstrap', 'validator'], function ($, undefined, Validator)
|
||||
var value = field.val() ? field.val().split(",") : [];
|
||||
|
||||
if(param.limit == 1){
|
||||
var html = '<div class="item"><div class="thumb" data-id="'+fileList[0].id+'"><div class="close"><i class="fa fa-close"></i></div><img src="'+fileList[0].url+'" /></div></div>';
|
||||
if(param.type == 'image'){
|
||||
var html = '<div class="item"><div class="thumb" data-id="'+fileList[0].id+'"><div class="close"><i class="fa fa-close"></i></div><img src="'+fileList[0].url+'" /></div></div>';
|
||||
}else{
|
||||
var html = '<div class="item"><div class="attach" data-id="'+fileList[0].id+'"><div class="close"><i class="fa fa-close"></i></div><span>'+fileList[0].savename+'</span></div></div>';
|
||||
}
|
||||
|
||||
file.html(html);
|
||||
field.val(fileList[0].id);
|
||||
}else{
|
||||
for(var i = 0; i < fileList.length; i++){
|
||||
if(!value.includes((fileList[i].id).toString())){
|
||||
var html = '<div class="item"><div class="thumb" data-id="'+fileList[i].id+'"><div class="close"><i class="fa fa-close"></i></div><img src="'+fileList[i].url+'" /></div></div>';
|
||||
if(param.type == 'image'){
|
||||
var html = '<div class="item"><div class="thumb" data-id="'+fileList[i].id+'"><div class="close"><i class="fa fa-close"></i></div><img src="'+fileList[i].url+'" /></div></div>';
|
||||
}else{
|
||||
var html = '<div class="item"><div class="attach" data-id="'+fileList[i].id+'"><div class="close"><i class="fa fa-close"></i></div><span>'+fileList[i].savename+'</span></div></div>';
|
||||
}
|
||||
value.push(fileList[i].id);
|
||||
file.append(html);
|
||||
}
|
||||
|
||||
@@ -424,8 +424,8 @@ define(['jquery', 'bootstrap', 'webupload'], function ($, undefined, WebUploader
|
||||
},
|
||||
server: function(){
|
||||
var query = sent.parseUrl(window.location.href);
|
||||
if($('.img-list .item .thumb').length > 0){
|
||||
$('.img-list .item .thumb').on('click', function(){
|
||||
if($('.img-list .item .thumb, .file-list .item .attach').length > 0){
|
||||
$('.img-list .item .thumb, .file-list .item .attach').on('click', function(){
|
||||
if($(this).hasClass('selected')){
|
||||
Upload.config.upList = Upload.config.upList.filter(item => !sent.utils.isObjEqual(item, $(this).data()));
|
||||
$(this).removeClass('selected');
|
||||
|
||||
@@ -4,5 +4,11 @@ var require = {
|
||||
}
|
||||
</script>
|
||||
<script src="__plugins__/require/require.js" data-main="__js__/main.js"></script>
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="__static__/common/js/html5shiv.js"></script>
|
||||
<script src="__static__/common/js/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
@@ -6,11 +6,5 @@
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
<title>SentCMS网站管理系统后台</title>
|
||||
<link rel="stylesheet" type="text/css" href="__css__/style.css?time={:time()}">
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="__static__/common/js/html5shiv.js"></script>
|
||||
<script src="__static__/common/js/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body class="hold-transition skin-blue sidebar-mini">
|
||||
@@ -6,7 +6,7 @@
|
||||
<h3 class="box-title">{$meta_title}</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<a class="btn btn-sm btn-primary" id="action_add" href="{:url('/admin/wechat/add')}">新 增</a>
|
||||
<button class="btn btn-sm btn-danger ajax-post confirm" data-form="ids" url="{:url('/admin/wechat/del')}">删 除</button>
|
||||
<button class="btn btn-sm btn-danger ajax-post confirm" data-form="ids" url="{:url('/admin/wechat/delete')}">删 除</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
@@ -18,7 +18,8 @@
|
||||
<th class="">编号</th>
|
||||
<th class="">名称</th>
|
||||
<th class="">类型</th>
|
||||
<th class="">appid</th>
|
||||
<th class="">微信appid</th>
|
||||
<th class="">微信秘钥</th>
|
||||
<th class="">创建时间</th>
|
||||
<th class="">操作</th>
|
||||
</tr>
|
||||
@@ -28,9 +29,10 @@
|
||||
<tr>
|
||||
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
|
||||
<td>{$item['id']}</td>
|
||||
<td>{$item['name']}</td>
|
||||
<td>{$item['title']}</td>
|
||||
<td>{$item['type_text']}</td>
|
||||
<td>{$item['appid']}</td>
|
||||
<td>{$item['app_id']}</td>
|
||||
<td>{$item['secret']}</td>
|
||||
<td>{$item['update_time']}</td>
|
||||
<td>
|
||||
<a href="{:url('/admin/wechat/edit', ['id'=>$item['id']])}">编辑</a>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<!-- 标题栏 -->
|
||||
<h3 class="box-title">{$meta_title}</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<a class="btn btn-sm btn-warning ajax-get confirm" href="{:url('/admin/wechat/addpay')}"><i class="fa fa-plus"></i> 添加</a>
|
||||
<a class="btn btn-sm btn-primary" href="{:url('/admin/wechat/addpay')}"><i class="fa fa-plus"></i> 添加</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,15 +16,31 @@
|
||||
<tr>
|
||||
<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
|
||||
<th class="">编号</th>
|
||||
<th class="">行为名称</th>
|
||||
<th class="">执行者</th>
|
||||
<th class="">appid</th>
|
||||
<th class="">商户ID</th>
|
||||
<th class="">执行时间</th>
|
||||
<th class="">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{volist name="list" id="item"}
|
||||
<tr>
|
||||
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
|
||||
<td>{$item['id']}</td>
|
||||
<td>{$item['app_id']}</td>
|
||||
<td>{$item['mch_id']}</td>
|
||||
<td>{$item['update_time']}</td>
|
||||
<td>
|
||||
<a href="{:url('/admin/wechat/editpay', ['id'=>$item['id']])}">编辑</a>
|
||||
<a href="{:url('/admin/wechat/deletepay', ['id'=>$item['id']])}" class="confirm ajax-get">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- 分页 -->
|
||||
{$page|raw}
|
||||
<!-- /分页 -->
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
@@ -6,6 +6,9 @@
|
||||
.img-list .item .thumb{margin: 5px; border: 1px solid #efefef; height: 120px; border-radius: 4px; position: relative; cursor: pointer; overflow: hidden;}
|
||||
.img-list .item .thumb img{width: 100%;}
|
||||
.img-list .item .selected .ok{position: absolute; right: 0; bottom: 0; width: 0; height: 0; border-left: 50px solid transparent; border-bottom: 50px solid #56b0fa;}
|
||||
.file-list{padding: 5px; height: 300px; overflow-y: scroll; display: flex; flex-direction: column; border: 1px dashed #999999;}
|
||||
.file-list .item .attach{margin: 5px; padding: 0 10px; line-height: 35px; border: 1px solid #efefef; position: relative; cursor: pointer; overflow: hidden;}
|
||||
.file-list .item .selected .ok{position: absolute; right: 0; bottom: 0; width: 0; height: 0; border-left: 50px solid transparent; border-bottom: 50px solid #56b0fa;}
|
||||
.page{height: 45px;}
|
||||
.page .pagination{margin: 0;}
|
||||
</style>
|
||||
@@ -19,6 +22,7 @@
|
||||
{if empty($list)}
|
||||
<p class="no-data">无{if $param['type'] == 'image'}图片{else/}文件{/if}</p>
|
||||
{else/}
|
||||
{if $param['type'] == 'image'}
|
||||
<div class="img-list">
|
||||
{volist name="list" id="item"}
|
||||
<div class="item">
|
||||
@@ -26,6 +30,15 @@
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
{else/}
|
||||
<div class="file-list">
|
||||
{volist name="list" id="item"}
|
||||
<div class="item">
|
||||
<div class="attach" data-id="{$item['id']}" data-url="{$item['url']}" data-savename="{$item['savename']}">{$item['savename']}<div class="ok"></div></div>
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
<div class="row" style="padding-top: 10px;">
|
||||
<div class="col-xs-10 page">{$page|raw}</div>
|
||||
|
||||
Reference in New Issue
Block a user