-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlanguage.js
41 lines (41 loc) · 1.03 KB
/
language.js
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
const { language, state } = require('../store/index');
const searchBar = require('../../components/search-bar/index.js');
Page({
data: {
searchBar: {
focus: false,
},
language: {
options: language,
state: state.trending.language,
}
},
onPullDownRefresh() {
wx.stopPullDownRefresh();
},
onSearchBarChange(e) {
this.data.language.options = language.filter((item) => {
if (item.name.match(new RegExp(e.detail.value, 'gi'))) {
return item;
}
});
this.setData({
language: this.data.language,
});
},
onSelectChange(e) {
state.trending.language = this.data.language.options[e.currentTarget.dataset.index];
this.data.language.state = this.data.language.options[e.currentTarget.dataset.index];
this.setData({
language: this.data.language
})
wx.navigateBack();
},
onLoad() {
this.data.language.state = state.trending.language;
this.setData({
language: this.data.language
})
searchBar.init.apply(this);
}
})