Files
pk-lab-xhs/pages/index/index.js
T
codex-bot 350aae797f
Verify mini program and deploy preview / verify-deploy (push) Failing after 34s
feat: launch PK testing application
2026-09-18 21:50:25 +08:00

24 lines
847 B
JavaScript

var api = require('../../utils/api');
Page({
data: { tests: [], 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: '' });
}).catch(function (error) {
self.setData({ loading: false, error: error.message || '加载失败' });
}).then(function () {
if (refreshing) xhs.stopPullDownRefresh();
}, function () {
if (refreshing) xhs.stopPullDownRefresh();
});
},
openTest: function (event) {
xhs.navigateTo({ url: '/pages/test/test?slug=' + event.currentTarget.dataset.slug });
},
openMe: function () { xhs.navigateTo({ url: '/pages/me/me' }); }
});