[更新]微信多图文模块

This commit is contained in:
邹景立 2017-04-24 16:24:27 +08:00
parent 2696707455
commit 6c321f732a

View File

@ -67,7 +67,7 @@
<div class="col-xs-8" style="width: 400px"> <div class="col-xs-8" style="width: 400px">
<br> <br>
<a data-file="one" data-type="jpg,png,jpeg" data-field="local_url" class="btn btn-sm">上传图片</a> <a data-file="one" data-type="jpg,png,jpeg" data-field="local_url" class="btn btn-sm">上传图片</a>
<a data-iframe="{:url('@wechat/news/media')}?field=local_url" class="btn btn-sm">从图库中选择图片</a> <a data-iframe="{:url('@wechat/news/media')}?field=local_url" class="btn btn-sm">从图库中选择图片</a>
<br><br> <br><br>
<label style="margin-left:0;padding-left:10px"> <label style="margin-left:0;padding-left:10px">
<input data-auto-none type="checkbox" value="1" name="show_cover_pic"> <input data-auto-none type="checkbox" value="1" name="show_cover_pic">
@ -146,14 +146,12 @@
// 数据提交 // 数据提交
$form.find('button[data-submit]').on('click', function () { $form.find('button[data-submit]').on('click', function () {
var data = [];
$form.submit(); $form.submit();
if ($form.find('input.validate-error').size() > 0 || (editor.getContent() || '').length < 1) { if (!syncEditor($('.news-item.active'))) {
if ((editor.getContent() || '').length < 1) { editor.setContent('文章内容不能留空,请输入内容!');
editor.setContent('文章内容不能留空,请输入内容!')
}
return false; return false;
} }
var data = [];
$('.news-item').map(function () { $('.news-item').map(function () {
var item = $(this).data('item'); var item = $(this).data('item');
item.content = item.content || '文章内容不能留空,请输入内容!'; item.content = item.content || '文章内容不能留空,请输入内容!';
@ -173,8 +171,8 @@
} }
}); });
/*! 显示编辑器 */ /*! 同步编辑器 */
function showEditor($pItem) { function syncEditor($pItem) {
// 处理上一个编辑器 // 处理上一个编辑器
if ($form && $pItem && $pItem.size() > 0) { if ($form && $pItem && $pItem.size() > 0) {
var data = {}; var data = {};
@ -191,6 +189,11 @@
return false; return false;
} }
} }
return true;
}
/*! 显示编辑器 */
function showEditor() {
// 读取对象数据 // 读取对象数据
$item = $('.news-item.active'); $item = $('.news-item.active');
this.get = function () { this.get = function () {
@ -227,9 +230,10 @@
} }
}).off('click', '.news-item').on('click', '.news-item', function () { }).off('click', '.news-item').on('click', '.news-item', function () {
/*! 列表选择 */ /*! 列表选择 */
$item = $('.news-item.active'); if (syncEditor($('.news-item.active'))) {
$(this).addClass('active').siblings().removeClass('active'); $(this).addClass('active').siblings().removeClass('active');
showEditor($item); showEditor($item);
}
}).off('mouseleave').on('mouseleave', '.news-item', function () { }).off('mouseleave').on('mouseleave', '.news-item', function () {
/*! 隐藏删除按钮 */ /*! 隐藏删除按钮 */
$(this).find('.upload-multiple-close').addClass('hide'); $(this).find('.upload-multiple-close').addClass('hide');