微信小程序页面迁移校验之前 P5任务处理之前
This commit is contained in:
45
apps/miniprogram - 副本/miniprogram/pages/notes/notes.ts
Normal file
45
apps/miniprogram - 副本/miniprogram/pages/notes/notes.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
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()
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user