轮播列表优化

This commit is contained in:
devil 2020-06-18 01:07:49 +08:00
parent 1af85b7a96
commit 036c980b27
9 changed files with 276 additions and 339 deletions

View File

@ -49,50 +49,61 @@ class Slide extends Common
*/
public function Index()
{
//
$params = input();
//
$total = SlideService::SlideTotal($this->form_where);
// 分页
$number = MyC('admin_page_number', 10, true);
// 条件
$where = SlideService::SlideListWhere($params);
// 获取总数
$total = SlideService::SlideTotal($where);
// 分页
$page_params = array(
'number' => $number,
'total' => $total,
'where' => $params,
'page' => isset($params['page']) ? intval($params['page']) : 1,
'url' => MyUrl('admin/slide/index'),
);
$page_params = [
'number' => $this->page_size,
'total' => $total,
'where' => $this->data_request,
'page' => $this->page,
'url' => MyUrl('admin/slide/index'),
];
$page = new \base\Page($page_params);
$this->assign('page_html', $page->GetPageHtml());
// 获取列表
$data_params = array(
'm' => $page->GetPageStarNumber(),
'n' => $number,
'where' => $where,
'field' => '*',
);
$data = SlideService::SlideList($data_params);
$this->assign('data_list', $data['data']);
$data_params = [
'where' => $this->form_where,
'm' => $page->GetPageStarNumber(),
'n' => $this->page_size,
];
$ret = SlideService::SlideList($data_params);
// 是否启用
$this->assign('common_is_enable_list', lang('common_is_enable_list'));
// 基础参数赋值
$this->assign('params', $this->data_request);
$this->assign('page_html', $page->GetPageHtml());
$this->assign('data_list', $ret['data']);
return $this->fetch();
}
// 所属平台
$this->assign('common_platform_type', lang('common_platform_type'));
/**
* 详情
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-08-05T08:21:54+0800
*/
public function Detail()
{
if(!empty($this->data_request['id']))
{
// 条件
$where = [
['id', '=', intval($this->data_request['id'])],
];
// 事件类型
$this->assign('common_app_event_type', lang('common_app_event_type'));
// 参数
$this->assign('params', $params);
// 获取列表
$data_params = [
'm' => 0,
'n' => 1,
'where' => $where,
'is_category' => 1,
];
$ret = SlideService::SlideList($data_params);
$data = (empty($ret['data']) || empty($ret['data'][0])) ? [] : $ret['data'][0];
$this->assign('data', $data);
}
return $this->fetch();
}
@ -106,39 +117,32 @@ class Slide extends Common
public function SaveInfo()
{
// 参数
$params = input();
$params = $this->data_request;
// 数据
$data = [];
if(!empty($params['id']))
{
// 获取列表
$data_params = array(
$data_params = [
'm' => 0,
'n' => 1,
'where' => ['id'=>intval($params['id'])],
'field' => '*',
);
];
$ret = SlideService::SlideList($data_params);
$data = empty($ret['data'][0]) ? [] : $ret['data'][0];
}
$this->assign('data', $data);
// 是否启用
// 静态资源
$this->assign('common_is_enable_list', lang('common_is_enable_list'));
// 所属平台
$this->assign('common_platform_type', lang('common_platform_type'));
// 事件类型
$this->assign('common_app_event_type', lang('common_app_event_type'));
// 参数
$this->assign('params', $params);
// 编辑器文件存放地址
// 数据
$this->assign('editor_path_type', 'slide');
$this->assign('params', $params);
$this->assign('data', $data);
return $this->fetch();
}
@ -158,7 +162,7 @@ class Slide extends Common
}
// 开始处理
$params = input();
$params = $this->data_request;
return SlideService::SlideSave($params);
}
@ -178,7 +182,7 @@ class Slide extends Common
}
// 开始处理
$params = input();
$params = $this->data_request;
return SlideService::SlideDelete($params);
}
@ -198,7 +202,7 @@ class Slide extends Common
}
// 开始处理
$params = input();
$params = $this->data_request;
return SlideService::SlideStatusUpdate($params);
}
}

View File

