brand-render.js
893 Bytes
let $ = require('yoho-jquery');
let dbClass = 'data-bind';
function render(data) {
if (data.history && data.history.list && data.history.list.length) {
let hisEl = $('.history>li').remove();
$.each(data.history.list, function(i, his) {
let itemEl = hisEl.clone();
itemEl.find('a')
.attr('href', his.url)
.attr('brandName', his.name)
.attr('collectTime', his.searchTime)
.text(his.name);
$('.history').append(itemEl);
});
$('.net-history').removeClass(dbClass);
} else {
$('.net-history').remove();
}
}
module.exports = function(callback) {
$.ajax({
type: 'POST',
url: '/brands/searchAsync',
success: function(data) {
render(data.data);
callback && callback(data);
}
});
};