controller.js
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'use strict';
import {
Controller
} from 'js/yoho-mvc';
import {
TabView,
GetContent
} from './view';
import {
globalSearch as search
} from './model';
let hisContent = require('hbs/home/grade-new.hbs');
class GradeController extends Controller {
constructor() {
super();
this.tabView = new TabView();
this.content = new GetContent();
this.content.on('search', this.doSearch.bind(this));
this.page = 1;
this.loading = false;
}
doSearch() {
if (!this.end && !this.loading) {
this.page++;
this.search(this.page);
}
}
search(page) {
this.loading = true;
search('//m.yohobuy.com/home/gradeNew/getHis', {page: page}).then(data => {
if (data.detailHis <= 0) {
this.end = true;
} else {
$('.ul-detail:first').append(hisContent(data));
}
}).catch(() => {}).finally(() => {
this.loading = false;
});
}
}
module.exports = GradeController;