|
|
@@ -17,7 +17,6 @@
|
|
|
<script src="{__MODULE_PATH}widget/qiniu-js-sdk-2.5.5.js"></script>
|
|
|
<script src="{__MODULE_PATH}widget/plupload.full.min.js"></script>
|
|
|
<script src="{__MODULE_PATH}widget/videoUpload.js"></script>
|
|
|
-
|
|
|
<style>
|
|
|
.wrapper-content {
|
|
|
padding: 0 !important;
|
|
|
@@ -76,7 +75,7 @@
|
|
|
{/block}
|
|
|
{block name="content"}
|
|
|
<div class="row">
|
|
|
- <div class="col-sm-12 panel panel-default" >
|
|
|
+ <div class="col-sm-12 panel panel-default">
|
|
|
<div class="panel-body" style="padding: 30px">
|
|
|
<form class="form-horizontal" id="signupForm">
|
|
|
<div class="form-group">
|
|
|
@@ -84,7 +83,7 @@
|
|
|
<div class="input-group">
|
|
|
<span class="input-group-addon">标题</span>
|
|
|
<input maxlength="64" placeholder="请在这里输入标题" name="title" class="layui-input" id="title" value="{$news.title}">
|
|
|
- <input type="hidden" id="id" value="{$news.id}">
|
|
|
+ <input type="hidden" id="id" value="{$news.id}">
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -101,20 +100,21 @@
|
|
|
<div class="input-group">
|
|
|
<span class="input-group-addon">文章分类</span>
|
|
|
<?php if(empty($all)){?>
|
|
|
- <select data-placeholder="请先添加文章分类" class="chosen-select" style="width:100%;" tabindex="4" name="type_id">
|
|
|
+ <select data-placeholder="请先添加文章分类" class="chosen-select" style="width:100%;" tabindex="4" name="type_id">
|
|
|
<?php }else{ ?>
|
|
|
- <select data-placeholder="选择文章分类" class="chosen-select" style="width:100%;" tabindex="4" name="type_id" {eq name="$select" value="1"}disabled="disabled"{/eq}>
|
|
|
+ <select data-placeholder="选择文章分类" class="chosen-select" style="width:100%;" tabindex="4" name="type_id" {eq name="$select" value="1"}disabled="disabled"{/eq}>
|
|
|
<?php }?>
|
|
|
{volist name="all" id="vo" key="k"}
|
|
|
{if condition="$key eq $cid"}
|
|
|
- <option value="{$key}" selected hassubinfo="true" >{$vo}</option>
|
|
|
+ <option value="{$key}" selected hassubinfo="true">{$vo}</option>
|
|
|
{elseif condition="in_array($key,$news['cid'])"}
|
|
|
- <option value="{$key}" selected hassubinfo="true" >{$vo}</option>
|
|
|
+ <option value="{$key}" selected hassubinfo="true">{$vo}</option>
|
|
|
{else/}
|
|
|
- <option value="{$key}" hassubinfo="true" >{$vo}</option>
|
|
|
+ <option value="{$key}" hassubinfo="true">{$vo}</option>
|
|
|
{/if}
|
|
|
{/volist}
|
|
|
- </select></div>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
@@ -134,7 +134,7 @@
|
|
|
{/if}
|
|
|
</div>
|
|
|
<div class="col-xs-6">
|
|
|
- <input type="file" class="upload" name="image" style="display: none;" id="image" />
|
|
|
+ <input type="file" class="upload" name="image" style="display: none;" id="image"/>
|
|
|
<br>
|
|
|
<a class="btn btn-sm add_image upload_span">上传图片</a>
|
|
|
<br>
|
|
|
@@ -180,7 +180,7 @@
|
|
|
<div class="form-group">
|
|
|
<div class="col-md-12">
|
|
|
<label style="color:#aaa">文章简介</label>
|
|
|
- <textarea id="synopsis" name="synopsis" class="layui-input" style="height:80px;resize:none;line-height:20px;color:#333;">{$news.synopsis}</textarea>
|
|
|
+ <textarea id="synopsis" name="synopsis" class="layui-input" style="height:80px;resize:none;line-height:20px;color:#333;">{$news.synopsis}</textarea>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
@@ -233,43 +233,43 @@
|
|
|
window.UMEDITOR_CONFIG.toolbar = [
|
|
|
// 加入一个 test
|
|
|
'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat |',
|
|
|
- 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize' ,
|
|
|
+ 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize',
|
|
|
'| justifyleft justifycenter justifyright justifyjustify |',
|
|
|
'link unlink | emotion selectimgs video | map',
|
|
|
'| horizontal print preview fullscreen', 'drafts', 'formula'
|
|
|
];
|
|
|
- UM.registerUI('selectimgs',function(name){
|
|
|
+ UM.registerUI('selectimgs', function (name) {
|
|
|
var me = this;
|
|
|
var $btn = $.eduibutton({
|
|
|
- icon : 'image',
|
|
|
- click : function(){
|
|
|
- createFrame('选择图片','{:Url('widget.images/index')}?fodder=editor');
|
|
|
+ icon: 'image',
|
|
|
+ click: function () {
|
|
|
+ createFrame('选择图片', '{:Url(\'widget.images/index\')}?fodder=editor');
|
|
|
},
|
|
|
title: '选择图片'
|
|
|
});
|
|
|
|
|
|
- this.addListener('selectionchange',function(){
|
|
|
- //切换为不可编辑时,把自己变灰
|
|
|
+ this.addListener('selectionchange', function () {
|
|
|
+ // 切换为不可编辑时,把自己变灰
|
|
|
var state = this.queryCommandState(name);
|
|
|
$btn.edui().disabled(state == -1).active(state == 1)
|
|
|
});
|
|
|
return $btn;
|
|
|
});
|
|
|
- //实例化编辑器
|
|
|
+ // 实例化编辑器
|
|
|
var um = UM.getEditor('myEditor', {
|
|
|
- autoTransWord: false, // 关闭自动转义
|
|
|
- allHtmlEnabled: true // 允许所有HTML
|
|
|
+ autoTransWord: false, // 关闭自动转义
|
|
|
+ allHtmlEnabled: true // 允许所有HTML
|
|
|
});
|
|
|
|
|
|
// 视频上传功能
|
|
|
- $(function() {
|
|
|
+ $(function () {
|
|
|
// 上传视频按钮点击事件
|
|
|
- $('#upload_video_btn').on('click', function() {
|
|
|
+ $('#upload_video_btn').on('click', function () {
|
|
|
if ($('#video_link').val()) {
|
|
|
// 如果输入框有值,直接设置为视频链接
|
|
|
$('#video_preview').show();
|
|
|
$('#video_preview video').attr('src', $('#video_link').val());
|
|
|
- $(this).text('上传视频');
|
|
|
+ $(this).text('确认添加');
|
|
|
} else {
|
|
|
// 否则触发文件选择
|
|
|
$('#video_file').trigger('click');
|
|
|
@@ -277,29 +277,33 @@
|
|
|
});
|
|
|
|
|
|
// 删除视频
|
|
|
- $('#delete_video').on('click', function() {
|
|
|
+ $('#delete_video').on('click', function () {
|
|
|
$('#video_link').val('');
|
|
|
$('#video_preview').hide();
|
|
|
$('#upload_video_btn').text('上传视频');
|
|
|
});
|
|
|
|
|
|
// 文件选择变化事件
|
|
|
-// 修改后的上传逻辑
|
|
|
- $('#video_file').on('change', function() {
|
|
|
+ $('#video_file').on('change', function () {
|
|
|
const file = this.files[0];
|
|
|
if (!file) return;
|
|
|
|
|
|
// 校验文件类型和大小...
|
|
|
+ if (file.type !== 'video/mp4' || file.size > 100 * 1024 * 1024) {
|
|
|
+ $eb.message('error', '请选择MP4格式视频,且大小不超过100MB');
|
|
|
+ $('#video_progress').hide();
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
// 显示进度条
|
|
|
$('#video_progress').show().find('.progress-bar').css('width', '0%');
|
|
|
|
|
|
// 获取上传凭证
|
|
|
$.ajax({
|
|
|
- url: "https://shop.yzcyzjkc.com/admin/widget.video/get_signature",
|
|
|
+ url: "{:Url('widget.video/get_signature')}",
|
|
|
type: 'GET',
|
|
|
dataType: 'json',
|
|
|
- success: function(res) {
|
|
|
+ success: function (res) {
|
|
|
// 状态码检查
|
|
|
console.log(res);
|
|
|
if (res.code !== 200) {
|
|
|
@@ -325,49 +329,55 @@
|
|
|
bucketName: data.storageName || '',
|
|
|
region: data.storageRegion || '',
|
|
|
domain: data.domain || '',
|
|
|
- uploadIng: function(progress) {
|
|
|
+ uploadIng: function (progress) {
|
|
|
$('#progress_bar').css('width', progress + '%').text(progress + '%');
|
|
|
}
|
|
|
}
|
|
|
- ).then(function(res) {
|
|
|
+ ).then(function (res) {
|
|
|
// 上传成功处理...
|
|
|
- }).catch(function(err) {
|
|
|
+ $('#video_link').val(res.url);
|
|
|
+ $('#video_preview').show();
|
|
|
+ $('#video_preview video').attr('src', res.url);
|
|
|
+ $('#upload_video_btn').text('确认添加');
|
|
|
+ $('#video_progress').hide();
|
|
|
+ $eb.message('success', '上传成功');
|
|
|
+ }).catch(function (err) {
|
|
|
$eb.message('error', '上传失败: ' + err.message);
|
|
|
+ $('#video_progress').hide();
|
|
|
});
|
|
|
},
|
|
|
- error: function(xhr) {
|
|
|
+ error: function (xhr) {
|
|
|
$eb.message('error', '网络请求失败');
|
|
|
$('#video_progress').hide();
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
-
|
|
|
});
|
|
|
|
|
|
// 选择图片
|
|
|
- function changeIMG(index,pic){
|
|
|
- $(".image_img").css('background-image',"url("+pic+")");
|
|
|
- $(".active").css('background-image',"url("+pic+")");
|
|
|
+ function changeIMG(index, pic) {
|
|
|
+ $(".image_img").css('background-image', "url(" + pic + ")");
|
|
|
+ $(".active").css('background-image', "url(" + pic + ")");
|
|
|
$('#image_input').val(pic);
|
|
|
}
|
|
|
|
|
|
// 选择图片插入到编辑器中
|
|
|
- function insertEditor(list){
|
|
|
+ function insertEditor(list) {
|
|
|
um.execCommand('insertimage', list);
|
|
|
}
|
|
|
|
|
|
// 图片上传按钮点击事件
|
|
|
- $('.upload_span').on('click',function (e) {
|
|
|
- createFrame('选择图片','{:Url('widget.images/index')}?fodder=image');
|
|
|
+ $('.upload_span').on('click', function (e) {
|
|
|
+ createFrame('选择图片', '{:Url(\'widget.images/index\')}?fodder=image');
|
|
|
})
|
|
|
|
|
|
// 编辑器上传图片
|
|
|
- $('.edui-icon-image').on('click',function (e) {
|
|
|
- createFrame('选择图片','{:Url('widget.images/index')}?fodder=image');
|
|
|
+ $('.edui-icon-image').on('click', function (e) {
|
|
|
+ createFrame('选择图片', '{:Url(\'widget.images/index\')}?fodder=image');
|
|
|
})
|
|
|
|
|
|
// 提交图文
|
|
|
- $('.save_news').on('click',function(){
|
|
|
+ $('.save_news').on('click', function () {
|
|
|
var list = {};
|
|
|
list.title = $('#title').val();
|
|
|
list.author = $('#author').val();
|
|
|
@@ -384,56 +394,56 @@
|
|
|
var Expression = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
|
|
|
var objExp = new RegExp(Expression);
|
|
|
|
|
|
- if(list.title == ''){
|
|
|
- $eb.message('error','请输入标题');
|
|
|
+ if (list.title == '') {
|
|
|
+ $eb.message('error', '请输入标题');
|
|
|
return false;
|
|
|
}
|
|
|
- if(list.author == ''){
|
|
|
- $eb.message('error','请输入作者');
|
|
|
+ if (list.author == '') {
|
|
|
+ $eb.message('error', '请输入作者');
|
|
|
return false;
|
|
|
}
|
|
|
- if(list.image_input == ''){
|
|
|
- $eb.message('error','请添加图片');
|
|
|
+ if (list.image_input == '') {
|
|
|
+ $eb.message('error', '请添加图片');
|
|
|
return false;
|
|
|
}
|
|
|
- if(list.content == ''){
|
|
|
- $eb.message('error','请输入内容');
|
|
|
+ if (list.content == '') {
|
|
|
+ $eb.message('error', '请输入内容');
|
|
|
return false;
|
|
|
}
|
|
|
- if(list.synopsis == ''){
|
|
|
- $eb.message('error','请输入简介');
|
|
|
+ if (list.synopsis == '') {
|
|
|
+ $eb.message('error', '请输入简介');
|
|
|
return false;
|
|
|
}
|
|
|
- if(list.url != '' && !objExp.test(list.url)){
|
|
|
- $eb.message('error','网址格式不正确!请重新输入');
|
|
|
+ if (list.url != '' && !objExp.test(list.url)) {
|
|
|
+ $eb.message('error', '网址格式不正确!请重新输入');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- var index = layList.layer.load(1, {shade: [0.5,'#fff']});
|
|
|
+ var index = layList.layer.load(1, {shade: [0.5, '#fff']});
|
|
|
$.ajax({
|
|
|
- url:"{:Url('add_new')}",
|
|
|
- data:list,
|
|
|
- type:'post',
|
|
|
- dataType:'json',
|
|
|
- success:function(re){
|
|
|
+ url: "{:Url('add_new')}",
|
|
|
+ data: list,
|
|
|
+ type: 'post',
|
|
|
+ dataType: 'json',
|
|
|
+ success: function (re) {
|
|
|
layer.close(index);
|
|
|
- if(re.code == 200){
|
|
|
- $eb.message('success',re.msg);
|
|
|
- setTimeout(function() {
|
|
|
+ if (re.code == 200) {
|
|
|
+ $eb.message('success', re.msg);
|
|
|
+ setTimeout(function () {
|
|
|
parent.$(".J_iframe:visible")[0].contentWindow.location.reload();
|
|
|
}, 600);
|
|
|
} else {
|
|
|
- $eb.message('error',re.msg);
|
|
|
+ $eb.message('error', re.msg);
|
|
|
}
|
|
|
},
|
|
|
- error:function() {
|
|
|
+ error: function () {
|
|
|
layer.close(index);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// 初始化选择器
|
|
|
- $(document).ready(function() {
|
|
|
+ $(document).ready(function () {
|
|
|
var config = {
|
|
|
".chosen-select": {},
|
|
|
".chosen-select-deselect": {allow_single_deselect: true},
|
|
|
@@ -447,22 +457,22 @@
|
|
|
});
|
|
|
|
|
|
// 创建弹窗框架
|
|
|
- function createFrame(title,src,opt){
|
|
|
+ function createFrame(title, src, opt) {
|
|
|
opt === undefined && (opt = {});
|
|
|
return layer.open({
|
|
|
type: 2,
|
|
|
- title:title,
|
|
|
- area: [(opt.w || 800)+'px', (opt.h || 550)+'px'],
|
|
|
+ title: title,
|
|
|
+ area: [(opt.w || 800) + 'px', (opt.h || 550) + 'px'],
|
|
|
fixed: false,
|
|
|
maxmin: true,
|
|
|
- moveOut:false,
|
|
|
- anim:5,
|
|
|
- offset:'auto',
|
|
|
- shade:0,
|
|
|
- resize:true,
|
|
|
+ moveOut: false,
|
|
|
+ anim: 5,
|
|
|
+ offset: 'auto',
|
|
|
+ shade: 0,
|
|
|
+ resize: true,
|
|
|
content: src,
|
|
|
- move:'.layui-layer-title'
|
|
|
+ move: '.layui-layer-title'
|
|
|
});
|
|
|
}
|
|
|
</script>
|
|
|
-{/block}
|
|
|
+{/block}
|