netsale-edit.js 2.02 KB
'use strict';
var $ = require('jquery'),
	common = require('../common/common');
require('../util/custom.js');
/*
 *	获取业务数据
 */
window.NETSALEDATA = require('./partials/data.js');


window.GOLABDATA = {
	on: function(key, callback) {
		var that = this;
		if (!that.registerEvent) {
			that.registerEvent = {};
		}
		if (!that.registerEvent[key]) {
			that.registerEvent[key] = [];
		}
		if (that.registerEvent[key].indexOf(callback) == -1) {
			that.registerEvent[key].push(callback);
		}
	},
	fire: function(key) {
		var that = this;
		if (!this.registerEvent) return;
		if (key) {
			if (!this.registerEvent[key]) return;
			var listeners = that.registerEvent[key];
			var args = [].slice.call(arguments, 1);
			for (var i in listeners) {
				return listeners[i].apply(this, args);
			}
		} else {
			var map = {},
				args = [].slice.call(arguments, 1);
			for (var key in that.registerEvent) {
				var listeners = that.registerEvent[key];
				for (var i in listeners) {
					map[key] = listeners[i].apply(this, args);
				}
			}
			return map;
		}

	}
};



//获取skn
if (NETSALEDATA && NETSALEDATA.baseProductInfo && NETSALEDATA.baseProductInfo.baseProduct) {
	$('#productSkn').val(NETSALEDATA.baseProductInfo.baseProduct.productSkn);
} else {
	common.util.__tip("SKN不存在");
}


console.log(NETSALEDATA);

/*加载其他模块*/
require('./partials/basic-info');
require('./partials/editor_recommend');
require('./partials/model');
require('./partials/video.js');
require('./partials/brand-relation');
require('./partials/add-info');
require('./partials/netsale-ty.js');


if ($('.contentpanel').data('type') == 'info') {
	$('form').find('input').prop('disabled', true);
	$('form').find('.btn').addClass('disabled');
}

$(document).on("click", "#saveAllInfo", function() {
	var data = {};
	$.each(GOLABDATA.fire(), function(key, value) {
		if (typeof value == 'string') {
			data = value;
			return;
		}
		$.extend(data, value, true);
	});

	common.util.__ajax({
		url: '/goods/product/saveNetSaleAllInfo',
		data: data
	}, function(res) {

	});
})