Authored by lijian

网销优化2.5

... ... @@ -247,6 +247,18 @@ var util = {
__input: function(id) {
return !!~$.trim($('#' + id).val()) ? $('#' + id).val() : ""
},
__setInput: function(id, value) {
if(/:checked/g.test(id)){
var values = value.split(value, '|');
if ($(id).length == values.length) {
$(id).each(function(){
$(this).val(values[0]);
});
}
}else{
$('#' + id).val(value);
}
},
__dateFormat: function(data, format) {
if (!isNaN(data)) {
var date = {
... ...
... ... @@ -74,7 +74,9 @@ var basicInfohtml = '',
},
basicInfo = NETSALEDATA.baseProductInfo.baseProduct || '',
productExtBo = NETSALEDATA.productExtBo || '';
var basicInfoTmp = JSON.stringify(basicInfo);
basicInfoTmp = JSON.parse(basicInfoTmp);
//alert( JSON.stringify(basicInfo));
/*
* 基本信息value值转换
* @param: basicInfo(请求的要渲染的数据), obj(转换的对象)
... ... @@ -108,6 +110,53 @@ basicInfoData.renderType = $('.contentpanel').data('type');
basicInfohtml = common.util.__template2($('#basicInfo').html(), basicInfoData);
$('#basic-info').html(basicInfohtml);
$(document).ready(function(){
initInfo(basicInfoTmp);
});
function initInfo(basicInfo) {
$("#ageLevel").val(basicInfo.ageLevel);
$("#seasons").val(basicInfo.seasons);
$("#gender").val(basicInfo.gender);
$("#grade").val(basicInfo.grade);
$("#isLimited").val(basicInfo.isLimited);
$("#isOutlets").val(basicInfo.isOutLets);
var ageLevel=basicInfo.ageLevel;
$(":checkbox[name=ageLevel]").each(function(){
if(ageLevel.indexOf($(this).val())>-1){
$(this).prop("checked",true)
}
});
$(":checkbox[name=seasons]").each(function(){
if(basicInfo.seasons.indexOf($(this).val())>-1){
$(this).prop("checked",true)
}
});
$(":radio[name=gender]").each(function(){
if(basicInfo.gender.indexOf($(this).val())>-1){
$(this).prop("checked",true)
}
});
$(":radio[name=grade]").each(function(){
if(basicInfo.grade.indexOf($(this).val())>-1){
$(this).prop("checked",true)
}
});
$(":radio[name=isLimited]").each(function(){
if(basicInfo.isLimited.indexOf($(this).val())>-1){
$(this).prop("checked",true)
}
});
$(":radio[name=isOutLets]").each(function(){
if(basicInfo.isOutLets.indexOf($(this).val())>-1){
$(this).prop("checked",true)
}
});
}
//能否补货
var suppledTable = new common.grid({
el: '#suppled-table',
... ... @@ -169,6 +218,54 @@ common.util.__ajax({
}, true);
$('#product-ext').html(common.util.__template2($('#productExtBoTemp').html(), productExtBo));
$(document).on("change", ":checkbox[name=ageLevel]", function () {
var value = $(this).val();
var c = $(":checkbox[name=ageLevel]");
if ($(this).is(":checked")) {
if (value == 1) {
c.slice(1, 5).prop("checked", false);
} else {
c.eq(0).prop("checked", false);
}
}
var arr = [];
$(":checked[name=ageLevel]").each(function () {
arr.push($(this).val())
});
$("#ageLevel").val(arr.join('|'));
});
$(document).on("change",":checkbox[name=seasons]",function(){
var value=$(this).val();
var c=$(":checkbox[name=seasons]");
if($(this).is(":checked")){
if(value=="seasons"){
c.slice(0,4).prop("checked",false);
}else{
c.eq(4).prop("checked",false);
}
}
var arr=[];
$(":checked[name=seasons]").each(function(){
arr.push($(this).val())
});
$("#seasons").val(arr.join(','));
});
$(document).on("change",":radio[name=gender]",function(){
$("#gender").val($(this).val());
});
$(document).on("change",":radio[name=isOutLets]",function(){
$("#isOutlets").val($(this).val());
});
$(document).on("change",":radio[name=grade]",function(){
$("#grade").val($(this).val());
});
$(document).on("change",":radio[name=isLimited]",function(){
$("#isLimited").val($(this).val());
});
//如果是info页,所有input btn置灰
if ($('.contentpanel').data('type') == 'info') {
$('.contentpanel').find('input').prop('disabled', true);
... ... @@ -193,7 +290,7 @@ $('#saveBasicInfo').on('click', function() {
});
});
GOLABDATA.on("LYbasicInfo", function() {
GOLABDATA.on("LYbasicInfo", function () {
var data = null;
if (!e.validate(true)) {
return e.errMessage;
... ... @@ -202,6 +299,13 @@ GOLABDATA.on("LYbasicInfo", function() {
data.productSkn = $('#productSkn').val();
data.sellChannels = data.sellChannels.split('|').join(',');
data.shopIds = data.shopIds ? data.shopIds.split('|').join(',') : '';
data.ageLevel = common.util.__input('ageLevel');
data.gender = common.util.__input('gender');
data.grade = common.util.__input('grade');
data.isLimited = common.util.__input('isLimited');
data.isOutlets =$('#isOutlets').val();;
data.seasons = common.util.__input('seasons');
return data;
}
});
\ No newline at end of file
... ...
... ... @@ -527,8 +527,16 @@ $(document).on("click", "#fenMainSave", function () {
common.util.__ajax({
url: '/product/manageProductImg',
data: data
});
}, function(res) {
if (res.code == 200) {
common.util.__tip(res.message, 'success');
} else {
common.util.__tip(res.message, 'danger');
}
}, true);
return false;
});
GOLABDATA.on("fenmian", function () {
... ... @@ -559,7 +567,8 @@ GOLABDATA.on("fenmian", function () {
//if (map.goodsImagesBoList.length == 0) return;
map.goodsImagesBoList = JSON.stringify(map.goodsImagesBoList);
if(typeof(map.productSkc) == "undefined"){
return '<p>请设置商品默认封面</p>';
// common.util.__tip("请设置商品默认封面", 'danger');
return "请设置商品默认封面";
}
if (errorMsg != '') {
return {
... ...
... ... @@ -159,7 +159,6 @@ $(document).on('click', '#modelTry-save', function () {
}
}, function (res) {
if(res.code==200){
}
});
});
\ No newline at end of file
... ...