|
|
const loading = require('../../plugin/loading'),
|
|
|
lazyLoad = require('yoho-jquery-lazyload');
|
|
|
|
|
|
require('../../common');
|
|
|
|
|
|
/*
|
|
|
留言view
|
|
|
*/
|
...
|
...
|
@@ -79,7 +84,85 @@ class RatingView { |
|
|
/*
|
|
|
订单列表view
|
|
|
*/
|
|
|
class OrderListView {}
|
|
|
class OrderListView {
|
|
|
constructor() {
|
|
|
this.bindEvent();
|
|
|
this.order = {
|
|
|
page: 0,
|
|
|
end: false
|
|
|
};
|
|
|
this.$curContainer = $('#order-container').children('.orders:not(.hide)');
|
|
|
this.getOrder(this);
|
|
|
}
|
|
|
|
|
|
bindEvent() {
|
|
|
// 订单
|
|
|
$('body').on('touchstart', '.menu .order', function() {
|
|
|
$('#chat-main-wrap').hide();
|
|
|
$('#order-list-wrap').show();
|
|
|
|
|
|
$('.order-back').on('click', function() {
|
|
|
$('#order-list-wrap').hide();
|
|
|
$('#chat-main-wrap').show();
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
getOrder(self, cb, option) {
|
|
|
var opt = {
|
|
|
type: 1,
|
|
|
page: self.order.page + 1
|
|
|
};
|
|
|
|
|
|
var show = option && !option.noLoadingMask;
|
|
|
|
|
|
if (this.inAjax) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
this.inAjax = true;
|
|
|
show && loading.showLoadingMask();
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/service/getOrders',
|
|
|
data: opt,
|
|
|
success: function(data) {
|
|
|
var num;
|
|
|
|
|
|
if (data) {
|
|
|
self.order.page = opt.page;
|
|
|
|
|
|
if (opt.page === 1) {
|
|
|
self.$curContainer.html(data);
|
|
|
lazyLoad(self.$curContainer.find('.lazy'), {
|
|
|
try_again_css: 'order-failure'
|
|
|
});
|
|
|
} else {
|
|
|
num = self.$curContainer.children('.order').length;
|
|
|
self.$curContainer.append(data);
|
|
|
|
|
|
// lazyload
|
|
|
lazyLoad(self.$curContainer.children('.order:gt(' + (num - 1) + ')').find('.lazy'), {
|
|
|
try_again_css: 'order-failure'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
window.rePosFooter(); // 重新计算底部位置
|
|
|
} else {
|
|
|
if (opt.page > 1) {
|
|
|
return;
|
|
|
}
|
|
|
self.$curContainer.html('<div class="no-order"><div class="icon"></div><span>你还没有订单!</span><a class="walk-way" href="//m.yohobuy.com/product/new">随便逛逛</a></div>');
|
|
|
self.order.end = true;
|
|
|
}
|
|
|
|
|
|
this.inAjax = false;
|
|
|
show && loading.hideLoadingMask();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
...
|
...
|
@@ -87,4 +170,4 @@ class ChatView { |
|
|
|
|
|
}
|
|
|
|
|
|
export {RatingView, LeaveMSGView}; |
|
|
export {RatingView, LeaveMSGView, OrderListView}; |
...
|
...
|
|