const { get } = require("../../utils/api"); const { showError } = require("../../utils/page-helpers"); Page({ data: { member: null, loading: false }, onLoad(options) { wx.setNavigationBarTitle({ title: "同学资料" }); this.load(options.id); }, async load(id) { if (!id) return; this.setData({ loading: true }); try { const member = await get(`/api/directory/${id}`); this.setData({ member }); } catch (error) { showError(error, "加载资料失败"); } finally { this.setData({ loading: false }); } } });