[更新]微信多图文模块

This commit is contained in:
邹景立 2017-04-24 16:58:07 +08:00
parent cb7a03fcc0
commit 8f943a9ae5
3 changed files with 138 additions and 21 deletions

View File

@ -33,6 +33,24 @@ class News extends BasicAdmin {
*/
protected $table = 'WechatNews';
/**
* 图文列表
*/
public function index() {
$this->assign('title', '图文列表');
parent::_list();
}
/**
* 图文列表数据处理
* @param $data
*/
protected function _index_data_filter(&$data) {
foreach ($data as &$vo) {
$vo = WechatService::getNewsById($vo['id']);
}
}
/**
* 添加图文
* @return \think\response\View

View File

@ -140,11 +140,11 @@
/*! 编辑器初始化成功 */
editor.ready(function () {
var $form = $('form[name="news"]');
var $form = $('form[name="news"]'), $body = $('body');
$form.validate();
// 数据提交
/*! 数据提交 */
$form.find('button[data-submit]').on('click', function () {
var data = [];
$form.submit();
@ -160,7 +160,7 @@
$.form.load('__SELF__', {data: data}, "post");
});
// 输入标题显示
/*! 输入标题显示 */
$form.find('[name="title"]').on('keyup', function () {
if ($item) {
if (('' + this.value).length > 0) {
@ -220,34 +220,38 @@
editor.setContent(data.content);
}
/*! jQuery事件绑定 */
$('body').off('click', '.news-box .article-add').on('click', '.news-box .article-add', function () {
/*! 添加新图文 */
/*! 添加新图文 */
$body.off('click', '.news-box .article-add').on('click', '.news-box .article-add', function () {
var $html = $('<div class="news-item transition" style="background-image:url(__PUBLIC__/static/plugs/uploader/theme/image.png)"><span class="news-title" style="display:none"></span></div><hr />');
$html.insertBefore(this).trigger('click');
if ($('.news-item').size() >= 7) {
return $(this).hide();
}
}).off('click', '.news-item').on('click', '.news-item', function () {
/*! 列表选择 */
$('.news-item').size() >= 7 && $(this).hide();
});
/*! 列表选择 */
$body.off('click', '.news-item').on('click', '.news-item', function () {
if (syncEditor($('.news-item.active'))) {
$(this).addClass('active').siblings().removeClass('active');
showEditor($item);
}
}).off('mouseleave').on('mouseleave', '.news-item', function () {
/*! 隐藏删除按钮 */
});
/*! 隐藏删除按钮 */
$body.off('mouseleave').on('mouseleave', '.news-item', function () {
$(this).find('.upload-multiple-close').addClass('hide');
}).off('mouseenter', '.news-item').on('mouseenter', '.news-item', function () {
/*! 显示删除按钮 */
});
/*! 显示删除按钮 */
$body.off('mouseenter', '.news-item').on('mouseenter', '.news-item', function () {
$('.upload-multiple-close').addClass('hide');
$(this).find('.upload-multiple-close').removeClass('hide');
}).off('click', '.upload-multiple-close').on('click', '.upload-multiple-close', function () {
/*! 删除操作图文 */
$(this).parents('.news-item').remove();
if ($('.news-item').size() < 7) {
$('.news-box .article-add').show();
}
});
/*! 删除操作图文 */
$body.off('click', '.upload-multiple-close').on('click', '.upload-multiple-close', function () {
$(this).parents('.news-item').remove();
$('.news-item').size() < 7 && $('.news-box .article-add').show();
});
/*! 默认显示第一个 */
$('.news-box .news-item:first').trigger('click');
});

View File

@ -0,0 +1,95 @@
{extend name='extra@admin/content' /}
{block name='content'}
{foreach $list as $key=>$vo}
<style>
#news-list li {
width: 30%;
float: left;
}
#news-list li img {
width: 100%;
padding: 10px
}
</style>
<ul class="flow-default" id="news-list"></ul>
<script>
layui.use('flow', function () {
layui.flow.load({
elem: '#news-list',
scrollElem: '#news-list',
isAuto: false,
isLazyimg: true,
done: function (page, next) {
setTimeout(function () {
var lis = [];
for (var i = 0; i < 6; i++) {
lis.push('<li><img lay-src="http://s17.mogucdn.com/p2/161011/upload_279h87jbc9l0hkl54djjjh42dc7i1_800x480.jpg?v=' + ( (page - 1) * 6 + i + 1 ) + '"></li>')
}
next(lis.join(''), page < 6); //假设总页数为 6
}, 500);
}
});
});
</script>
<!--<div class="graphic web-design cbp-item" style="border:1px solid #eee;padding:8px 8px 0 8px;">-->
<!--<div class="cbp-caption">-->
<!--{foreach $vo.articles as $key=>$value}-->
<!--{if $key < 1}-->
<!--<div class="cbp-caption-defaultWrap">-->
<!--<img src="{$value.local_url}?imageMogr2/thumbnail/!338x180r/gravity/Center/crop/338x180/interlace/1">-->
<!--<span class="news-title">{$value.title}</span>-->
<!--</div>-->
<!--{else}-->
<!--<div class="cbp-caption-defaultWrap" style="background:#fff">-->
<!--<hr style="margin:10px 0 0 0">-->
<!--<div class="row">-->
<!--<div class="col-xs-8" style="padding-right:0">-->
<!--<span style="display:inline-block;max-height:4em;overflow:hidden;margin:10px 0">-->
<!--{$value.title}-->
<!--</span>-->
<!--</div>-->
<!--<div class="col-xs-4" style="padding-left:0">-->
<!--<img style="margin:10px 0"-->
<!--src="{$value.local_url}?imageMogr2/thumbnail/!338x260r/gravity/Center/crop/338x260/interlace/1"-->
<!--alt="">-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--{/if}-->
<!--{/foreach}-->
<!--<div class="cbp-caption-activeWrap">-->
<!--<div class="cbp-l-caption-alignCenter">-->
<!--<div class="cbp-l-caption-body">-->
<!--<a class="btn red uppercase btn red uppercase" data-tips-text="预览" data-tips-placement="bottom"-->
<!--data-phone-view='{:url("wechat/review/index")}?type=news&content={$vo.id}'>-->
<!--<i class="fa fa-eye"></i>-->
<!--</a>-->
<!--<a class="btn red uppercase btn red uppercase" data-tips-text="推送" data-title='图文推送'-->
<!--data-tips-placement="bottom" data-iframe='{"@wechat/news/push/`$vo.id`"|app_url}'><i-->
<!--class="fa fa-weixin"></i></a>-->
<!--<a class="btn red uppercase btn red uppercase" data-tips-text="编辑" data-tips-placement="bottom"-->
<!--href='{"@wechat/news/edit/`$vo.id`"|app_url}'><i class="fa fa-pencil"></i></a>-->
<!--<a class="btn red uppercase btn red uppercase" data-tips-text="删除" data-tips-placement="bottom"-->
<!--data-news-del='{$vo.id}'><i class="fa fa-trash"></i></a>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
{/foreach}
{/block}
{block name='script'}
{/block}
{block name="style"}
{/block}