init project
This commit is contained in:
46
miniprogram/pages/index/index.ts
Normal file
46
miniprogram/pages/index/index.ts
Normal file
@ -0,0 +1,46 @@
|
||||
// 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" })
|
||||
});
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user