Files
gaoYuJournal/miniprogram/pages/index/index.ts
2025-12-05 10:38:55 +08:00

47 lines
789 B
TypeScript

// index.ts
import config from "../../config/index"
interface IndexData {
key: string;
}
Page({
data: <IndexData>{
key: ""
},
onShow() {
const key = wx.getStorageSync("key");
if (key) {
this.setData({
key
});
}
},
navigateToMain() {
wx.request({
url: `${config.url}/journal/list`,
method: "POST",
header: {
Key: this.data.key
},
data: {
index: 0,
size: 1
},
success: (resp) => {
const data = resp.data as any;
if (data.code === 20000) {
wx.setStorageSync("key", this.data.key);
wx.switchTab({
url: "/pages/main/journal/index",
})
} else {
wx.showToast({ title: "密码错误", icon: "error" });
}
},
fail: () => wx.showToast({ title: "验证失败", icon: "error" })
});
}
})