@ -0,0 +1,158 @@
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\admin\form;
/**
* 轮播动态表格
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-18
* @desc description
*/
class Slide
{
// 基础条件
public $condition_base = [];
/**
* 入口
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-18
* @desc description
* @param [array] $params [输入参数]
*/
public function Run($params = [])
{
return [
// 基础配置
'base' => [
'key_field' => 'id',
'status_field' => 'is_enable',
'is_search' => 1,
'search_url' => MyUrl('admin/slide/index'),
'is_delete' => 1,
'delete_url' => MyUrl('admin/slide/delete'),
'delete_key' => 'ids',
],
// 表单配置
'form' => [
[
'view_type' => 'checkbox',
'is_checked' => 0,
'checked_text' => '反选',
'not_checked_text' => '全选',
'align' => 'center',
'width' => 80,
],
[
'label' => '名称',
'view_type' => 'field',
'view_key' => 'name',
'search_config' => [
'form_type' => 'input',
'where_type' => 'like',
],
],
[
'label' => '所属平台',
'view_type' => 'field',
'view_key' => 'platform_text',
'search_config' => [
'form_type' => 'select',
'form_name' => 'platform',
'where_type' => 'in',
'data' => lang('common_platform_type'),
'data_key' => 'value',
'data_name' => 'name',
'is_multiple' => 1,
],
],
[
'label' => '图片',
'view_type' => 'module',
'view_key' => 'slide/module/images',
'grid_size' => 'sm',
],
[
'label' => '事件类型',
'view_type' => 'field',
'view_key' => 'event_type_text',
'search_config' => [
'form_type' => 'select',
'form_name' => 'event_type',
'where_type' => 'in',
'data' => lang('common_app_event_type'),
'data_key' => 'value',
'data_name' => 'name',
'is_multiple' => 1,
],
],
[
'label' => '事件值',
'view_type' => 'field',
'view_key' => 'event_value',
'search_config' => [
'form_type' => 'input',
'where_type' => 'like',
],
],
[
'label' => '是否启用',
'view_type' => 'status',
'view_key' => 'is_enable',
'post_url' => MyUrl('admin/slide/statusupdate'),
'is_form_su' => 1,
'align' => 'center',
'search_config' => [
'form_type' => 'select',
'where_type' => 'in',
'data' => lang('common_is_enable_list'),
'data_key' => 'id',
'data_name' => 'name',
'is_multiple' => 1,
],
],
[
'label' => '排序',
'view_type' => 'field',
'view_key' => 'sort',
],
[
'label' => '创建时间',
'view_type' => 'field',
'view_key' => 'add_time',
'search_config' => [
'form_type' => 'datetime',
],
],
[
'label' => '更新时间',
'view_type' => 'field',
'view_key' => 'upd_time',
'search_config' => [
'form_type' => 'datetime',
],
],
[
'label' => '操作',
'view_type' => 'operate',
'view_key' => 'slide/module/operate',
'align' => 'center',
'fixed' => 'right',
],
],
];
}
}
?>

View File

@ -0,0 +1,2 @@
<!-- 继承公共的 form -->
{{extend name="public/module/detail" /}}

View File

