family-coinMall.page.js
1.12 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
import 'home/family-coinMall.page.css';
import $ from 'yoho-jquery';
import Page from 'yoho-page';
class IconMall extends Page {
constructor() {
super();
this.selector = {
$tabItem: $('.tab .tab-item'),
$defaultTabItem: $('.tab .tab-item:first'),
$coinMallC: $('.coin-mall-c')
};
this.init();
}
init() {
this.bindEvents();
this.defaultChosen();
}
bindEvents() {
this.selector.$tabItem.on('click', this.tabItem.bind(this));
}
defaultChosen() {
let defaultId = this.selector.$defaultTabItem.attr('id');
this.selector.$defaultTabItem.addClass('active');
this.selector.$coinMallC.attr('id', defaultId);
}
tabItem(e) {
let $this = $(e.currentTarget);
let $thisId = $this.attr('id');
$(`#${$thisId}-tab`).show().siblings('.tab-item-c').hide();
this.selector.$coinMallC.removeAttr('id');
this.selector.$coinMallC.attr('id', $thisId);
$this.addClass('active').siblings('div').removeClass('active');
}
}
$(() => {
new IconMall();
});