feat: add animated choice modes and bracket editor
Verify mini program and deploy preview / verify-deploy (push) Successful in 50s
Verify mini program and deploy preview / verify-deploy (push) Successful in 50s
This commit is contained in:
+10
-2
@@ -1,13 +1,13 @@
|
||||
var api = require('../../utils/api');
|
||||
|
||||
Page({
|
||||
data: { tests: [], loading: true, error: '' },
|
||||
data: { tests: [], visibleTests: [], keyword: '', loading: true, error: '' },
|
||||
onLoad: function () { this.loadTests(); },
|
||||
onPullDownRefresh: function () { this.loadTests(true); },
|
||||
loadTests: function (refreshing) {
|
||||
var self = this;
|
||||
api.request('/api/v1/tests').then(function (tests) {
|
||||
self.setData({ tests: tests, loading: false, error: '' });
|
||||
self.setData({ tests: tests, visibleTests: tests, loading: false, error: '' });
|
||||
}).catch(function (error) {
|
||||
self.setData({ loading: false, error: error.message || '加载失败' });
|
||||
}).then(function () {
|
||||
@@ -19,5 +19,13 @@ Page({
|
||||
openTest: function (event) {
|
||||
xhs.navigateTo({ url: '/pages/test/test?slug=' + event.currentTarget.dataset.slug });
|
||||
},
|
||||
search: function (event) {
|
||||
var keyword = (event.detail.value || '').trim().toLowerCase();
|
||||
var visible = this.data.tests.filter(function (item) {
|
||||
return (item.title + ' ' + item.subtitle).toLowerCase().indexOf(keyword) >= 0;
|
||||
});
|
||||
this.setData({ keyword: keyword, visibleTests: visible });
|
||||
},
|
||||
openDiscover: function () { xhs.navigateTo({ url: '/pages/discover/discover' }); },
|
||||
openMe: function () { xhs.navigateTo({ url: '/pages/me/me' }); }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user