@ -1,211 +1,9 @@
{{include file="public/header" /}}
<!-- 继承公共的 form -->
{{extend name="public/module/form" /}}
<!-- right content start -->
<div class="content-right">
<div class="content">
<!-- form start -->
<form class="am-form form-validation form-search" method="post" action="{{:MyUrl('admin/slide/index')}}" request-type="form">
<div class="thin">
<div class="am-input-group am-input-group-sm am-fl so">
<input type="text" autocomplete="off" name="keywords" class="am-radius" placeholder="名称" value="{{if !empty($params.keywords)}}{{$params.keywords}}{{/if}}" />
<span class="am-input-group-btn">
<button class="am-btn am-btn-default am-radius" type="submit" data-am-loading="{spinner:'circle-o-notch', loadingText:'搜索中...'}">搜索</button>
</span>
</div>
<label class="am-fl thin_sub more-submit">
更多筛选条件
{{if isset($params['is_more']) and $params['is_more'] eq 1}}
<input type="checkbox" name="is_more" value="1" id="is_more" checked />
<i class="am-icon-angle-up"></i>
{{else /}}
<input type="checkbox" name="is_more" value="1" id="is_more" />
<i class="am-icon-angle-down"></i>
{{/if}}
</label>
</div>
<table class="so-list more-where {{if !isset($params['is_more'])}}none{{/if}}">
<tbody>
<tr>
<td>
<span>启用:</span>
<select name="is_enable" class="chosen-select" data-placeholder="是否启用...">
<option value="-1">是否启用...</option>
{{foreach $common_is_enable_list as $v}}
<option value="{{$v.id}}" {{if isset($params['is_enable']) and $params['is_enable'] eq $v['id']}}selected{{/if}}>{{$v.name}}</option>
{{/foreach}}
</select>
</td>
<td>
<span>平台:</span>
<select name="platform" class="chosen-select" data-placeholder="所属平台...">
<option value="">所属平台...</option>
{{foreach $common_platform_type as $v}}
<option value="{{$v.value}}" {{if isset($params['platform']) and $params['platform'] eq $v['value']}}selected{{/if}}>{{$v.name}}</option>
{{/foreach}}
</select>
</td>
</tr>
<tr>
<td>
<span>类型:</span>
<select name="event_type" class="chosen-select" data-placeholder="事件类型...">
<option value="-1">事件类型...</option>
{{foreach $common_app_event_type as $v}}
<option value="{{$v.value}}" {{if isset($params['event_type']) and $params['event_type'] eq $v['value']}}selected{{/if}}>{{$v.name}}</option>
{{/foreach}}
</select>
</td>
<td class="time">
<span>时间:</span>
<span>
<input type="text" autocomplete="off" name="time_start" class="am-form-field am-input-sm am-radius Wdate" placeholder="起始时间" value="{{if !empty($params.time_start)}}{{$params.time_start}}{{/if}}" data-validation-message="日期格式有误" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd'})" autocomplete="off" /><i class="am-icon-calendar"></i>
</span>
<em class="text-grey">~</em>
<span>
<input type="text" autocomplete="off" name="time_end" class="am-form-field am-input-sm am-radius Wdate" placeholder="结束时间" value="{{if !empty($params.time_end)}}{{$params.time_end}}{{/if}}" pattern="^[0-9]{4}-[0-9]{2}-[0-9]{2}$" data-validation-message="日期格式有误" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd'})" autocomplete="off" /><i class="am-icon-calendar"></i>
</span>
</td>
</tr>
<tr>
<td class="time"></td>
<td>
<button type="submit" class="am-btn am-btn-primary am-radius am-btn-xs btn-loading-example" data-am-loading="{spinner:'circle-o-notch', loadingText:'搜索中...'}">搜索</button>
<a href="{{:MyUrl('admin/slide/index')}}" class="am-btn am-btn-warning am-radius am-btn-sm reset-submit">清除条件</a>
</td>
</tr>
</tbody>
</table>
</form>
<!-- form end -->
<!-- operation start -->
<div class="am-g am-margin-top-sm">
<a href="{{:MyUrl('admin/slide/saveinfo')}}" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus"> 新增</a>
</div>
<!-- operation end -->
<!-- list start -->
<div class="am-scrollable-horizontal am-table-scrollable-horizontal am-margin-top-sm">
<table class="am-table am-table-striped am-table-hover am-table-bordered am-text-nowrap am-table-td-fixed-last">
<thead>
<tr>
<th>名称</th>
<th>所属平台</th>
<th class="am-grid-sm">图片</th>
<th class="am-grid-lg">事件值</th>
<th class="am-text-center">是否启用</th>
<th class="am-text-center">更多</th>
<th class="am-text-center">操作</th>
</tr>
</thead>
<tbody>
{{if !empty($data_list)}}
{{foreach $data_list as $v}}
<tr id="data-list-{{$v.id}}" {{if $v['is_enable'] eq 0}}class="am-active"{{/if}}>
<td class="am-text-middle">{{$v.name}}</td>
<td class="am-text-middle">{{$v.platform_text}}</td>
<td {{if !empty($v['bg_color'])}}style="background-color:{{$v.bg_color}};"{{/if}}>
{{if !empty($v['images_url'])}}
<a href="{{$v['images_url']}}" target="_blank">
<img src="{{$v['images_url']}}" class="am-radius" width="100" height="60" />
</a>
{{else /}}
<span class="cr-ddd">暂无图片</span>
{{/if}}
</td>
<td class="am-text-middle am-nowrap-initial">
{{$v.event_value}}
{{if !empty($v['event_type_text'])}}
<br /><span class="am-badge am-badge-warning am-radius">{{$v.event_type_text}}</span>
{{/if}}
</td>
<td class="am-text-middle am-text-center">
<a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['is_enable'] eq 1}}am-success{{else /}}am-default{{/if}}" data-url="{{:MyUrl('admin/slide/statusUpdate')}}" data-id="{{$v.id}}" data-state="{{$v['is_enable']}}" data-is-update-status="1"></a>
</td>
<td class="am-text-middle">
<p class="am-text-center xo-cursor-pr">
<i class="am-icon-caret-down"></i>
<span data-am-modal="{target: '#my-popup{{$v.id}}'}"> 查看更多</span>
</p>
<div class="am-popup am-radius" id="my-popup{{$v.id}}">
<div class="am-popup-inner">
<div class="am-popup-hd">
<h4 class="am-popup-title">详情内容</h4>
<span data-am-modal-close
class="am-close">&times;</span>
</div>
<div class="am-popup-bd">
<dl class="dl-content">
<dt>名称</dt>
<dd>{{$v.name}}</dd>
<dt>所属平台</dt>
<dd>{{$v.platform_text}}</dd>
<dt>图片</dt>
<dd>
{{if !empty($v['images_url'])}}
<a href="{{$v['images_url']}}" target="_blank">
<img src="{{$v['images_url']}}" class="am-radius" width="100" height="60" />
</a>
{{else /}}
<span class="cr-ddd">暂无图片</span>
{{/if}}
</dd>
<dt>事件值</dt>
<dd class="am-nowrap-initial">
{{$v.event_value}}
{{if !empty($v['event_type_text'])}}
<br /><span class="am-badge am-badge-warning am-radius">{{$v.event_type_text}}</span>
{{/if}}
</dd>
<dt>启用</dt>
<dd>{{$v.is_enable_text}}</dd>
<dt>创建时间</dt>
<dd>{{$v.add_time_time}}</dd>
<dt>更新时间</dt>
<dd>{{$v.upd_time_time}}</dd>
</dl>
</div>
</div>
</div>
</td>
<td class="am-operate-grid">
<div class="am-scrollable-vertical">
<a class="am-btn am-btn-secondary am-btn-xs am-radius am-btn-block" href="{{:MyUrl('admin/slide/saveinfo', array_merge($params, ['id'=>$v['id']]))}}">
<i class="am-icon-edit"></i>
<span>编辑</span>
</a>
<button class="am-btn am-btn-danger am-btn-xs am-radius am-btn-block submit-delete" data-url="{{:MyUrl('admin/slide/delete')}}" data-id="{{$v.id}}">
<i class="am-icon-trash-o"></i>
<span>删除</span>
</button>
</div>
</td>
</tr>
{{/foreach}}
{{/if}}
</tbody>
</table>
{{if empty($data_list)}}
<div class="table-no"><i class="am-icon-warning"></i> 没有相关数据</div>
{{/if}}
</div>
<!-- list end -->
<!-- page start -->
{{if !empty($data_list)}}
{{$page_html|raw}}
{{/if}}
<!-- page end -->
</div>
</div>
<!-- right content end -->
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->
<!-- 表单顶部操作栏 -->
{{block name="form_operate_top"}}
<a href="{{:MyUrl('admin/slide/saveinfo')}}" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus"> 新增</a>
<!-- 父级内容 -->
{__block__}
{{/block}}

