Authored by dongjunjie

店铺装修加入店铺销售类目

... ... @@ -358,4 +358,37 @@
</div>
</script>
<script type="text/template" id="link">
<select class="form-control inputChange linkSelect" name="linkType" style="margin-bottom: 10px" data-index='[[index]]'>
<option value="0" [[data.linkType==0?'selected':'']]>自定义</option>
<option value="1" [[data.linkType==1?'selected':'']]>销售类目</option>
</select>
[[if data.linkType == 0]]
<div class="link_url">
<input class='form-control inputChange urlInput' type=text name='url' value='[[data.url]]' data-index='[[index]]' />
</div>
<div class="link_category" style="display: none">
<select class="form-control inputChange" name='categoryId' data-index='[[index]]'>
<option value="-1">-- 请选择销售类目 --</option>
[[each categoryList as item _index]]
<option value="[[item.categoryId]]" [[data.categoryId==item.categoryId?'selected':'']]>[[item.categoryName]]</option>
[[/each]]
</select>
</div>
[[else]]
<div class="link_url" style="display: none">
<input class='form-control inputChange urlInput' type=text name='url' value='[[data.url]]' data-index='[[index]]' />
</div>
<div class="link_category">
<select class="form-control inputChange" name='categoryId' data-index='[[index]]'>
<option value="-1">-- 请选择销售类目 --</option>
[[each categoryList as item _index]]
<option value="[[item.categoryId]]" [[data.categoryId==item.categoryId?'selected':'']]>[[item.categoryName]]</option>
[[/each]]
</select>
</div>
[[/if]]
</script>
<%include '../../common/views/__ui/footer'%>
\ No newline at end of file
... ...
... ... @@ -9,6 +9,7 @@ var curPlatform = "pc"; //当前渲染页面用的模板名称
var curTemplateType = "2"; //当前模板类型 1:基础模板,2:经典模板
var shopType = 1; //店铺类型 1:单品牌,2:多品牌
var shopOperate = 'view'; //操作 editor:可编辑, view:查看不可编辑
var shopCategory = []; //店铺下所有的销售类目
var defaultSrc = "http://img01.yohoboys.com/staticimg/2016/05/19/15/01091c21f2317a64f123f1649fbbccf7ba.png"; //初始化默认图片路径
var ENUM = {
"editor-largePic":{"src": "", "url": "", "startTime": "", "endTime": "", "publishStatus": 0},
... ... @@ -180,7 +181,7 @@ function showMain(){
if($(this).width() > 280){
$(this).css("right",(280-($(this).width()))+"px");
}
})
});
showEditorIconEvent();
}
//弹窗编辑主流程
... ... @@ -264,6 +265,10 @@ function findDecoration(){
//最新上架,最热商品接口
if(shopOperate == 'editor'){
//获取店铺下销售类目
findShopCategory();
//最新商品,最热单品
if(!jsonMain.resources.allNewProducts.data || jsonMain.resources.allNewProducts.data.length < 1){
findTopNewProducts();
}
... ... @@ -273,11 +278,26 @@ function findDecoration(){
if(!jsonMain.resources.allHotProducts_APP.data || jsonMain.resources.allHotProducts_APP.data.length < 1){
findTopHotProducts_APP();
}
/*findTopNewProducts(); findTopHotProducts(); findTopHotProducts_APP();*/
}
//渲染页面
showMain();
},true);
}
//Ajax查询店铺下销售类目
function findShopCategory() {
common.util.__ajax({
url:'/shops/shopCategory/list',
data: {
shopId: jsonMain.shopsId
}
},function(rs){
console.log(rs);
if(rs.data){
shopCategory = rs.data;
}
},true);
}
//Ajax最新上架商品
function findTopNewProducts(){
common.util.__ajax({
... ... @@ -323,28 +343,28 @@ function findTopHotProducts_APP(){
//Ajax保存,暂存:100,提交审核:200
function saveDecoration(submitStatus){
console.log(jsonMain);
common.util.__ajax({
url:'/shop/ShopsDecoratorRest/saveShopsDecorator',
data: {
"submitStatus": submitStatus,
"shopsId": jsonMain.shopsId,
"platform": jsonMain.platform,
"templateType": jsonMain.templateType,
"resources": JSON.stringify(jsonMain.resources)
}
},function(rs){
if(rs.data){
if(submitStatus == 100){
jsonMain = rs.data;
jsonClone = $.extend(true,{},jsonMain);
showMain();
}else{
setTimeout(function() {
location.href="/supplier/shop/decoration";
}, 1000);
}
}
});
// common.util.__ajax({
// url:'/shop/ShopsDecoratorRest/saveShopsDecorator',
// data: {
// "submitStatus": submitStatus,
// "shopsId": jsonMain.shopsId,
// "platform": jsonMain.platform,
// "templateType": jsonMain.templateType,
// "resources": JSON.stringify(jsonMain.resources)
// }
// },function(rs){
// if(rs.data){
// if(submitStatus == 100){
// jsonMain = rs.data;
// jsonClone = $.extend(true,{},jsonMain);
// showMain();
// }else{
// setTimeout(function() {
// location.href="/supplier/shop/decoration";
// }, 1000);
// }
// }
// });
}
//Ajax审核,审核通过:300,驳回:900
function checkDecoration(checkStatus,comment){
... ... @@ -477,7 +497,13 @@ function gridInit(id){
return "<input class='form-control inputChange' type=text name='name' value='"+item.name+"' data-index='"+item.__index+"' maxlength='5' />";
}},
{display:"链接", render:function(item){
return "<input class='form-control inputChange urlInput' type=text name='url' value='"+(item.url).replace(/'/g,'\"')+"' data-index='"+item.__index+"' />";
if(item.url != ''){
item.linkType = item.linkType || '0';
}else{
item.linkType = item.linkType || '1';
}
item.categoryId = item.categoryId || '-1';
return common.util.__template2($("#link").html(),{data:item, categoryList:shopCategory, index:item.__index});
}}
]
});
... ... @@ -590,7 +616,13 @@ function gridInit(id){
}
}},
{display:"链接", render:function(item){
return "<input class='form-control inputChange urlInput' type=text name='url' value='"+(item.url).replace(/'/g,'\"')+"' data-index='"+item.__index+"' />";
if(item.url != ''){
item.linkType = item.linkType || '0';
}else{
item.linkType = item.linkType || '1';
}
item.categoryId = item.categoryId || '-1';
return common.util.__template2($("#link").html(),{data:item, categoryList:shopCategory, index:item.__index});
}},
{display:"操作", render:function(item){
var htmlPic = "",i=item.__index;
... ... @@ -638,7 +670,13 @@ function gridInit(id){
return "<input type=file fileType='9' name='signboardImage' id='hotRecommendImage_"+item.__index+"' value='"+item.src+"' />";
}},
{display:"链接", render:function(item){
return "<input class='form-control inputChange urlInput' type=text name='url' value='"+(item.url).replace(/'/g,'\"')+"' data-index='"+item.__index+"' />";
if(item.url != ''){
item.linkType = item.linkType || '0';
}else{
item.linkType = item.linkType || '1';
}
item.categoryId = item.categoryId || '-1';
return common.util.__template2($("#link").html(),{data:item, categoryList:shopCategory, index:item.__index});
}},
{display:"操作", render:function(item){
var htmlPic = "",i=item.__index;
... ... @@ -1353,10 +1391,15 @@ function resourcesHtmlInit(item,resName){
var picList = item.data,
htmlPic = "";
for(var i=0; i<picList.length; i++){
picList[i].url=picList[i].url.replace(/'/g,'\"'); // 字符串里面单引号转换成双引号
htmlPic += "<div class='row'><div class='col-sm-2'>";
//picList[i].url=picList[i].url.replace(/'/g,'\"'); // 字符串里面单引号转换成双引号
if(i == 0){
htmlPic += "<div class='row' style='padding: 10px 0'>";
}else{
htmlPic += "<div class='row' style='padding: 10px 0; border-top: 1px solid #dddddd'>";
}
//大图资源位,小图资源位,水牌图片尺寸校验——fileType参数
//图片,大图资源位,小图资源位,水牌图片尺寸校验——fileType参数
htmlPic += "<div class='col-sm-2'>";
if(curPlatform == "pc"){
if(curDialogId == "editor-largePic"){//经典模板pc大图资源位
htmlPic += "<input type=file fileType='6' name='"+ resName +"Image' id='"+ resName +"Image_"+item.__index+"_"+i+"' value='"+picList[i].src+"' />";
... ... @@ -1376,19 +1419,43 @@ function resourcesHtmlInit(item,resName){
htmlPic += "<input type=file fileType='12' name='"+ resName +"Image' id='"+ resName +"Image_"+item.__index+"_"+i+"' value='"+picList[i].src+"' />";
}
}
htmlPic += "</div>";
//url&销售类目
console.log(picList[i].url);
if(picList[i].url != ''){
picList[i].linkType = picList[i].linkType || '0';
}else{
picList[i].linkType = picList[i].linkType || '1';
}
picList[i].categoryId = picList[i].categoryId || '-1';
htmlPic += "<div class='col-sm-3'>";
htmlPic += common.util.__template2($("#link").html(),{data:picList[i], categoryList:shopCategory, index:item.__index+'_'+i});
htmlPic += "</div><div class='col-sm-3'><input type=text class='form-control inputChange urlInput' name='url' value='"+picList[i].url+"' data-index='"+item.__index+"_"+i+"' /></div>" +
"<div class='col-sm-2'>";
htmlPic += "</div>";
//开始时间
htmlPic += "<div class='col-sm-2'>";
if(i>0){
htmlPic += "<input type=text class='form-control' disabled jsaction='time:end:endTime_"+item.__index+"_"+ i +"' id='startTime_"+item.__index+"_"+ i +"' name='startTime' value='"+ picList[i].startTime +"' />" +
"<span style='color: #999; font-size: 12px'>*上一条结束时间</span>";
}else{
htmlPic += "<input type=text class='form-control inputChange' style='background-color:#fff' readOnly='true' jsaction='time:end:endTime_"+item.__index+"_"+ i +"' id='startTime_"+item.__index+"_"+ i +"' name='startTime' value='"+ picList[i].startTime +"' data-index='"+ item.__index +"_"+ i +"' />";
}
htmlPic += "</div><div class='col-sm-2'>" +
"<input type=text class='form-control inputChange' style='background-color:#fff' readOnly='true' jsaction='time:start:startTime_"+item.__index+"_"+ i +"' id='endTime_"+item.__index+"_"+ i +"' name='endTime' value='"+ picList[i].endTime +"' data-index='"+ item.__index +"_"+ i +"' /></div>" +
"<div class='col-sm-1'><span class='publishStatus' style='white-space: nowrap; line-height: 40px'>"+ checkdate(picList[i].startTime,picList[i].endTime) +"</span></div>" +
"<div class='col-sm-2' style='line-height: 40px'>";
htmlPic += "</div>";
//结束时间
htmlPic += "<div class='col-sm-2'>"
+ "<input type=text class='form-control inputChange' style='background-color:#fff' readOnly='true' jsaction='time:start:startTime_"+item.__index+"_"+ i +"' id='endTime_"+item.__index+"_"+ i +"' name='endTime' value='"+ picList[i].endTime +"' data-index='"+ item.__index +"_"+ i +"' />"
+ "</div>";
//状态
htmlPic += "<div class='col-sm-1'><span class='publishStatus' style='white-space: nowrap; line-height: 40px'>"+ checkdate(picList[i].startTime,picList[i].endTime) +"</span></div>";
//操作
htmlPic += "<div class='col-sm-2' style='line-height: 40px'>";
if(i == (picList.length-1) && picList.length > 1){
htmlPic += "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+ item.__index +"_"+ i +"' /><br>";
htmlPic += "<input type=button class='btn btn-info btn-xs addBtn' style='margin-top: 10px' value='添加一条' data-index='"+ item.__index +"_"+ i +"' />";
... ... @@ -1514,16 +1581,16 @@ $(document).on("click",".tabheader .nav-tabs li",function(){
$(this).addClass('active').siblings('li').removeClass('active');
curTemplateType = $(this).attr("data-toggle");
showMain();
})
});
//pc,app切换
$(document).on("click","input[name=brandLevel]",function(){
curPlatform = $("input[name=brandLevel]:checked").val();
showMain();
})
});
//暂存模板
$(document).on("click","#saveModule",function(){
saveDecoration(100);
})
});
//提交审核
$(document).on("click","#submitModule",function(){
jsonMain.templateType = curTemplateType;
... ... @@ -1536,7 +1603,7 @@ $(document).on("click","#submitModule",function(){
},
function(){}
)
})
});
//审核通过
$(document).on("click","#checkOk",function(){
common.dialog.confirm(
... ... @@ -1547,7 +1614,7 @@ $(document).on("click","#checkOk",function(){
},
function(){}
);
})
});
//驳回
$(document).on("click","#checkNo",function(){
common.dialog.confirm(
... ... @@ -1566,7 +1633,15 @@ $(document).on("click","#checkNo",function(){
},
function(){}
);
})
});
//销售类目&自定义切换
$(document).on("change", ".linkSelect", function () {
if($(this).val() == 0){ //自定义
$(this).next('.link_url').show().next('.link_category').hide();
}else{ //销售类目
$(this).next('.link_url').hide().next('.link_category').show();
}
});
//删除
$(document).on("click",".deleteBtn",function(){
var _index = $(this).data("index")+"";
... ...