Initial commit
Made-with: Cursor
This commit is contained in:
37
srde/miniprogram/pages/dashboard/dashboard.ts
Normal file
37
srde/miniprogram/pages/dashboard/dashboard.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { mockAccount, mockTrades } from '../../services/api';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
loading: true,
|
||||
error: '',
|
||||
account: mockAccount,
|
||||
trades: mockTrades.slice(0, 3),
|
||||
},
|
||||
onLoad() {
|
||||
this.load();
|
||||
},
|
||||
onShow() {
|
||||
const app = getApp<IAppOption>();
|
||||
if (app.globalData.account && Date.now() - app.globalData.accountLoadedAt < 30000) {
|
||||
this.setData({ account: app.globalData.account });
|
||||
} else {
|
||||
this.load();
|
||||
}
|
||||
},
|
||||
load() {
|
||||
this.setData({ loading: true, error: '' });
|
||||
const app = getApp<IAppOption>();
|
||||
setTimeout(() => {
|
||||
app.globalData.account = mockAccount;
|
||||
app.globalData.accountLoadedAt = Date.now();
|
||||
this.setData({
|
||||
loading: false,
|
||||
account: mockAccount,
|
||||
trades: mockTrades.slice(0, 3),
|
||||
});
|
||||
}, 300);
|
||||
},
|
||||
goCreate() {
|
||||
wx.navigateTo({ url: '/pages/create/create' });
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user