basic-info.js 1.91 KB
var $ = require('jquery'),
	common = require('../../common/common');

var basicInfohtml = '',
	convertObj = {
		ageLevel: {
			'1': '成人',
			'2': '大童',
			'3': '小童'
		},
		gender: {
			1: '男',
			2: '女',
			3: '通用'
		},
		grade: {
			'1': '是',
			'null': '否'
		},
		isOutLets: {
			'Y': '是',
			'N': '否'
		},
		isLimited: {
			'Y': '是',
			'N': '否'
		},
		isPromotionalGifts: {
			'Y': '是',
			'N': '否'
		},
		isAdvance: {
			'Y': '是',
			'N': '否'
		},
		isLimitbuy: {
			'Y': '是',
			'N': '否'
		},
		attribute: {
			1: '普通',
			2: '赠品'
		}
	};

/*
 * 基本信息value值转换
 * @param: basicInfo(请求的要渲染的数据), obj(转换的对象)
 */
function convert(basicInfo, obj) {
	$.each(basicInfo, function(key, value) {
		if (convertObj[key]) {
			basicInfo[key] = convertObj[key][value];
		}
	});
	return basicInfo;
}

var basicInfoData = convert(NETSALEDATA.baseProductInfo.baseProduct, convertObj);

//基本信息
basicInfoData.renderType = $('.contentpanel').data('type');
basicInfohtml = common.util.__template2($('#basicInfo').html(), basicInfoData);
$('#basic-info').html(basicInfohtml);

//能否补货
$('#goods-table').html(common.util.__template2($('#goodsList').html(), {
	goodsList: NETSALEDATA.goodsList
}));


//上架必填
NETSALEDATA.productExtBo.sellChannels = NETSALEDATA.productExtBo.sellChannels.replace(/,/g, "|");
$('#product-ext').html(common.util.__template2($('#productExtBoTemp').html(), NETSALEDATA.productExtBo));

$('#saveBasicInfo').on('click', function() {
	NETSALEEDIT.submit('/goods/product/saveNetSaleBaseInfo', function(option) {
		var list = option.data.sellChannels.split('|').join(',');
		option.data.sellChannels = list;
		option.success = function(res) {
			res = res.data;
			if (res.code == '200') {
				NETSALEEDIT.$tip(res.message, function() {}, 'growl-success');
			} else {
				NETSALEEDIT.$tip(res.message);
			}
			return false;
		}
	});
});