$(function() {
const merchant_id = "マーチャントID";
const staffStartApiDomain = "https://api.staff-start.com";
const columnNum = 4;
const coordinateDetail = '/SHOP/coordinate/';
const staffDetail = '/SHOP/staff/';
let staffstartApi = new StaffStartApiCaller(staffStartApiDomain, merchant_id);
let appendNewCoodinateList = document.getElementById("new-coordinate-list-render");
let requestNewCoodinateData = {sort:'time'};
staffstartApi.getCoordinateList(requestNewCoodinateData)
.done(function (data) {
total = data.total;
result = data.item;
if (total <= 0) {
const template = '<div>該当コーディネートはありません</div>';
$("#new-coordinate-list-render").append(template);
return;
}
for(let i=0; i<columnNum; i++){
if (result[i] != undefined) {
let item = result[i];
let userResizedImage = item.user_resized_images.length > 2 ? item.user_resized_images[2].url : "/SHOP/img/simg/noimage.gif";
let coordlistResizedImages = "/SHOP/img/mimg/noimage.gif";
if (item.resized_main_images.length === 1 && Object.keys(item.resized_main_images[0]).length > 0 ) {
coordlistResizedImages = item.resized_main_images[0].m;
}
let template = '<section class="column4">';
template += '<div class="itemThumb-wrap">';
template += '<span class="badge"></span>';
template += '<p class="itemThumb">';
template += '<a href="' + coordinateDetail + item.cid + '"> <span class="item-list-span-img"><img class="max-height-333" src="' + coordlistResizedImages + '"></span></a>';
template += '</p>';
template += '</div>';
template += '<div class="description">';
template += '<div class="img-icon"><a href="'+ staffDetail + item.user_id + '"> <img src="' + userResizedImage + '"></a></div>';
template += '<div class="text"><span>' + item.user_name + '</span>';
if (item.user_height>0) {
template += '<span>' + item.user_height + 'cm</span>';
}
template += '</div>';
template += '</div>';
template += '</section>';
appendNewCoodinateList.innerHTML += template;
}
}
}).fail(function (error) {
console.log(error);
const template = '<div class="ss-api-error">情報を取得できませんでした。</div>';
$("#new-coordinate-list-render").append(template);
});
});