"use strict";
///
(function () {
'use strict';
var Page = {
Init: function Init() {
$(".commentList .fancybox").fancybox();
/*灞曞紑璇勮*/
$(".userComment .Comment_exponent .amount").click(function () {
$(this).parents(".userComment").find(" [data-action='toggleReplays']").triggerHandler("click");
});
$(".userComment [data-action='toggleReplays']").click(function () {
$(this).find(".fa").toggleClass("active");
if ($(this).next(".replyMessages").is(":animated")) {
return;
}
if (!$(this).hasClass("opened")) {
$(this).addClass("opened");
$(this).find("span").html("鐐瑰嚮鍚堝苟");
} else {
$(this).removeClass("opened");
$(this).find("span").html("鐐瑰嚮灞曞紑");
}
$(this).next(".replyMessages").stop(false, true).slideToggle(400);
});
//$(".UserEvaluation .wrap_products .navBar ul li").click(function () {
// $(this).addClass("active").siblings().removeClass("active");
// var num = $(this).attr("data-num");
// $(".UserEvaluation .wrap_products .comment ").find("ul").eq(num -1).fadeIn(300).siblings().hide();
// $(".UserEvaluation .wrap_products .comment ul:nth-child("+num+")").fadeIn(300).siblings().hide();
//})
///*璇勮鏁扮洰鐨勬姈鍔?/
//$(".num").mouseenter(function () {
// $(this).addClass("tada");
//}).mouseleave(function () {
// $(this).removeClass("tada");
//})
//$(".PagePilot ul li").click(function () {
// $(this).addClass("active").siblings().removeClass("active");
//})
////鎵撳紑鍥炲鍒楄〃
//$("[data-action='toggleReplyMessages']").click(function () {
// $(this).next().slideToggle(1000);
// $(this).find(".fa").toggleClass("active");
// $(this).find("span").toggle();
//})
}
};
//鑾峰彇ID
var ID = getNavInfo('ID');
//鑾峰彇PageIndex
var PageIndex = getNavInfo('PageIndex') || '1';
//浜у搧鍒楄〃
function getList1() {
return new Promise(function (resolve, reject) {
//鍋氫竴浜涘紓姝ユ搷浣
ajax({
url: '/customer/evaluation/prdList',
complete: function complete(xhr) {
var data = xhr.responseJSON || JSON.parse(xhr.responseText);
var _list = data.data.list;
var _list2 = void 0;
if (!ID) {
ID = _list[0].id;
}
_list2 = _list.find(function (item) {
return item.id == ID;
});
// console.log(_list2);
var _listStr = '';
var _listStr2 = '';
console.log('浜у搧鍒楄〃:', _list);
// navBar 瀵艰埅鏍忎慨鏀
for (var i in _list) {
_listStr += "
\n " + _list[i].name + "\n ";
}
$('.navBar ul').html(_listStr);
// productDetail 淇敼
_listStr2 = "\n - \n \n
\n - \n
" + _list2.name + "
\n \n
\n - \u7279\u70B9
\n - " + _list2.subject + "
\n
\n
\n \n
";
$('.productDetail ').html(_listStr2);
resolve(_list);
}
});
});
}
//璇勪环鍒楄〃
function getList2() {
return new Promise(function (resolve, reject) {
//鍋氫竴浜涘紓姝ユ搷浣
var _limit = 5;
ajax({
type: 'post',
url: '/customer/evaluation/evaluateList',
params: {
limit: _limit,
page: PageIndex,
prdId: ID
},
complete: function complete(xhr) {
var data = xhr.responseJSON || JSON.parse(xhr.responseText);
var _list = data.data.list || {};;
var _listStr = '';
console.log('璇勪环鍒楄〃:', _list);
//璁剧疆鍒嗛〉
setPageNav(data.data, _limit);
for (var i in _list) {
var _photoList = _list[i].photos.split(',');
var _photoStr = '';
for (var _i in _photoList) {
if (_photoList[_i]) {
_photoStr += "\n \n ";
}
}
_listStr += "";
}
_listStr = _listStr || '鏆傛棤璇勪环';
$('.commentList').html(_listStr);
resolve(_list);
}
});
});
}
getList1().then(getList2).then(Page.Init);
})();