search-key.js 1.83 KB
var $ = require('jquery'),
	common = require('../../../../common/common');

var searchKeys = window.NETSALEDATA.productExtBo.searchKeys || "";

$("#searchKeys").val(searchKeys);
var g = new common.grid({
	el: "#search-key",
	hash: false,
	columns: [{
		display: "ID",
		name: "id"
	}, {
		display: "内容",
		name: "content"
	}, {
		display: "操作",
		name: "",
		render: function(item) {
			return '<a class="btn btn-info add" data-index="' + item.__index + '">添加</a>';
		}
	}]
});

g.init('/netSale/queryHotSearchTerms');

$("#searchKeys").on('change', function() {
	searchKeys = $("#searchKeys").val();
});

$(document).on('click', '.add', function() {
	var item = g.rows[$(this).data("index")];
	var value = $("#searchKeys").val();
	if (value) value += ",";
	$("#searchKeys").val(value + item.content);
	searchKeys = $("#searchKeys").val();
});

$("#save-searchKey").on('click', function() {
	common.util.__ajax({
		url: '/netSale/saveNetSaleSearchKeys',
		data: {
			productSkn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
			searchKeys: searchKeys
		}
	});
});

var taobaoUrl = window.NETSALEDATA.productUrlBo.taobaoUrl || "";
var tmallUrl = window.NETSALEDATA.productUrlBo.tmallUrl || "";
var jdUrl = window.NETSALEDATA.productUrlBo.jdUrl || "";
$("#taobaoUrl").val(taobaoUrl);
$("#tmallUrl").val(tmallUrl);
$("#jdUrl").val(jdUrl);
$("#taobaoUrl").on('change', function() { taobaoUrl = $("#taobaoUrl").val(); });
$("#tmallUrl").on('change', function() { tmallUrl = $("#tmallUrl").val(); });
$("#jdUrl").on('change', function() { jdUrl = $("#jdUrl").val(); });
$("#save-urlList").on('click', function() {
	common.util.__ajax({
		url: '/netSale/saveProductUrlList',
		data: {
			productSkn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
			taobaoUrl: taobaoUrl,
			tmallUrl : tmallUrl,
			jdUrl    : jdUrl
		}
	});
	return false;
});