Files
FreeERP.Applet/miniprogram/pages/components/date-now/date-now.ts

56 lines
1.0 KiB
TypeScript
Raw Normal View History

2026-03-12 15:16:49 +08:00
import { formatTime } from '@/utils/util';
Component({
options: { multipleSlots: true },
/**
*
*/
properties: {},
lifetimes: {
attached() {
// console.log('attached-----');
},
detached() {
clearInterval(this.data.timer);
},
},
pageLifetimes: {
show() {
clearInterval(this.data.timer);
console.log('show-----');
this.setDateMsg();
this.data.timer = setInterval(() => {
this.setDateMsg();
}, 1000);
},
hide() {
console.log('hide-----');
clearInterval(this.data.timer);
},
},
/**
*
*/
data: {
timer: null as any,
date: '',
week: '',
weekArr: ['日', '一', '二', '三', '四', '五', '六'],
},
/**
*
*/
methods: {
setDateMsg() {
console.log('ddd');
this.setData({
date: formatTime(new Date()),
week: `星期${this.data.weekArr[new Date().getDay()]}`,
});
},
},
});