Files
Neo-ZQYY/apps/miniprogram - 副本/miniprogram/pages/notes/notes.ts

46 lines
1020 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { mockNotes } from '../../utils/mock-data'
import type { Note } from '../../utils/mock-data'
Page({
data: {
loading: true,
error: false,
notes: [] as Note[],
/** 系统状态栏高度px用于自定义导航栏顶部偏移 */
statusBarHeight: 20,
},
onLoad() {
// 获取真实状态栏高度兼容所有机型iPhone 刘海屏、安卓异形屏等)
const sysInfo = wx.getSystemInfoSync()
this.setData({ statusBarHeight: sysInfo.statusBarHeight || 20 })
this.loadData()
},
loadData() {
this.setData({ loading: true, error: false })
setTimeout(() => {
// TODO: 替换为真实 API 调用 GET /api/xcx/notes
try {
this.setData({
loading: false,
notes: mockNotes,
})
} catch {
this.setData({ loading: false, error: true })
}
}, 400)
},
/** 返回上一页 */
onBack() {
wx.navigateBack()
},
/** 错误态重试 */
onRetry() {
this.loadData()
},
})