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

64 lines
1.4 KiB
TypeScript

// pages/info/info.ts
import Time from "../../../utils/Time";
import config from "../../../config/index"
interface IAboutData {
timer?: number;
total?: number;
beginFriendText: string;
}
Page({
data: <IAboutData>{
copyright: `Copyright © 2017 - ${new Date().getFullYear()} imyeyu.com`,
timer: undefined,
total: undefined,
beginFriendText: "相识 -- 天 -- 小时 -- 分钟 -- 秒",
beginLoveText: "相恋 -- 天 -- 小时 -- 分钟 -- 秒"
},
onShow() {
const beginLove = new Date("2025/11/10 00:10:00");
const beginFriend = new Date("2025/06/28 16:00:00");
const timer = setInterval(() => {
{
const r = Time.between(beginLove)
this.setData({
beginLoveText: `相恋 ${r.d}${r.h} 小时 ${r.m.toString().padStart(2, "0")} 分钟 ${r.s.toString().padStart(2, "0")}`
})
}
{
const r = Time.between(beginFriend)
this.setData({
beginFriendText: `相识 ${r.d}${r.h} 小时 ${r.m.toString().padStart(2, "0")} 分钟 ${r.s.toString().padStart(2, "0")}`
})
}
}, 1000)
this.setData({
timer
});
wx.request({
url: `${config.url}/journal/total`,
method: "GET",
header: {
Key: wx.getStorageSync("key")
},
success: (resp: any) => {
this.setData({
total: resp.data.data
});
}
});
},
onHide() {
this.data.timer && clearInterval(this.data.timer);
},
exit() {
wx.redirectTo({
"url": "/pages/index/index?from=info"
})
}
})