43 lines
801 B
TypeScript
43 lines
801 B
TypeScript
// index.ts
|
|
|
|
import config from "../../config/index"
|
|
import { JournalPage, JournalPageType } from "../../types/Journal";
|
|
import { JournalApi } from "../../api/JournalApi";
|
|
|
|
interface IndexData {
|
|
key: string;
|
|
}
|
|
|
|
Page({
|
|
data: <IndexData>{
|
|
key: ""
|
|
},
|
|
onShow() {
|
|
const key = wx.getStorageSync("key");
|
|
if (key) {
|
|
this.setData({
|
|
key
|
|
});
|
|
}
|
|
},
|
|
async navigateToMain() {
|
|
try {
|
|
await JournalApi.getList({
|
|
index: 0,
|
|
size: 1,
|
|
type: JournalPageType.PREVIEW
|
|
});
|
|
wx.setStorageSync("key", this.data.key);
|
|
wx.switchTab({
|
|
url: "/pages/main/journal/index",
|
|
})
|
|
} catch (error: any) {
|
|
if (error?.code === 40100) {
|
|
wx.showToast({ title: "密码错误", icon: "error" });
|
|
} else {
|
|
wx.showToast({ title: "验证失败", icon: "error" });
|
|
}
|
|
}
|
|
}
|
|
})
|