...
|
...
|
@@ -5,6 +5,7 @@ const loading = require('../../plugin/loading'), |
|
|
require('../../common');
|
|
|
|
|
|
import {EventEmitter, api} from './store';
|
|
|
import qs from 'yoho-qs';
|
|
|
|
|
|
|
|
|
const LeaveMSGView = function(elem) {
|
...
|
...
|
@@ -156,8 +157,20 @@ const OrderListView = function(elem) { |
|
|
this.$localOrders = this.$elem.find('[data-tab=local]');
|
|
|
this.$globalOrders = this.$elem.find('[data-tab=global]');
|
|
|
|
|
|
// 分页数据
|
|
|
this.state = {
|
|
|
global: {
|
|
|
curCount: 0,
|
|
|
totalCount: null
|
|
|
},
|
|
|
order: {
|
|
|
curCount: 0,
|
|
|
totalCount: null
|
|
|
}
|
|
|
};
|
|
|
|
|
|
this.bindEvents();
|
|
|
this.fetchOrders();
|
|
|
// this.fetchOrders();
|
|
|
};
|
|
|
|
|
|
OrderListView.prototype = $.extend({}, EventEmitter.prototype, {
|
...
|
...
|
@@ -173,7 +186,9 @@ OrderListView.prototype = $.extend({}, EventEmitter.prototype, { |
|
|
});
|
|
|
|
|
|
// 被通知显示,执行显示
|
|
|
this.on('show.OderListView', $.proxy(this.toggleHide, this, false));
|
|
|
this.on('show.OderListView', (event, type) => {
|
|
|
self.toggleHide(false, type);
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -203,25 +218,53 @@ OrderListView.prototype = $.extend({}, EventEmitter.prototype, { |
|
|
* @param boolean willHide;
|
|
|
* @return this
|
|
|
*/
|
|
|
toggleHide: function(willHide) {
|
|
|
toggleHide: function(willHide, type) {
|
|
|
this.$elem.toggleClass('chat-page-hide', willHide);
|
|
|
|
|
|
if (!willHide) {
|
|
|
let orderState = this.state[type];
|
|
|
let {totalCount} = orderState;
|
|
|
|
|
|
totalCount === null && this.fetchOrderByType(type, orderState);
|
|
|
|
|
|
if (type === 'global') {
|
|
|
this.$globalOrders.show();
|
|
|
this.$localOrders.hide();
|
|
|
} else if (type === 'order') {
|
|
|
this.$globalOrders.hide();
|
|
|
this.$localOrders.show();
|
|
|
}
|
|
|
} else {
|
|
|
this.$globalOrders.hide();
|
|
|
this.$localOrders.hide()
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
},
|
|
|
|
|
|
fetchOrderByType: function(type, orderState) {
|
|
|
let self = this;
|
|
|
let $order = type === 'global' ? this.$globalOrders : this.$localOrders;
|
|
|
|
|
|
/**
|
|
|
* method: 获取订单
|
|
|
*/
|
|
|
fetchOrders: function() {
|
|
|
const self = this;
|
|
|
let {totalCount} = orderState;
|
|
|
|
|
|
return api.fetchOrders().done(result => {
|
|
|
let html = self.orderListT({orders: result.data});
|
|
|
// TODO: 分页
|
|
|
if (totalCount === null) { // 还未加载数据
|
|
|
api.fetchOrders(type).done(
|
|
|
result => {
|
|
|
let html = self.orderListT({
|
|
|
orders: result.data
|
|
|
});
|
|
|
|
|
|
self.$localOrders.append(html);
|
|
|
lazyLoad($('img.lazy'));
|
|
|
});
|
|
|
orderState.totalCount = result.data.length;
|
|
|
orderState.curCount = result.data.length;
|
|
|
|
|
|
$order.append(html);
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
|