mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
[更新]微信多图文模块
This commit is contained in:
parent
f99b446d56
commit
0b0475190e
@ -133,56 +133,51 @@
|
|||||||
require(['ueditor'], function () {
|
require(['ueditor'], function () {
|
||||||
|
|
||||||
/*! 实例富文本编辑器 */
|
/*! 实例富文本编辑器 */
|
||||||
var editor, $preItem;
|
var editor, $item;
|
||||||
|
|
||||||
/*! 默认编辑第一篇图文 */
|
/*! 默认编辑第一篇图文 */
|
||||||
editor = window.createEditor('[name="content"]', 'basic');
|
editor = window.createEditor('[name="content"]', 'basic');
|
||||||
|
|
||||||
|
/*! 编辑器初始化成功 */
|
||||||
editor.ready(function () {
|
editor.ready(function () {
|
||||||
|
|
||||||
var $form = $('form[name="news"]');
|
var $form = $('form[name="news"]');
|
||||||
|
|
||||||
// 表单验证
|
|
||||||
function verify(callback) {
|
|
||||||
$form.validate(function (ret) {
|
|
||||||
ret.content = editor.getContent();
|
|
||||||
if (ret.content.length < 1) {
|
|
||||||
return $.msg.tips('请输入图文内容!');
|
|
||||||
}
|
|
||||||
$('.news-item.active').data('item', ret);
|
|
||||||
callback.call(this.ret);
|
|
||||||
}).submit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 数据提交
|
// 数据提交
|
||||||
$form.find('button[data-submit]').on('click', function () {
|
$form.find('button[data-submit]').on('click', function () {
|
||||||
verify(function () {
|
var data = [];
|
||||||
var data = [];
|
$('.news-item').map(function () {
|
||||||
$('.news-item').map(function () {
|
data.push($(this).data('item'));
|
||||||
data.push($(this).data('item'));
|
|
||||||
});
|
|
||||||
$.form.load('__SELF__', {data: data}, "post");
|
|
||||||
});
|
});
|
||||||
|
$.form.load('__SELF__', {data: data}, "post");
|
||||||
});
|
});
|
||||||
|
|
||||||
// 输入标题显示
|
// 输入标题显示
|
||||||
$form.find('[name="title"]').on('keyup', function () {
|
$form.find('[name="title"]').on('keyup', function () {
|
||||||
console.log($preItem);
|
if ($item) {
|
||||||
if ($preItem) {
|
|
||||||
if (('' + this.value).length > 0) {
|
if (('' + this.value).length > 0) {
|
||||||
$preItem.find('.news-title').html(this.value).show();
|
$item.find('.news-title').html(this.value).show();
|
||||||
} else {
|
} else {
|
||||||
$preItem.find('.news-title').html(this.value).hide();
|
$item.find('.news-title').html(this.value).hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*! 显示编辑器 */
|
/*! 显示编辑器 */
|
||||||
function showEditor() {
|
function showEditor($pItem) {
|
||||||
var $item = $('.news-item.active');
|
|
||||||
// 处理上一个编辑器
|
// 处理上一个编辑器
|
||||||
$preItem = $item;
|
if ($form && $pItem && $pItem.size() > 0) {
|
||||||
|
var data = {};
|
||||||
|
data.title = $form.find('[name=title]').val();
|
||||||
|
data.local_url = $form.find('[name=local_url]').val();
|
||||||
|
data.content = editor.getContent();
|
||||||
|
data.author = $form.find('[name=author]').val();
|
||||||
|
data.show_cover_pic = $form.find('[name="show_cover_pic"]').get(0).checked ? 1 : 0;
|
||||||
|
$form.find('[name=local_url]').trigger('change');
|
||||||
|
$pItem.data('item', data);
|
||||||
|
}
|
||||||
// 读取对象数据
|
// 读取对象数据
|
||||||
|
$item = $('.news-item.active');
|
||||||
this.get = function () {
|
this.get = function () {
|
||||||
var data = $item.data('item') || {};
|
var data = $item.data('item') || {};
|
||||||
data.title = data.title || '';
|
data.title = data.title || '';
|
||||||
@ -192,7 +187,9 @@
|
|||||||
data.show_cover_pic = data.show_cover_pic || 0;
|
data.show_cover_pic = data.show_cover_pic || 0;
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
// 重置表单
|
||||||
$form.get(0).reset();
|
$form.get(0).reset();
|
||||||
|
// 获取当前数据
|
||||||
var data = this.get();
|
var data = this.get();
|
||||||
for (var i in data) {
|
for (var i in data) {
|
||||||
if (i !== 'content' && i !== 'show_cover_pic') {
|
if (i !== 'content' && i !== 'show_cover_pic') {
|
||||||
@ -215,8 +212,9 @@
|
|||||||
}
|
}
|
||||||
}).off('click', '.news-item').on('click', '.news-item', function () {
|
}).off('click', '.news-item').on('click', '.news-item', function () {
|
||||||
/*! 列表选择 */
|
/*! 列表选择 */
|
||||||
|
$item = $('.news-item.active');
|
||||||
$(this).addClass('active').siblings().removeClass('active');
|
$(this).addClass('active').siblings().removeClass('active');
|
||||||
showEditor();
|
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');
|
||||||
@ -259,11 +257,9 @@
|
|||||||
height: 150px;
|
height: 150px;
|
||||||
max-width: 270px;
|
max-width: 270px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background-size: 100%;
|
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
background-repeat: no-repeat;
|
background-size: cover;
|
||||||
background-position: center center;
|
background-position: center center;
|
||||||
background-image: url('__PUBLIC__/static/plugs/uploader/theme/image.png');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.news-left .news-item.active {
|
.news-left .news-item.active {
|
||||||
@ -312,10 +308,8 @@
|
|||||||
.news-right .upload-image-box {
|
.news-right .upload-image-box {
|
||||||
width: 150px;
|
width: 150px;
|
||||||
height: 120px;
|
height: 120px;
|
||||||
background-size: 100%;
|
background-size: cover;
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center center;
|
background-position: center center;
|
||||||
background-image: url('__PUBLIC__/static/plugs/uploader/theme/image.png');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.panel {
|
.panel {
|
||||||
|
@ -67,9 +67,8 @@ define(['zeroclipboard'], function (ZeroClipboard) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局编辑器生成器
|
* 全局编辑器生成器
|
||||||
* @param {type} selector
|
* @param {string} selector
|
||||||
* @param {type} type
|
* @param {string} type
|
||||||
* @returns {unresolved}
|
|
||||||
*/
|
*/
|
||||||
window.createEditor = function (selector, type) {
|
window.createEditor = function (selector, type) {
|
||||||
type = type || 'basic';
|
type = type || 'basic';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user