Authored by weiqingting

Merge branch 'yohobuy_shops_dev_v4.4_20160525' into develop

... ... @@ -5,7 +5,7 @@ var $ = require('jquery'),
var g; //grid
var curDialogId; //当前打开的编辑弹层ID
var curPlatform = "shopWeb-pc"; //当前渲染页面用的模板名称
var curPlatform = "pc"; //当前渲染页面用的模板名称
var curTemplateType = "2"; //当前模板类型 1:基础模板,2:经典模板
var shopType = 1; //店铺类型 1:单品牌,2:多品牌
var shopOperate = 'view'; //操作 editor:可编辑, view:查看不可编辑
... ... @@ -15,7 +15,7 @@ var ENUM = {
"editor-largePic2":{"position":"", "data":[{"src": "", "url": "", "startTime": "", "endTime": "", "publishStatus": 0}]},
"editor-smallPic":{"src": "", "url": "", "startTime": "", "endTime": "", "publishStatus": 0},
"editor-brand":{"position":"", "name":"", "url":""},
"editor-recommend": {"position":"", "name":"", "enName":"", "src":"", "url":"","isShowInApp":"Y"},
"editor-recommend": {"position":"", "name":"", "enName":"", "src":"", "url":""},
"editor-hotRecommend":{"position":"", "src":"", "url":""},
"editor-signboard":{"position":"", "src":"", "url":"","startTime": "","endTime": "","publishStatus": 0},
"editor-newGoodTab":{"position":"", "name":"", "url":""},
... ... @@ -28,6 +28,10 @@ var resourcesNew = {
"id":"",
"data": [{"shopSrc": defaultSrc, "detailSrc": defaultSrc, "isShowShopName": "N"}]
},
"shopTopBanner_base":{
"id":"",
"data": [{"shopSrc": defaultSrc, "detailSrc": defaultSrc, "isShowShopName": "N"}]
},
"navigationBar":{
"id":"",
"data": [{"name":"",url:""}, {"name":"",url:""}, {"name":"",url:""}]
... ... @@ -50,7 +54,7 @@ var resourcesNew = {
"recommend":{
"id":"",
"title":"经典推荐",
"data": [{"position":1, "name":"默认商品", "enName":"", "src":defaultSrc, "url":"","isShowInApp":"Y"}]
"data": [{"position":1, "name":"默认商品", "enName":"", "src":defaultSrc, "url":""}]
},
"hotRecommend":{
"id":"",
... ... @@ -105,6 +109,16 @@ var resourcesNew = {
"allHotProducts_APP":{
"id":"",
"data":[]
},
"largeSlideImg_APP":{
"id":"",
"isUsed":"N",
"data": [{"position": 1, "data":[{"src": defaultSrc, "url": "", "startTime": "", "endTime": ""}]}]
},
"recommend_APP":{
"id":"",
"isUsed":"N",
"data": [{"position":1, "name":"默认商品", "enName":"", "src":defaultSrc, "url":""}]
}
} //初始化装修信息json
var shopsId, _id, jsonMain, jsonClone;
... ... @@ -127,26 +141,34 @@ function getParams(){
_id = paramList[4];
}
if(shopOperate == 'editor'){
$(".moduleTypeSelect").show().find("#templateSelect").removeAttr("disabled");
$(".moduleSubmite").show().siblings().hide();
}else if(shopOperate == 'view'){
$(".moduleTypeSelect").hide();
$(".tabheader").hide();
$(".moduleView").show().siblings().hide();
}else if(shopOperate == 'check'){
$(".moduleTypeSelect").show().find("#templateSelect").attr("disabled","disabled");
$(".tabheader").hide();
$(".moduleCheck").show().siblings().hide();
}
}
//json渲染模板
function showMain(){
$('#templateSelect').val(jsonMain.templateType);
$("input[name='brandLevel'][value='"+curTemplateType+"']").attr('checked',"checked");
// tab自动选中基础模板,经典模板
$('.tabheader .nav').find("li[data-toggle='"+ curTemplateType +"']").addClass("active");
// radio自动选中pc端或者app端
$('.moduleTypeView').find("input[name='brandLevel'][value='"+ curPlatform +"']").attr("checked","checked");
if(curPlatform == "shopWeb-pc"){
//console.log(jsonMain);
$('#main').empty().html(common.util.__template2($("#"+curPlatform+"-"+curTemplateType).html(),jsonMain));
} else if(curPlatform == "shopWeb-app"){
$('#main').empty().html(common.util.__template2($("#"+curPlatform).html(),jsonMain));
//渲染装修模板
if(curTemplateType == 1){
$('#main').empty().html(common.util.__template2($("#"+curTemplateType+"-pc").html(),jsonMain));
}else if(curTemplateType == 2){
$('#main').empty().html(common.util.__template2($("#"+curTemplateType+"-"+curPlatform).html(),jsonMain));
}
//基础模板不显示pc端跟app端
if(curTemplateType == "1"){
$(".moduleTypeView").hide();
}else{
$(".moduleTypeView").show();
}
//单品牌,多品牌
if(shopType == 2){
... ... @@ -166,25 +188,55 @@ function showMain(){
function editorIconEvent(title,id){
$('.editorIcon').on('click',function(){
curDialogId = id;
common.dialog.confirm(
title,
"<div class='editorTitle'></div><div class='editor-dialog' id='"+ id +"'></div><div class='editorTip'></div> ",
function(){
if(editorCheck(id)){
if(!(curDialogId == "editor-largePic-app" || curDialogId == "editor-recommend-app" || curDialogId == "editor-brand-app")){
freshJson(id, g.__rows, 1);
var option = {
title:title,
content:"<div class='editorTitle'></div><div class='editor-dialog' id='"+ id +"'></div><div class='editorTip'></div> ",
width:'70%',
button:[
{
value:"取消",
callback:function(){
if(curDialogId != "editor-brand-app"){
freshJson(id, g.__rows, 0);
}
}
},
{
value:"确认",
css:"btn-info",
callback:function(){
if(editorCheck(id)){
if(curDialogId != "editor-brand-app"){
freshJson(id, g.__rows, 1);
}
showMain();
}else{
return false;
}
}
showMain();
}else{
return false;
}
},
function(){
if(!(curDialogId == "editor-largePic-app" || curDialogId == "editor-recommend-app" || curDialogId == "editor-brand-app")){
freshJson(id, g.__rows, 0);
]
}
if(id == "editor-recommend" && curPlatform == "pc" && jsonMain.resources.recommend_APP.isUsed == "Y"){
option.button.push({
value:"保存并同步至APP",
css:"btn-success",
callback: function(){
if(editorCheck(id)){
freshJson(id, g.__rows, 1);
cloneArr(sortJson(g.__rows,1),jsonMain.resources.recommend_APP.data);
cloneArr(sortJson(g.__rows,1),jsonClone.resources.recommend_APP.data);
removeUrlParam("editor-recommend",jsonMain.resources.recommend_APP.data); //去除url
removeUrlParam("editor-recommend",jsonClone.resources.recommend_APP.data);
common.util.__tip("同步APP成功!","success");
showMain();
}else{
return false;
}
}
}
);
});
}
new common.dialog(option);
gridInit(id);
untilEditorEvent(id);
editorTipInit(id);
... ... @@ -220,6 +272,7 @@ function findDecoration(){
common.util.__tip("店铺没有品牌,无法装修,请返回添加品牌!");
return;
}
//初始化模板类型
if(jsonMain.templateType && jsonMain.templateType != "0"){
curTemplateType = jsonMain.templateType;
}
... ... @@ -237,11 +290,7 @@ function findDecoration(){
if(!jsonMain.resources.allHotProducts_APP.data || jsonMain.resources.allHotProducts_APP.data.length < 1){
findTopHotProducts_APP();
}
/*
findTopNewProducts();
findTopHotProducts();
findTopHotProducts_APP();
*/
/*findTopNewProducts(); findTopHotProducts(); findTopHotProducts_APP();*/
}
showMain();
},true);
... ... @@ -351,9 +400,36 @@ function checkDecoration(checkStatus,comment){
//弹层表单grid生成器
function gridInit(id){
switch (id){
//店铺顶部banner
//基础模板顶部banner
case "editor-banner-base":
g = new common.grid({
hash: false,
el:"#"+id,
columns:[
{display:"店铺banner图片", render:function(item){
return "<input type=file name='shopBannerImage' id='shopBannerImage_"+item.__index+"' value='"+item.shopSrc+"' />";
}},
{display:"是否显示店铺名称", render:function(item){
if(item.isShowShopName == "Y"){
return "<lable><input type='radio' name='isShowShopName' value='Y' checked='checked'>显示店铺名称</lable><br>" +
"<lable><input type='radio' name='isShowShopName' value='N'>不显示店铺名称</lable>";
}else{
return "<lable><input type='radio' name='isShowShopName' value='Y'>显示店铺名称</lable><br>" +
"<lable><input type='radio' name='isShowShopName' value='N' checked='checked'>不显示店铺名称</lable>";
}
}},
{display:"商品详情页banner图片", render:function(item){
return "<input type=file name='DetailbannerImage' id='DetailbannerImage_"+item.__index+"' value='"+item.detailSrc+"' />";
}}
]
});
g.__rows=""||jsonClone.resources.shopTopBanner_base.data;
g.init(g.__rows);
break;
//经典模板顶部banner
case "editor-banner":
if(curPlatform == "shopWeb-pc"){
if(curPlatform == "pc"){
g = new common.grid({
hash: false,
el:"#"+id,
... ... @@ -377,7 +453,7 @@ function gridInit(id){
});
g.__rows=""||jsonClone.resources.shopTopBanner.data;
}
if(curPlatform == "shopWeb-app"){
if(curPlatform == "app"){
g = new common.grid({
hash: false,
el:"#"+id,
... ... @@ -414,7 +490,7 @@ 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' type=text name='url' value='"+item.url+"' data-index='"+item.__index+"' />";
return '<input class="form-control inputChange urlInput" type=text name="url" value="'+item.url+'" data-index="'+item.__index+'" />';
}}
]
});
... ... @@ -441,12 +517,17 @@ function gridInit(id){
},
{display:"操作", render:function(item){
if(g.__rows.length > 1){
return "<input type=button class='btn btn-danger btn-xs deleteBtn' value='删除' data-index='"+item.__index+"' />";
return "<input type=button class='btn btn-warning btn-xs deleteBtn' style='margin-top:6px' value='删除' data-index='"+item.__index+"' />";
}
}}
]
});
g.__rows=""||jsonClone.resources.largeSlideImg.data;
if(curPlatform == "pc"){
g.__rows=""||jsonClone.resources.largeSlideImg.data;
}
if(curPlatform == "app"){
g.__rows=""||jsonClone.resources.largeSlideImg_APP.data;
}
g.init(g.__rows);
break;
... ... @@ -468,10 +549,10 @@ function gridInit(id){
}
]
});
if(curPlatform == "shopWeb-pc"){
if(curPlatform == "pc"){
g.__rows=""||jsonClone.resources.oneRowTwoColImages.data;
}
if(curPlatform == "shopWeb-app"){
if(curPlatform == "app"){
g.__rows=""||jsonClone.resources.oneRowTwoColImages_APP.data;
}
g.init(g.__rows);
... ... @@ -498,7 +579,6 @@ function gridInit(id){
//经典推荐recommend
case "editor-recommend":
$('.editorTitle').html("<div class='form-inline' style='margin-bottom: 10px'><label>标题名称编辑:</label><input class='form-control' type=text name='title' value='"+ jsonMain.resources.recommend.title +"' /></div> ");
g = new common.grid({
hash: false,
el:"#"+id,
... ... @@ -517,14 +597,7 @@ function gridInit(id){
return "<input type=file name='recommendImage' id='recommendImage_"+item.__index+"' value='"+item.src+"' />";
}},
{display:"链接", render:function(item){
return "<input class='form-control inputChange' type=text name='url' value='"+item.url+"' data-index='"+item.__index+"' />";
}},
{display:"APP展示", render:function(item){
if(item.isShowInApp == "Y"){
return "<input class='form-control checkBoxChange' type=checkBox name='isShowInApp' data-index='"+item.__index+"' checked />";
}else{
return "<input class='form-control checkBoxChange' type=checkBox name='isShowInApp' data-index='"+item.__index+"' />";
}
return '<input class="form-control inputChange urlInput" type=text name="url" value="'+item.url+'" data-index="'+item.__index+'" />';
}},
{display:"操作", render:function(item){
var htmlPic = "",i=item.__index;
... ... @@ -547,7 +620,13 @@ function gridInit(id){
}}
]
});
g.__rows=""||jsonClone.resources.recommend.data;
if(curPlatform == "pc"){
$('.editorTitle').html("<div class='form-inline' style='margin-bottom: 10px'><label>标题名称编辑:</label><input class='form-control' type=text name='title' value='"+ jsonMain.resources.recommend.title +"' /></div> ");
g.__rows=""||jsonClone.resources.recommend.data;
}
if(curPlatform == "app"){
g.__rows=""||jsonClone.resources.recommend_APP.data;
}
g.init(g.__rows);
break;
... ... @@ -566,7 +645,7 @@ function gridInit(id){
return "<input type=file name='signboardImage' id='hotRecommendImage_"+item.__index+"' value='"+item.src+"' />";
}},
{display:"链接", render:function(item){
return "<input class='form-control inputChange' type=text name='url' value='"+item.url+"' data-index='"+item.__index+"' />";
return '<input class="form-control inputChange urlInput" type=text name="url" value="'+item.url+'" data-index="'+item.__index+'" />';
}},
{display:"操作", render:function(item){
var htmlPic = "",i=item.__index;
... ... @@ -646,7 +725,7 @@ function gridInit(id){
if(item.__index == 0){
return "http://店铺商品列表页(默认)";
}else{
return "<input class='form-control inputChange' type=text name='url' value='"+item.url+"' data-index='"+item.__index+"' />";
return '<input class="form-control inputChange urlInput" type=text name="url" value="'+item.url+'" data-index="'+item.__index+'" />';
}
}},
{display:"操作", render:function(item){
... ... @@ -694,7 +773,7 @@ function gridInit(id){
if(item.__index == 0){
return "http://店铺商品列表页(默认)";
}else{
return "<input class='form-control inputChange' type=text name='url' value='"+item.url+"' data-index='"+item.__index+"' />";
return '<input class="form-control inputChange urlInput" type=text name="url" value="'+item.url+'" data-index="'+item.__index+'" />';
}
}},
{display:"操作", render:function(item){
... ... @@ -719,8 +798,7 @@ function gridInit(id){
//新品上架
case "editor-newProduct":
$("#"+id).html("<div id='editor-newProduct-grid' style='width: 500px; float: left'></div><div class='top20List' style='float: left;margin-left: 40px'></div> ");
//左侧已选商品
$("#"+id).html("<div id='editor-newProduct-grid' style='width: 50%; float:left;padding-left: 20px'></div><div class='top20List' style='float:left; padding-left:10%'></div> ");
g = new common.grid({
hash: false,
el:"#editor-newProduct-grid",
... ... @@ -739,20 +817,13 @@ function gridInit(id){
]
});
g.__rows=""||jsonClone.resources.newProducts.data;
productTopDataShow(id, jsonMain.resources.allNewProducts); //右侧热销排名前20商品
g.init(g.__rows);
//右侧热销排名前20商品
if(jsonMain.resources.allNewProducts.data && jsonMain.resources.allNewProducts.data.length > 0){
$("#"+id+" .top20List").html(common.util.__template2($("#top20Products").html(),jsonMain.resources.allNewProducts));
productTopDataLink(g.__rows);
}else{
$("#"+id+" .top20List").html("<font color='red'>*&nbsp;&nbsp;最新上架20条加载失败,请重新加载页面!</font>");
}
break;
//人气单品
case "editor-hotProduct":
$("#"+id).html("<div id='editor-hotProduct-grid' style='width: 500px; float: left'></div><div class='top20List' style='float: left;margin-left: 40px'></div> ");
//左侧已选商品
$("#"+id).html("<div id='editor-hotProduct-grid' style='width: 50%; float:left;padding-left: 20px'></div><div class='top20List' style='float:left; padding-left:10%'></div> ");
g = new common.grid({
hash: false,
el:"#editor-hotProduct-grid",
... ... @@ -770,25 +841,13 @@ function gridInit(id){
}}
]
});
if(curPlatform == "shopWeb-pc"){
if(curPlatform == "pc"){
g.__rows=""||jsonClone.resources.hotProducts.data;
//右侧热销排名前20商品
if(jsonMain.resources.allHotProducts.data && jsonMain.resources.allHotProducts.data.length > 0){
$("#"+id+" .top20List").html(common.util.__template2($("#top20Products").html(),jsonMain.resources.allHotProducts));
productTopDataLink(g.__rows);
}else{
$("#"+id+" .top20List").html("<font color='red'>*&nbsp;&nbsp;最新上架20条加载失败,请重新加载页面!</font>");
}
productTopDataShow(id, jsonMain.resources.allHotProducts); //右侧热销排名前20商品
}
if(curPlatform == "shopWeb-app"){
if(curPlatform == "app"){
g.__rows=""||jsonClone.resources.hotProducts_APP.data;
//右侧热销排名前20商品
if(jsonMain.resources.allHotProducts_APP.data && jsonMain.resources.allHotProducts_APP.data.length > 0){
$("#"+id+" .top20List").html(common.util.__template2($("#top20Products").html(),jsonMain.resources.allHotProducts_APP));
productTopDataLink(g.__rows);
}else{
$("#"+id+" .top20List").html("<font color='red'>*&nbsp;&nbsp;最新上架20条加载失败,请重新加载页面!</font>");
}
productTopDataShow(id, jsonMain.resources.allHotProducts_APP); //右侧热销排名前20商品
}
g.init(g.__rows);
break;
... ... @@ -800,29 +859,36 @@ function gridInit(id){
//弹层表单确定后刷新json数据,status参数:1:确定,0:取消
function freshJson(id,data,status){
switch (id){
case "editor-banner-base":
if(status == 1){
data[0].isShowShopName = $("input[name='isShowShopName']:checked").val();
cloneArr(data,jsonMain.resources.shopTopBanner_base.data);
}else if(status == 0){
cloneArr(jsonMain.resources.shopTopBanner_base.data,data);
}
break;
case "editor-banner":
if(status == 1){
data[0].isShowShopName = $("input[name='isShowShopName']:checked").val();
if(curPlatform == "shopWeb-app"){
jsonMain.resources.shopTopBanner_APP.isUsed = "Y"; // 用于提交审核时候校验app端是否维护店招
cloneArr(data,jsonMain.resources.shopTopBanner_APP.data);
}
if(curPlatform == "shopWeb-pc"){
if(curPlatform == "pc"){
cloneArr(data,jsonMain.resources.shopTopBanner.data);
/* app端与pc端单独配置,不取pc端的大图了
if(jsonMain.resources.shopTopBanner_APP.isUsed == "N"){
cloneArr(data,jsonMain.resources.shopTopBanner_APP.data);
cloneArr(data,jsonClone.resources.shopTopBanner_APP.data);
}
*/
if(jsonMain.resources.shopTopBanner_APP.isUsed == "N"){
cloneArr(data,jsonMain.resources.shopTopBanner_APP.data);
cloneArr(data,jsonClone.resources.shopTopBanner_APP.data);
}
}
}else if(status == 0){
if(curPlatform == "shopWeb-app"){
cloneArr(jsonMain.resources.shopTopBanner_APP.data,data);
if(curPlatform == "app"){
jsonMain.resources.shopTopBanner_APP.isUsed = "Y";
cloneArr(data,jsonMain.resources.shopTopBanner_APP.data);
}
if(curPlatform == "shopWeb-pc"){
}else if(status == 0){
if(curPlatform == "pc"){
cloneArr(jsonMain.resources.shopTopBanner.data,data);
}
if(curPlatform == "app"){
cloneArr(jsonMain.resources.shopTopBanner_APP.data,data);
}
}
break;
... ... @@ -836,32 +902,51 @@ function freshJson(id,data,status){
case "editor-largePic":
if(status == 1){
cloneArr(sortJson(data,1),jsonMain.resources.largeSlideImg.data);
if(curPlatform == "pc"){
cloneArr(sortJson(data,1),jsonMain.resources.largeSlideImg.data);
if(jsonMain.resources.largeSlideImg_APP.isUsed == "N"){
cloneArr(sortJson(data,1),jsonMain.resources.largeSlideImg_APP.data);
cloneArr(sortJson(data,1),jsonClone.resources.largeSlideImg_APP.data);
removeUrlParam(id,jsonMain.resources.largeSlideImg_APP.data); //去除url
removeUrlParam(id,jsonClone.resources.largeSlideImg_APP.data);
}
}
if(curPlatform == "app"){
jsonMain.resources.largeSlideImg_APP.isUsed = "Y";
cloneArr(sortJson(data,1),jsonMain.resources.largeSlideImg_APP.data);
}
}else if(status == 0){
cloneArr(jsonMain.resources.largeSlideImg.data,data);
if(curPlatform == "pc"){
cloneArr(jsonMain.resources.largeSlideImg.data,data);
}
if(curPlatform == "app"){
cloneArr(jsonMain.resources.largeSlideImg_APP.data,data);
}
}
break;
case "editor-smallPic":
if(status == 1){
if(curPlatform == "shopWeb-app"){
jsonMain.resources.oneRowTwoColImages_APP.isUsed = "Y";
cloneArr(sortJson(data,1),jsonMain.resources.oneRowTwoColImages_APP.data);
}
if(curPlatform == "shopWeb-pc"){
if(curPlatform == "pc"){
cloneArr(sortJson(data,1),jsonMain.resources.oneRowTwoColImages.data);
if(jsonMain.resources.oneRowTwoColImages_APP.isUsed == "N"){
cloneArr(sortJson(data,1),jsonMain.resources.oneRowTwoColImages_APP.data);
cloneArr(sortJson(data,1),jsonClone.resources.oneRowTwoColImages_APP.data);
removeUrlParam(id,jsonMain.resources.oneRowTwoColImages_APP.data); //去除url
removeUrlParam(id,jsonClone.resources.oneRowTwoColImages_APP.data);
}
}
}else if(status == 0){
if(curPlatform == "shopWeb-app"){
cloneArr(jsonMain.resources.oneRowTwoColImages_APP.data,data);
if(curPlatform == "app"){
jsonMain.resources.oneRowTwoColImages_APP.isUsed = "Y";
cloneArr(sortJson(data,1),jsonMain.resources.oneRowTwoColImages_APP.data);
}
if(curPlatform == "shopWeb-pc"){
}else if(status == 0){
if(curPlatform == "pc"){
cloneArr(jsonMain.resources.oneRowTwoColImages.data,data);
}
if(curPlatform == "app"){
cloneArr(jsonMain.resources.oneRowTwoColImages_APP.data,data);
}
}
break;
... ... @@ -875,10 +960,28 @@ function freshJson(id,data,status){
case "editor-recommend":
if(status == 1){
jsonMain.resources.recommend.title = jsonClone.resources.recommend.title = $(".editorTitle input[name='title']").val();
cloneArr(sortJson(data,1),jsonMain.resources.recommend.data);
if(curPlatform == "pc"){
var title = $(".editorTitle input[name='title']").val();
jsonMain.resources.recommend.title = jsonClone.resources.recommend.title = title;
cloneArr(sortJson(data,1),jsonMain.resources.recommend.data);
if(jsonMain.resources.recommend_APP.isUsed == "N"){
cloneArr(sortJson(data,1),jsonMain.resources.recommend_APP.data);
cloneArr(sortJson(data,1),jsonClone.resources.recommend_APP.data);
removeUrlParam(id,jsonMain.resources.recommend_APP.data); //去除url
removeUrlParam(id,jsonClone.resources.recommend_APP.data);
}
}
if(curPlatform == "app"){
jsonMain.resources.recommend_APP.isUsed = "Y";
cloneArr(sortJson(data,1),jsonMain.resources.recommend_APP.data);
}
}else if(status == 0){
cloneArr(jsonMain.resources.recommend.data,data);
if(curPlatform == "pc"){
cloneArr(jsonMain.resources.recommend.data,data);
}
if(curPlatform == "app"){
cloneArr(jsonMain.resources.recommend_APP.data,data);
}
}
break;
... ... @@ -925,24 +1028,24 @@ function freshJson(id,data,status){
case "editor-hotProduct":
if(status == 1){
if(curPlatform == "shopWeb-app"){
jsonMain.resources.hotProducts_APP.isUsed = "Y";
cloneArr(sortJson(data,1),jsonMain.resources.hotProducts_APP.data);
}
if(curPlatform == "shopWeb-pc"){
if(curPlatform == "pc"){
cloneArr(sortJson(data,1),jsonMain.resources.hotProducts.data);
if(jsonMain.resources.hotProducts_APP.isUsed == "N"){
cloneArr(sortJson(data,1),jsonMain.resources.hotProducts_APP.data);
cloneArr(sortJson(data,1),jsonClone.resources.hotProducts_APP.data);
}
}
}else if(status == 0){
if(curPlatform == "shopWeb-app"){
cloneArr(jsonMain.resources.hotProducts_APP.data,data);
if(curPlatform == "app"){
jsonMain.resources.hotProducts_APP.isUsed = "Y";
cloneArr(sortJson(data,1),jsonMain.resources.hotProducts_APP.data);
}
if(curPlatform == "shopWeb-pc"){
}else if(status == 0){
if(curPlatform == "pc"){
cloneArr(jsonMain.resources.hotProducts.data,data);
}
if(curPlatform == "app"){
cloneArr(jsonMain.resources.hotProducts_APP.data,data);
}
}
break;
... ... @@ -954,28 +1057,28 @@ function freshJson(id,data,status){
function editorTipInit(id){
var tipHtml = "";
switch (id){
case "editor-banner-base":
tipHtml = "<span>提示:请上传像素1150*200的图片,图片大小不能超过500KB。</span>";
break;
case "editor-banner":
if(curPlatform == "shopWeb-pc"){
tipHtml = "<span>提示:请上传像素1150*150的图片,图片大小不能大于500KB。</span>";
if(curPlatform == "pc"){
tipHtml = "<span>提示:请上传像素1150*200的图片,图片大小不能超过500KB。</span>";
}
if(curPlatform == "shopWeb-app"){
tipHtml = "<span>提示:请上传像素640*200的图片,图片大小不能大于500KB。</span>";
if(curPlatform == "app"){
tipHtml = "<span>提示:请上传像素640*200的图片,图片大小不能超过500KB。</span>";
}
break;
case "editor-nav":
tipHtml = "<span>提示:标题名称最多5个汉字。</span>";
break;
case "editor-largePic":
tipHtml = "<span>提示:请上传像素660*358的图片,图片大小不能大于500KB,该图片会适配到APP端。</span>";
break;
case "editor-largePic-app":
tipHtml = "<span>提示:由PC端适配,修改请到PC端修改。</span>";
tipHtml = "<span>提示:请上传像素660*358的图片,图片大小不能超过500KB。</span>";
break;
case "editor-smallPic":
if(curPlatform == "shopWeb-app"){
tipHtml = "<span>提示:请上传像素275*160的图片,图片大小不能大于500KB。</span>";
if(curPlatform == "app"){
tipHtml = "<span>提示:请上传像素275*160的图片,图片大小不能超过500KB。</span>";
}else{
tipHtml = "<span>提示:请上传像素300*174的图片,图片大小不能大于500KB。</span>";
tipHtml = "<span>提示:请上传像素300*174的图片,图片大小不能超过500KB。</span>";
}
break;
case "editor-brand":
... ... @@ -985,16 +1088,13 @@ function editorTipInit(id){
tipHtml = "<span>提示:【品牌一览】由PC端【品牌集合】适配,修改请到PC端【品牌集合】修改。</span>";
break;
case "editor-recommend":
tipHtml = "<span>提示:请上传像素150*150的图片,图片大小不能大于500KB,图片和标题会适配到APP的【热门品类】中。</span>";
break;
case "editor-recommend-app":
tipHtml = "<span>提示:【热门品类】由PC端【经典推荐】适配,修改请到PC端【经典推荐】修改。</span>";
tipHtml = "<span>提示:请上传像素150*150的图片,图片大小不能超过500KB。</span>";
break;
case "editor-signboard":
tipHtml = "<span>提示:请上传像素160*240的图片,图片大小不能大于500KB。</span>";
tipHtml = "<span>提示:请上传像素160*240的图片,图片大小不能超过500KB。</span>";
break;
case "editor-hotRecommend":
tipHtml = "<span>提示:请上传像素160*240的图片,图片大小不能大于500KB。</span>";
tipHtml = "<span>提示:请上传像素160*240的图片,图片大小不能超过500KB。</span>";
break;
case "editor-newGoodTab":
tipHtml = "<span>提示:最多编辑5个标签,标题名称最多5个汉字。</span>";
... ... @@ -1010,12 +1110,16 @@ function editorTipInit(id){
//弹出框编辑校验
function editorCheck(id){
switch (id){
case "editor-nav":
return checkUrlInput();
break;
case "editor-largePic":
return (checkNumInput() && checkEndTime());
return (checkNumInput() && checkEndTime() && checkUrlInput());
break;
case "editor-smallPic":
return (checkNumInput() && checkEndTime());
return (checkNumInput() && checkEndTime() && checkUrlInput());
break;
case "editor-brand":
... ... @@ -1024,39 +1128,38 @@ function editorCheck(id){
case "editor-recommend":
var title = $(".editorTitle input[name='title']");
if(title.val()){
if(checkNumInput()){
var nameList = $(".grid input[name='name']");
for(var i=0; i<nameList.length; i++){
if(!nameList.eq(i).val()){
nameList.eq(i).focus().addClass("error");
common.util.__tip("中文名不能为空!");
return false;
}
}
return true;
}
}else{
if(title.length > 0 && title.val().trim() == ""){
title.focus().addClass("error");
common.util.__tip("模块标题不能为空!");
return false;
}
if(checkNumInput() && checkUrlInput()){
var nameList = $(".grid input[name='name']");
for(var i=0; i<nameList.length; i++){
if(!nameList.eq(i).val()){
nameList.eq(i).focus().addClass("error");
common.util.__tip("中文名不能为空!");
return false;
}
}
return true;
}
break;
case "editor-hotRecommend":
return checkNumInput();
return (checkNumInput() && checkUrlInput());
break;
case "editor-signboard":
return (checkNumInput() && checkEndTime());
return (checkNumInput() && checkEndTime() && checkUrlInput());
break;
case "editor-newGoodTab":
return checkNumInput();
return (checkNumInput() && checkUrlInput());
break;
case "editor-hotGoodTab":
return checkNumInput();
return (checkNumInput() && checkUrlInput());
break;
case "editor-newProduct":
... ... @@ -1096,6 +1199,21 @@ function checkNumInput(){
}
return true;
}
//url域名校验
function checkUrlInput(){
var urlList = $(".grid input[name='url']");
for(var i=0; i<urlList.length; i++){
var reg = new RegExp(".+\.yohobuy\.com.*","g");
if(urlList.eq(i).val() != ""){
if(!reg.test(urlList.eq(i).val())){
urlList.eq(i).focus().select().addClass("error");
common.util.__tip("Url一级域名错误!必须是.yohobuy.com");
return false;
}
}
}
return true;
}
//结束时间校验
function checkEndTime(){
var endTimeList = $(".grid input[name='endTime']");
... ... @@ -1117,7 +1235,7 @@ function showEditorIconEvent(){
var editorModelId = $(this).attr("data-toggle");
var editorModelTitle = $(this).attr("data-title");
var editorIcon = "";
if(editorModelId == "editor-brand-app" || editorModelId == "editor-largePic-app" || editorModelId == "editor-recommend-app"){
if(editorModelId == "editor-brand-app"){
editorIcon += "<div class='editorBorder' style='border: 5px solid #ff69b4'></div>"
}else{
editorIcon += "<div class='editorBorder'></div>"
... ... @@ -1172,7 +1290,7 @@ function untilEditorEvent(id){
}
});
$("#"+id+" nav").hide();
$(".modal-dialog").css("width","960px");
$(".modal-dialog .modal-header .close").hide();
$(".modal-dialog .modal-body .editor-dialog").css("overflow-y","auto");
$(".modal-dialog .modal-body .editor-dialog").css("overflow-x","hidden");
}
... ... @@ -1183,7 +1301,7 @@ function resourcesHtmlInit(item,resName){
for(var i=0; i<picList.length; i++){
htmlPic += "<div class='row'>" +
"<div class='col-sm-2'><input type=file name='"+ resName +"Image' id='"+ resName +"Image_"+item.__index+"_"+i+"' value='"+picList[i].src+"' /></div>" +
"<div class='col-sm-3'><input type=text class='form-control inputChange' name='url' value='"+ picList[i].url +"' data-index='"+ item.__index +"_"+ i +"' /></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'>";
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 +"' />" +
... ... @@ -1194,7 +1312,7 @@ function resourcesHtmlInit(item,resName){
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'>";
"<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 +"' />";
... ... @@ -1209,6 +1327,15 @@ function resourcesHtmlInit(item,resName){
}
return htmlPic;
}
//展示最新,最热排名前20条
function productTopDataShow(id, products){
if(products.data && products.data.length > 0){
$("#"+id+" .top20List").html(common.util.__template2($("#top20Products").html(),products));
productTopDataLink(g.__rows);
}else{
$("#"+id+" .top20List").html("<font color='red'>*&nbsp;&nbsp;最新上架20条加载失败,请重新加载页面!</font>");
}
}
//top20商品根据以展示商品自动勾选
function productTopDataLink(productList){
$(".top20List li").removeClass("selected");
... ... @@ -1287,50 +1414,52 @@ function checkdate(startDate,endDate){
}
return true;
}
//去除json中的url参数
function removeUrlParam(id, data){
if(id == "editor-largePic" || id == "editor-smallPic"){
for(var i=0; i<data.length; i++){
var data2 = data[i].data;
for(var j=0; j<data2.length; j++){
data2[j].url = "";
}
}
}
if(id == "editor-recommend"){
for(var i=0; i<data.length; i++){
data[i].url = "";
}
}
}
/********************事件绑定*********************/
//pc跟app的tab选项事件
//基础模板,经典模板切换
$(document).on("click",".tabheader .nav-tabs li",function(){
$(this).addClass('active').siblings('li').removeClass('active');
curPlatform = $(this).attr("data-toggle");
if(curPlatform == "shopWeb-app"){
$(".moduleTypeView").hide();
}else{
$(".moduleTypeView").show();
}
curTemplateType = $(this).attr("data-toggle");
showMain();
})
//基础模板,经典模板切换
//pc,app切换
$(document).on("click","input[name=brandLevel]",function(){
curTemplateType = $("input[name=brandLevel]:checked").val();
curPlatform = $("input[name=brandLevel]:checked").val();
showMain();
})
//选择使用模板
$(document).on("change","#templateSelect",function(){
jsonMain.templateType = $(this).val();
$(this).removeClass("error");
})
//暂存模板
$(document).on("click","#saveModule",function(){
saveDecoration(100);
})
//提交审核
$(document).on("click","#submitModule",function(){
if(jsonMain.resources.shopTopBanner.data[0].shopSrc == defaultSrc){
common.util.__tip("PC端没有维护顶部banner!");
return;
}
if(jsonMain.resources.shopTopBanner_APP.isUsed == "N"){
common.util.__tip("APP端没有维护顶部banner!");
return;
}
if(jsonMain.templateType == "0"){
common.util.__tip("请选择展示使用模板!");
$("#templateSelect").focus().addClass("error");
return;
}
saveDecoration(200);
jsonMain.templateType = curTemplateType;
var templateName = curTemplateType=='2'?"经典模板":"基础模板";
common.dialog.confirm(
"提交审核确认",
"你确认使用<strong style='color:#5cb85c'>"+ templateName + "</strong>,并提交审核么?审核过程中,店铺装修将无法修改!",
function(){
saveDecoration(200);
},
function(){}
)
})
//审核通过
$(document).on("click","#checkOk",function(){
... ... @@ -1437,16 +1566,6 @@ $(document).on("change",".inputChange",function(){
}
$(this).removeClass("error");
});
//checkBox change同时更新json
$(document).on("change",".checkBoxChange",function(){
var _index = $(this).attr("data-index");
var _name = $(this).attr("name");
if($(this).is(':checked')){
g.__rows[_index][_name] = "Y";
}else{
g.__rows[_index][_name] = "N";
}
});
//选择Top20
$(document).on("click",".topAdd",function(){
if($(this).hasClass("selected")){
... ... @@ -1481,4 +1600,4 @@ $(document).on("click",".topAdd",function(){
$(".topTip span").text("商品数量已满8个,无法继续添加商品!");
}
}
});
});
\ No newline at end of file
... ...
<div class="tabheader">
<ul class="nav nav-tabs">
<li data-toggle="shopWeb-pc" class="active"><a href="javascript:">店铺装修(PC端)</a></li>
<li data-toggle="shopWeb-app"><a href="javascript:">店铺装修(移动端)</a></li>
</ul>
</div>
<div class="pageheader">
<div class="media">
<div class="media-body" style="display: block;">
<div class="panel-body">
<div class="col-sm-3">
<h4>选择模板</h4>
</div>
<div class="col-sm-3">
<div class="moduleTypeView">
<label class="radio-inline"><input type="radio" name="brandLevel" value="1">基础模板</label>
<label class="radio-inline"><input type="radio" name="brandLevel" value="2">经典模板</label>
</div>
</div>
<div class="col-sm-3">
<div class="moduleTypeSelect" style="display: none; margin-top: -10px">
<label>PC端使用模板:</label>
<select id="templateSelect" style="width: 120px; display: inline-block" class="form-control">
<option value="0" selected="selected">--选择模板--</option>
<option value="1">基础模板</option>
<option value="2">经典模板</option>
</select>
<div class="pageicon pull-left">
<i class="fa fa-th-list"></i>
</div>
<div class="media-body" style="display: block">
<ul class="breadcrumb">
<li><a href="javascript:"><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="javascript:">店铺装修</a></li>
<li>店铺装修模板</li>
</ul>
<div class="tabheader" style="margin: 10px 0 20px">
<ul class="nav nav-tabs">
<li data-toggle="1"><a href="javascript:">基础模板</a></li>
<li data-toggle="2"><a href="javascript:">经典模板</a></li>
<div class="clearfix"></div>
</ul>
</div>
<div style="margin-bottom: 10px">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<div class="moduleTypeView" style="text-align: center">
<label class="radio-inline"><input type="radio" name="brandLevel" value="pc">PC端</label>
<label class="radio-inline" style="margin-left: 30px;"><input type="radio" name="brandLevel" value="app">APP端</label>
</div>
</div>
<div id="operations" class="col-sm-3">
<div id="operations" class="col-sm-4">
<div class="moduleView" style="display: none; text-align: right; margin-top: -10px">
<input type="button" class="btn btn-default " value="返回" onclick="history.go(-1)">
</div>
... ... @@ -43,6 +43,7 @@
<input type="button" class="btn btn-default " value="返回" onclick="history.go(-1)">
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
... ... @@ -51,13 +52,13 @@
<div id="main" class="contentpanel"></div>
<!--pc端店铺基础模板-->
<script type="text/template" id="shopWeb-pc-1">
<script type="text/template" id="1-pc">
<div class="model-wrap contentpanel-pc">
<!--banner-->
<div class="model-banner model-editor" data-toggle="editor-banner" data-title="顶部图片编辑">
<img src="[[resources.shopTopBanner.data[0].shopSrc]]">
[[if resources.shopTopBanner.data[0].isShowShopName == "Y"]]
<div class="model-banner model-editor" data-toggle="editor-banner-base" data-title="顶部图片编辑">
<img src="[[resources.shopTopBanner_base.data[0].shopSrc]]">
[[if resources.shopTopBanner_base.data[0].isShowShopName == "Y"]]
<h1>[[shopName]]</h1>
[[/if]]
</div>
... ... @@ -86,7 +87,7 @@
</script>
<!--pc端店铺经典模板-->
<script type="text/template" id="shopWeb-pc-2">
<script type="text/template" id="2-pc">
<div class="model-wrap contentpanel-pc">
<!--banner-->
... ... @@ -161,8 +162,10 @@
<!--右侧main-->
<div class="model-main-right">
<!--slide-->
<div class="model-slide model-editor" data-toggle="editor-largePic" data-title="资源位大图编辑"><img src="[[resources.largeSlideImg.data[0].data[0].src]]"></div>
<!--资源位大图-->
<div class="model-slide model-editor" data-toggle="editor-largePic" data-title="资源位大图编辑">
<img src="[[resources.largeSlideImg.data[0].data[0].src]]">
</div>
<!--资源位小图-->
<div class="model-sourcePic">
<ul class="model-editor" data-toggle="editor-smallPic" data-title="资源位小图编辑">
... ... @@ -251,7 +254,7 @@
</script>
<!--app端店铺模板-->
<script type="text/template" id="shopWeb-app">
<script type="text/template" id="2-app">
<div class="model-wrap contentpanel-app">
<!--banner-->
<div class="model-banner model-editor" data-toggle="editor-banner" data-title="顶部图片编辑">
... ... @@ -283,9 +286,11 @@
<div class="clear"></div>
</ul>
</div>
<!--大图-->
<div class="largePic model-editor" data-toggle="editor-largePic-app" data-title="资源位大图编辑"><a href="javascript:"><img src="[[resources.largeSlideImg.data[0].data[0].src]]"></a></div>
<!--小图-->
<!--资源位大图-->
<div class="largePic model-editor" data-toggle="editor-largePic" data-title="资源位大图编辑">
<img src="[[resources.largeSlideImg_APP.data[0].data[0].src]]">
</div>
<!--资源位小图-->
<div class="model-smallPic model-editor" data-toggle="editor-smallPic" data-title="资源位小图编辑">
<ul>
[[each resources.oneRowTwoColImages_APP.data as item _index]]
... ... @@ -297,12 +302,10 @@
<!--热门品类-->
<div class="sortList">
<span>热门品类</span>
<div class="sortListDetail model-editor" data-toggle="editor-recommend-app" data-title="热门品类编辑">
<div class="sortListDetail model-editor" data-toggle="editor-recommend" data-title="热门品类编辑">
<ul>
[[each resources.recommend.data as item _index]]
[[if item.isShowInApp == "Y"]]
[[each resources.recommend_APP.data as item _index]]
<li><img src="[[item.src]]"><a href="[[item.url]]">[[item.name]]</a></li>
[[/if]]
[[/each]]
</ul>
<div class="clear"></div>
... ... @@ -341,7 +344,8 @@
<div class="topListDetail">
<ul>
[[each data as item _index]]
<li class="topAdd" data-productId="[[item.productId]]" data-productName="[[item.productName]]" data-productPrice="[[item.salesPrice]]" data-productSkn="[[item.productSkn]]">
<li class="topAdd" data-productId="[[item.productId]]" data-productName="[[item.productName]]"
data-productPrice="[[item.salesPrice]]" data-productSkn="[[item.productSkn]]" data-cnAlphabet="[[item.cnAlphabet]]" data-goodsId ="[[item.goodsId]]">
<a href="javascript:"><img src="[[item.src]]"><b></b><span>top[[_index+1]]</span><i></i></a>
</li>
[[/each]]
... ... @@ -352,5 +356,4 @@
<i>*&nbsp;&nbsp;</i><span></span>
</div>
</div>
</script>
</script>
\ No newline at end of file
... ...