View File

@ -0,0 +1,10 @@
<!-- 商品基础信息 -->
{{if !empty($module_data)}}
<div {{if !empty($module_data['bg_color'])}}style="background-color:{{$module_data.bg_color}};"{{/if}}>
{{if !empty($module_data['images_url'])}}
<a href="{{$module_data['images_url']}}" target="_blank">
<img src="{{$module_data['images_url']}}" class="am-radius" width="100" height="60" />
</a>
{{/if}}
</div>
{{/if}}

View File

@ -0,0 +1,13 @@
<!-- 操作栏 -->
<button type="button" class="am-btn am-btn-default am-btn-xs am-radius am-btn-block submit-popup" data-url="{{:MyUrl('admin/slide/detail', ['id'=>$module_data['id']])}}">
<i class="am-icon-eye"></i>
<span>详情</span>
</button>
<a class="am-btn am-btn-secondary am-btn-xs am-radius am-btn-block" href="{{:MyUrl('admin/slide/saveinfo', array('id'=>$module_data['id']))}}">
<i class="am-icon-edit"></i>
<span>编辑</span>
</a>
<button type="button" class="am-btn am-btn-danger am-btn-xs am-radius am-btn-block submit-delete" data-url="{{:MyUrl('admin/slide/delete')}}" data-id="{{$module_data.id}}" data-key="ids">
<i class="am-icon-trash-o"></i>
<span>删除</span>
</button>

