初始上传
This commit is contained in:
427
addon/giftcard/shop/view/media/lists.html
Executable file
427
addon/giftcard/shop/view/media/lists.html
Executable file
@@ -0,0 +1,427 @@
|
||||
<link rel="stylesheet" type="text/css" href="SHOP_CSS/picture_manager.css" />
|
||||
<style>
|
||||
.album-box .album-img-box{display: flex;flex-wrap: wrap;}
|
||||
.album-box .album-content{margin-top: 10px;}
|
||||
.album-box .album-img-box li{margin: 0 13px 20px 0;position: relative;width: 290px;height: 187.5px;cursor: pointer;border: 1px solid #ccc;padding: 2px;}
|
||||
.album-box .album-img-box li.selected{border-color: var(--base-color);}
|
||||
.album-box .album-img-box li.selected .iconfont{color: var(--base-color);}
|
||||
.album-box .album-img-box li .iconfont{position: absolute;bottom: 0;right: 0;font-size: 30px;color: transparent;}
|
||||
.album-box .album-img-box li .album-pic{width: 100%;height: 100%;background-size: 100% 100%;background-repeat: no-repeat;background-position: center;}
|
||||
.album-box .album-img-box li .album-img-operation{position: absolute;top: 0;right: 0;bottom: 0;left: 0;background-color: rgba(0, 0, 0, .5);display: none;align-items: center;justify-content: center;color: #fff;}
|
||||
.album-box .album-img-box li .album-img-operation a{margin: 0 12px;color: #fff;font-size: 14px;}
|
||||
.multuple-list{max-height: 275px; height: auto;}
|
||||
.upload-attention{margin-left: 75px;}
|
||||
.multuple-list-box{display: flex;flex-direction: column;height: 100%;}
|
||||
.multuple-list-box .form-row{margin-top: auto;}
|
||||
.album-box .album-img-box li:hover .album-img-operation{display: flex;}
|
||||
.album-foot-operation{margin-top: auto;display: flex;justify-content: flex-end;padding: 0 25px;}
|
||||
.preview-img .layui-layer-content{padding: 0;}
|
||||
.album-content .album-img-box li:nth-child(7n){margin-right: 13px;}
|
||||
</style>
|
||||
|
||||
<!-- 清理网站缓存 start-->
|
||||
<meta http-equiv="pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store">
|
||||
<meta http-equiv="expires" content="0">
|
||||
<!-- 清理网站缓存 end-->
|
||||
|
||||
<!-- 搜索框 -->
|
||||
<div class="single-filter-box">
|
||||
<button class="layui-btn" onclick="uploadImg()">添加素材</button>
|
||||
</div>
|
||||
<div class="album-box">
|
||||
<div class="album-content">
|
||||
<ul class="album-img-box"></ul>
|
||||
<div class="album-foot-operation">
|
||||
<div id="paged" class="page"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 存储图片路径 -->
|
||||
<input type="hidden" id="hidden_image_path">
|
||||
</div>
|
||||
|
||||
<!-- 相册展示 -->
|
||||
<script type="text/html" id="list_html">
|
||||
{{# layui.each(d.list,function(index, item){ }}
|
||||
<li class="img layui-show">
|
||||
<img class="album-pic" src="{{ ns.img(item.media_path + '?time=' + parseInt(new Date().getTime()/1000)) }}" onerror="onerrorFn(this)">
|
||||
<div class="album-img-operation">
|
||||
<a href="javascript:;" data-id="{{item.media_id}}" onclick="previewFile('{{item.media_path}}','{{item.media_spec}}',this)">预览</a> |
|
||||
<a href="javascript:;" data-id="{{item.media_id}}" onclick="modifyFile(this)">替换</a> |
|
||||
<a href="javascript:;" class="delete-pic" data-id="{{item.media_id}}" onclick="deleteImg(this)">删除</a>
|
||||
</div>
|
||||
<i class="iconfont iconxuanzhong"></i>
|
||||
</li>
|
||||
{{# }) }}
|
||||
</script>
|
||||
|
||||
<!-- 多图上传 -->
|
||||
<script type="text/html" id="multuple_html">
|
||||
<div class="layui-form multuple-list-box">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">本地图片</label>
|
||||
<ul class="layui-input-block multuple-list">
|
||||
<li class="multuple-list-img" id="ImgUpload">
|
||||
<span class="bg-color">+</span>
|
||||
<span>点击添加图片</span>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="upload-attention">请上传320*220素材图片</p>
|
||||
</div>
|
||||
<div class="form-row sm">
|
||||
<button class="layui-btn layui-btn-disabled" disabled="disabled" onclick="submitOne()" id="chooseListAction">提交</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 替换图片 -->
|
||||
<script type="text/html" id="modify_file_html">
|
||||
<div class="layui-form multuple-list-box">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">本地图片</label>
|
||||
<ul class="layui-input-block multuple-list">
|
||||
<li class="multuple-list-img" id="modifyFile">
|
||||
<span class="bg-color">+</span>
|
||||
<span>点击添加图片</span>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="upload-attention">请上传320*220素材图片</p>
|
||||
</div>
|
||||
<div class="form-row sm">
|
||||
<button class="layui-btn layui-btn-disabled" disabled="disabled" id="modifyFileAction">提交</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var form, upload, laytpl, layer, laypage, layer_one,element,
|
||||
picture_arr = [],
|
||||
initIdent= true,
|
||||
limit = 10,
|
||||
album_list_count = 0;
|
||||
var repeat_flag = false;
|
||||
|
||||
$(function() {
|
||||
layui.use(['form', 'laytpl', 'laypage', 'layer', 'upload', 'element'], function () {
|
||||
form = layui.form;
|
||||
laytpl = layui.laytpl;
|
||||
laypage = layui.laypage;
|
||||
element = layui.element;
|
||||
layer = layui.layer;
|
||||
upload = layui.upload;
|
||||
|
||||
init(); //初始化数据
|
||||
form.render();
|
||||
element.init();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 图片加载
|
||||
*/
|
||||
function getFileAlbumList(page, limit) {
|
||||
$.ajax({
|
||||
url: ns.url("giftcard://shop/media/lists"),
|
||||
type: "POST",
|
||||
dataType: "JSON",
|
||||
async: false,
|
||||
data: {
|
||||
pic_name: $(".album-img-sreach").val(),
|
||||
page_size:limit,
|
||||
page
|
||||
},
|
||||
success: function(res) {
|
||||
res.data.status = $('.album-content-title .edit').attr('data-status');
|
||||
laytpl($("#list_html").html()).render(res.data, function(html) {
|
||||
$(".album-img-box").html(html);
|
||||
loadImgMagnify();
|
||||
});
|
||||
if(initIdent){
|
||||
album_list_count = res.data.list.length;
|
||||
$(".default-group .num").text(album_list_count);
|
||||
initIdent = false;
|
||||
}
|
||||
$("#paged").empty();
|
||||
if (res.data.count > 0) {
|
||||
//调用分页
|
||||
laypage.render({
|
||||
elem: "paged",
|
||||
count: res.data.count,
|
||||
curr: page, //当前页
|
||||
limit: limit,
|
||||
jump: function(obj, first) {
|
||||
if (!first) {
|
||||
getFileAlbumList(obj.curr, obj.limit);
|
||||
}
|
||||
form.render('checkbox');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 图片替换
|
||||
function modifyFile(data) {
|
||||
laytpl($("#modify_file_html").html()).render({}, function(html) {
|
||||
layer_one = layer.open({
|
||||
type: 1,
|
||||
area: ['580px', '500px'],
|
||||
title: '替换图片',
|
||||
content: html,
|
||||
cancel: function() {
|
||||
$("#modifyFileAction").removeClass("bg-color").addClass("layui-btn-disabled").attr("disabled", "disabled");
|
||||
},
|
||||
success: function(res) {
|
||||
//上传图片
|
||||
upload.render({
|
||||
elem: '#modifyFile',
|
||||
url: ns.url("giftcard://shop/media/modifyFile"),
|
||||
data: {
|
||||
media_id: $(data).attr('data-id')
|
||||
},
|
||||
multiple: true,
|
||||
auto: false,
|
||||
bindAction: '#modifyFileAction',
|
||||
choose: function(obj) {
|
||||
//将每次选择的文件追加到文件队列
|
||||
var files = this.files = obj.pushFile();
|
||||
//预读本地文件,如果是多文件,则会遍历。(不支持ie8/9)
|
||||
obj.preview(function(index, file, result) {
|
||||
//追加预览图片
|
||||
var html = '';
|
||||
html += '<li class="multuple-list-img upload-wrap" index="' + index + '">';
|
||||
html += '<img src="' + result + '" alt="' + file.name + '">';
|
||||
html += '<span class="upload-close-modal" id="upload_img_' + index + '">×</span>';
|
||||
html += '<div class="upload-image-curtain">50%</div>';
|
||||
html += '<div class="tips"></div>';
|
||||
html += '</li>';
|
||||
$(".multuple-list").prepend(html);
|
||||
|
||||
//删除预览图片
|
||||
$("#upload_img_" + index).bind("click", function() {
|
||||
delete files[index];
|
||||
delete picture_arr[index]; //删除所选队列
|
||||
$(this).parent('.upload-wrap').remove();
|
||||
|
||||
// uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值,以免删除后出现同名文件不可选
|
||||
|
||||
//禁止点击
|
||||
if ($(".multuple-list li").length <= 1) {
|
||||
$("#modifyFileAction").removeClass("bg-color").addClass("layui-btn-disabled").attr("disabled", "disabled");
|
||||
//未选择图片时,显示添加按钮
|
||||
$("#modifyFile").show();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//禁止点击
|
||||
if ($(".multuple-list li").length > 1) {
|
||||
$("#modifyFileAction").addClass("bg-color").removeClass("layui-btn-disabled").removeAttr("disabled");
|
||||
//隐藏添加按钮,仅替换一张图片
|
||||
$("#modifyFile").hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
done: function(res, index) {
|
||||
picture_arr.push(res.data);
|
||||
var image_box = $(".upload-wrap[index='" + index + "']").parent().find(".upload-image-curtain");
|
||||
var image_tips = $(".upload-wrap[index='" + index + "']").parent().find(".tips");
|
||||
image_box.text("50%");
|
||||
image_box.show();
|
||||
if (res.code >= 0) {
|
||||
setTimeout(function() {
|
||||
image_box.text("100%");
|
||||
}, 500);
|
||||
setTimeout(function() {
|
||||
getFileAlbumList(1, limit);
|
||||
layer.close(layer_one);
|
||||
}, 1000);
|
||||
return delete this.files[index]; //删除文件队列已经上传成功的文件
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
image_box.text("上传失败");
|
||||
image_tips.text(res.message);
|
||||
layer.close(layer_one);
|
||||
}, 500);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 预览图片
|
||||
function previewFile(path, spec,data){
|
||||
let val = $(data).parent().parent().find('img').attr("data-isShow");
|
||||
if(val){
|
||||
layer.msg("图片无法进行预览!")
|
||||
return false;
|
||||
}
|
||||
spec = spec.split("*");
|
||||
layer.open({
|
||||
type:1,
|
||||
title: false,
|
||||
closeBtn: 0,
|
||||
shadeClose: true,
|
||||
area: [spec[0]+'px', spec[1]+'px'], //宽高
|
||||
content: "<img src=" + ns.img(path) + " />",
|
||||
skin: 'preview-img'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
function init() {
|
||||
getFileAlbumList(1, limit); //图片加载
|
||||
}
|
||||
|
||||
/**
|
||||
* 多图上传
|
||||
*/
|
||||
function uploadImg() {
|
||||
var imageArray=1;
|
||||
laytpl($("#multuple_html").html()).render({}, function(html) {
|
||||
layer_one = layer.open({
|
||||
type: 1,
|
||||
area: ['580px', '430px'],
|
||||
title: '本地上传',
|
||||
content: html,
|
||||
cancel: function() {
|
||||
$("#chooseListAction").removeClass("bg-color").addClass("layui-btn-disabled").attr("disabled", "disabled");
|
||||
},
|
||||
success: function(res) {
|
||||
//上传图片
|
||||
upload.render({
|
||||
elem: '#ImgUpload',
|
||||
url: ns.url("giftcard://shop/media/upload"),
|
||||
data: {
|
||||
is_thumb:1,
|
||||
},
|
||||
multiple: true,
|
||||
auto: false,
|
||||
bindAction: '#chooseListAction',
|
||||
choose: function(obj) {
|
||||
imageArray=1;
|
||||
//将每次选择的文件追加到文件队列
|
||||
var files = this.files = obj.pushFile();
|
||||
//预读本地文件,如果是多文件,则会遍历。(不支持ie8/9)
|
||||
obj.preview(function(index, file, result) {
|
||||
this.num=index;
|
||||
//追加预览图片
|
||||
var html = '';
|
||||
html += '<li class="multuple-list-img upload-wrap" index="' + index + '">';
|
||||
html += '<img class="multuple-list-image" src="' + result + '" alt="' + file.name + '">';
|
||||
html += '<span class="upload-close-modal" id="upload_img_' + index + '">×</span>';
|
||||
html += '<div class="upload-image-curtain">50%</div>';
|
||||
html += '<div class="tips"></div>';
|
||||
html += '</li>';
|
||||
$(".multuple-list").prepend(html);
|
||||
//删除预览图片
|
||||
$("#upload_img_" + index).bind("click", function() {
|
||||
delete files[index];
|
||||
delete picture_arr[index]; //删除所选队列
|
||||
$(this).parent('.upload-wrap').remove();
|
||||
// uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值,以免删除后出现同名文件不可选
|
||||
//禁止点击
|
||||
if ($(".multuple-list li").length <= 1) {
|
||||
$("#chooseListAction").removeClass("bg-color").addClass("layui-btn-disabled").attr("disabled", "disabled");
|
||||
}
|
||||
});
|
||||
//开启点击
|
||||
if ($(".multuple-list li").length > 1) {
|
||||
$("#chooseListAction").addClass("bg-color").removeClass("layui-btn-disabled").removeAttr("disabled");
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
done: function(res,index) {
|
||||
let data=$('.multuple-list-image');
|
||||
// 禁止点击
|
||||
picture_arr.push(res.data);
|
||||
var image_box = $(".upload-wrap[index='" + index + "']").parent().find(".upload-image-curtain");
|
||||
var image_tips = $(".upload-wrap[index='" + index + "']").parent().find(".tips");
|
||||
image_box.text("上传汇总");
|
||||
image_box.text("50%");
|
||||
image_box.show();
|
||||
if (res.code >= 0) {
|
||||
setTimeout(function() {
|
||||
image_box.text("100%");
|
||||
}, 500);
|
||||
setTimeout(function() {
|
||||
getFileAlbumList(1, limit);
|
||||
layer.close(layer_one)
|
||||
}, 1000);
|
||||
return delete this.files[index]; //删除文件队列已经上传成功的文件
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
image_box.text("上传失败");
|
||||
image_tips.text(res.message);
|
||||
layer.msg(res.message);
|
||||
}, 500);
|
||||
}
|
||||
if(imageArray==data.length){
|
||||
$("#chooseListAction").addClass("bg-color").removeClass("layui-btn-disabled").removeAttr("disabled");
|
||||
imageArray=1;
|
||||
return false
|
||||
}
|
||||
imageArray++
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 上传图片是禁止操作
|
||||
function submitOne(){
|
||||
$("#chooseListAction").removeClass("bg-color").addClass("layui-btn-disabled").attr("disabled","disabled");
|
||||
$(".upload-image-curtain").css('display','block').text('等待中')
|
||||
}
|
||||
|
||||
function deleteImg(data) {
|
||||
var flag_delete_img = false;
|
||||
var media_id = $(data).attr("data-id");
|
||||
if(!media_id){
|
||||
layer.msg("请选择图片再进行操作");
|
||||
return false;
|
||||
}
|
||||
var url = ns.url("giftcard://shop/media/delete");
|
||||
layer.confirm('删除图片会连本地存储或云存储的图片也删掉,请谨慎操作!', {
|
||||
btn: ['确定', '取消']
|
||||
}, function(index) {
|
||||
if (flag_delete_img) return;
|
||||
flag_delete_img = true;
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url,
|
||||
data: {
|
||||
media_id: media_id
|
||||
},
|
||||
dataType: "JSON",
|
||||
success: function(data) {
|
||||
flag_delete_img = false;
|
||||
layer.msg(data.message);
|
||||
if (data.code == 0) {
|
||||
getFileAlbumList(1, limit);
|
||||
layer.closeAll('page');
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function() {
|
||||
layer.close();
|
||||
});
|
||||
}
|
||||
function onerrorFn(data){
|
||||
$(data).attr("data-isShow",true)
|
||||
}
|
||||
</script>
|
||||
213
addon/giftcard/shop/view/media/media.html
Executable file
213
addon/giftcard/shop/view/media/media.html
Executable file
@@ -0,0 +1,213 @@
|
||||
<link rel="stylesheet" type="text/css" href="GIFTCARD_CSS/media_manager.css" />
|
||||
<style>
|
||||
body{background-color: #fff;}
|
||||
.media-box .media-list-box{height: 380px;margin-right: 20px;display: flex;flex-direction: column;}
|
||||
.media-box .media-list-box .media-list {flex: 1;height: 0;overflow-y: scroll}
|
||||
.media-box .media-list-box .media-list::-webkit-scrollbar{display: none;}
|
||||
.media-box .media-img{max-height: 336px;}
|
||||
.media-box .media-img li{width: 185px;height: auto; margin: 0 7px 15px;}
|
||||
.media-box .media-img li div{height: 119.7px;line-height: 119.7px;background-size: cover;background-repeat: no-repeat;background-position: center;cursor: pointer;}
|
||||
.media-box .media-img li:nth-child(5n){margin-right: 0;}
|
||||
.layui-tab-content{padding: 0;height: 449px;}
|
||||
.layui-tab{margin: 5px 0 0;}
|
||||
.layui-tab .layui-tab-item{height: 449px;}
|
||||
.layui-laypage{margin: 10px 0 0;}
|
||||
.layui-tab-title {margin: 0 20px}
|
||||
#media {padding: 20px 20px 0;}
|
||||
.page {text-align: right}
|
||||
</style>
|
||||
|
||||
<div class="layui-tab layui-tab-brief media-tab select-media-wrap">
|
||||
<ul class="layui-tab-title layui-hide">
|
||||
<li class="layui-this">选择图片</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<div id="media" class="layui-tab-item">
|
||||
<div class="media-box">
|
||||
<div class="media-content">
|
||||
<ul class="media-img"></ul>
|
||||
<div id="paged" class="page"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="media_ids" value="{$media_ids}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 图片展示 -->
|
||||
<script type="text/html" id="mediaList">
|
||||
{{# layui.each(d.list,function(index,item){ }}
|
||||
<li data-media-id="{{item.media_id}}" data-json_data='{{JSON.stringify(item)}}' class="media-list-item">
|
||||
<div class="bg-color-gray" style="background-image:url({{ ns.img(item.media_path) }})">
|
||||
{{# if( getActiveArrayIndex(item.media_id) != "-1"){ }}
|
||||
<div class="image-box-active border-color"><i class="active-index">{{ getActiveArrayIndex(item.media_id) }}</i></div>
|
||||
{{# } }}
|
||||
</div>
|
||||
</li>
|
||||
{{# }) }}
|
||||
{{# if(d.list.length === 0){ }}
|
||||
<div class="empty-data">暂无数据</div>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var form, laytpl, laypage, upload,element,
|
||||
limit = 10,
|
||||
active_array = [],
|
||||
repeat_flag = false;
|
||||
layui.use(['form', 'laytpl', 'laypage', 'upload', 'element'], function() {
|
||||
form = layui.form;
|
||||
laytpl = layui.laytpl;
|
||||
laypage = layui.laypage;
|
||||
element = layui.element;
|
||||
upload = layui.upload;
|
||||
|
||||
form.render();
|
||||
//初始化数据
|
||||
init();
|
||||
|
||||
//监听搜索事件
|
||||
form.on('submit(search)', function() {
|
||||
mediaImgList(1, limit);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 素材图片加载
|
||||
* @param page
|
||||
* @param limit
|
||||
*/
|
||||
function mediaImgList(page, limit) {
|
||||
$.ajax({
|
||||
url: ns.url("giftcard://shop/media/media"),
|
||||
type: "POST",
|
||||
dataType: "JSON",
|
||||
async: false,
|
||||
data: {
|
||||
limit,
|
||||
page,
|
||||
media_name: $(".media-img-sreach").val(),
|
||||
app_module:ns_url.appModule,
|
||||
site_id:ns_url.siteId
|
||||
},
|
||||
success: function(res) {
|
||||
laytpl($("#mediaList").html()).render(res.data, function(data) {
|
||||
$(".media-img").html(data);
|
||||
});
|
||||
laypage.render({
|
||||
elem: 'paged',
|
||||
count: res.data.count,
|
||||
limit,
|
||||
curr: page,
|
||||
jump: function(obj, first) {
|
||||
if (!first) {
|
||||
mediaImgList(obj.curr, obj.limit);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择个体
|
||||
*/
|
||||
function checkItem() {
|
||||
$("#media").unbind('click').on("click", ".media-list-item", function() {
|
||||
var json_data = $(this).data("json_data");
|
||||
json_data.id = parseInt(json_data.media_id);
|
||||
|
||||
if ($(this).find(".image-box-active").length > 0) {
|
||||
var active_index = getDeleteActiveArrayIndex(json_data.id);
|
||||
sortActiveArrayIndex(active_index);
|
||||
$(this).find(".image-box-active").remove();
|
||||
} else {
|
||||
json_data.index = active_array.length + 1;
|
||||
if (json_data.index > imgNum) {
|
||||
$(".media-box .media-img li").each((index,item) => {
|
||||
if(active_array.length > 0 && $(item).attr("data-media-id") == active_array[0].media_id) $(item).find(".image-box-active").remove();
|
||||
});
|
||||
var active_index = active_array.length > 0 ? getDeleteActiveArrayIndex(active_array[0].media_id) : 0;
|
||||
sortActiveArrayIndex(active_index);
|
||||
--json_data.index;
|
||||
}
|
||||
active_array.push(json_data);
|
||||
var active_html = '<div class="image-box-active border-color"><i class="active-index">' + active_array.length + '</i></div>';
|
||||
$(this).find("div").append(active_html);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//获取选择图片信息
|
||||
function selectGiftCardMediaListener(callback) {
|
||||
if (typeof callback != "function") return false;
|
||||
if($(".select-media-wrap .layui-tab-content .layui-tab-item").eq(0).hasClass("layui-show")){
|
||||
callback(active_array);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//获取选中
|
||||
function getActiveArrayIndex(id) {
|
||||
var delete_index = -1;
|
||||
$.each(active_array, function(i, item) {
|
||||
if (item.media_id == id) {
|
||||
delete_index = item.index;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return delete_index;
|
||||
}
|
||||
|
||||
//删除选中
|
||||
function getDeleteActiveArrayIndex(id) {
|
||||
var delete_index;
|
||||
$.each(active_array, function(i, item) {
|
||||
if (item.id == id) {
|
||||
delete_index = item.index;
|
||||
active_array.splice(i, 1);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return delete_index;
|
||||
}
|
||||
|
||||
//重新排序
|
||||
function sortActiveArrayIndex(index) {
|
||||
$.each(active_array, function(i, item) {
|
||||
var item_index = item.index;
|
||||
if (item_index > index) {
|
||||
active_array[i]["index"] = item_index - 1;
|
||||
if ($("#media").find(".media-list-item[data-media-id = '" + item["id"] + "']").length > 0) {
|
||||
$("#media").find(".media-list-item[data-media-id = '" + item["id"] + "']").find(".image-box-active i ").text(item["index"]);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
function init() {
|
||||
mediaImgList(1, limit); //分组图像
|
||||
checkItem(); //选择个体
|
||||
$(".select-media-wrap .layui-tab-content .layui-tab-item").eq(0).addClass('layui-show').siblings().removeClass('layui-show');
|
||||
}
|
||||
|
||||
var search = window.location.search,
|
||||
imgNum = parseInt(getSearchString('imgNum', search));
|
||||
function getSearchString(key, Url) {
|
||||
var str = Url;
|
||||
str = str.substring(1, str.length); // 获取URL中?之后的字符(去掉第一位的问号)
|
||||
// 以&分隔字符串,获得类似name=xiaoli这样的元素数组
|
||||
var arr = str.split("&");
|
||||
var obj = new Object();
|
||||
// 将每一个数组元素以=分隔并赋给obj对象
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
var tmp_arr = arr[i].split("=");
|
||||
obj[decodeURIComponent(tmp_arr[0])] = decodeURIComponent(tmp_arr[1]);
|
||||
}
|
||||
return obj[key];
|
||||
}
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user