View File

@ -38,7 +38,7 @@ class SlideService
$m = isset($params['m']) ? intval($params['m']) : 0;
$n = isset($params['n']) ? intval($params['n']) : 10;
$data = Db::name('Slide')->field($field)->where($where)->order('sort asc')->limit($m, $n)->select();
$data = Db::name('Slide')->field($field)->where($where)->order('id desc,sort asc')->limit($m, $n)->select();
if(!empty($data))
{
$common_platform_type = lang('common_platform_type');
@ -74,13 +74,11 @@ class SlideService
// 时间
if(isset($v['add_time']))
{
$v['add_time_time'] = date('Y-m-d H:i:s', $v['add_time']);
$v['add_time_date'] = date('Y-m-d', $v['add_time']);
$v['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
}
if(isset($v['upd_time']))
{
$v['upd_time_time'] = date('Y-m-d H:i:s', $v['upd_time']);
$v['upd_time_date'] = date('Y-m-d', $v['upd_time']);
$v['upd_time'] = empty($v['upd_time']) ? '' : date('Y-m-d H:i:s', $v['upd_time']);
}
}
}
@ -101,54 +99,6 @@ class SlideService
return (int) Db::name('Slide')->where($where)->count();
}
/**
* 列表条件
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $params [输入参数]
*/
public static function SlideListWhere($params = [])
{
$where = [];
if(!empty($params['keywords']))
{
$where[] = ['name', 'like', '%'.$params['keywords'].'%'];
}
// 是否更多条件
if(isset($params['is_more']) && $params['is_more'] == 1)
{
// 等值
if(isset($params['is_enable']) && $params['is_enable'] > -1)
{
$where[] = ['is_enable', '=', intval($params['is_enable'])];
}
if(isset($params['event_type']) && $params['event_type'] > -1)
{
$where[] = ['event_type', '=', intval($params['event_type'])];
}
if(!empty($params['platform']))
{
$where[] = ['platform', '=', $params['platform']];
}
if(!empty($params['time_start']))
{
$where[] = ['add_time', '>', strtotime($params['time_start'])];
}
if(!empty($params['time_end']))
{
$where[] = ['add_time', '<', strtotime($params['time_end'])];
}
}
return $where;
}
/**
* 数据保存
* @author Devil
@ -251,27 +201,24 @@ class SlideService
*/
public static function SlideDelete($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'id',
'error_msg' => '操作id有误',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
// 参数是否有误
if(empty($params['ids']))
{
return DataReturn($ret, -1);
return DataReturn('商品id有误', -1);
}
// 是否数组
if(!is_array($params['ids']))
{
$params['ids'] = explode(',', $params['ids']);
}
// 删除操作
if(Db::name('Slide')->where(['id'=>$params['id']])->delete())
if(Db::name('Slide')->where(['id'=>$params['ids']])->delete())
{
return DataReturn('删除成功');
}
return DataReturn('删除失败或资源不存在', -100);
return DataReturn('删除失败', -100);
}
/**
@ -291,6 +238,11 @@ class SlideService
'key_name' => 'id',
'error_msg' => '操作id有误',
],
[
'checked_type' => 'empty',
'key_name' => 'field',
'error_msg' => '未指定操作字段',
],
[
'checked_type' => 'in',
'key_name' => 'state',
@ -305,11 +257,11 @@ class SlideService
}
// 数据更新
if(Db::name('Slide')->where(['id'=>intval($params['id'])])->update(['is_enable'=>intval($params['state'])]))
if(Db::name('Slide')->where(['id'=>intval($params['id'])])->update([$params['field']=>intval($params['state']), 'upd_time'=>time()]))
{
return DataReturn('编辑成功');
}
return DataReturn('编辑失败或数据未改变', -100);
return DataReturn('编辑失败', -100);
}
}
?>

File diff suppressed because one or more lines are too long

View File

@ -90,7 +90,7 @@ Page({
player_event(e) {
var params = encodeURIComponent(JSON.stringify({type: 'detail'}));
wx.navigateTo({
url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${this.data.detail.id}&custom_params=${params}`
url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${this.data.detail.roomid}&custom_params=${params}`
});
},