添加组件等

This commit is contained in:
zhengw
2026-03-12 15:16:49 +08:00
parent 76c28f8d78
commit f9425daab6
14 changed files with 193 additions and 27 deletions

View File

@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1,55 @@
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()]}`,
});
},
},
});

View File

@@ -0,0 +1,3 @@
<view class="time-box">
<view>{{date}} {{week}}</view>
</view>

View File

@@ -0,0 +1,5 @@
.time-box {
display: flex;
align-items: center;
padding-bottom: 16rpx;
}

View File

@@ -1,7 +1,6 @@
{
"component": true,
"usingComponents": {
"t-button": "tdesign-miniprogram/button/button",
"t-checkbox": "tdesign-miniprogram/checkbox/checkbox",
"t-link": "tdesign-miniprogram/link/link",
"t-loading": "tdesign-miniprogram/loading/loading",

View File

@@ -1,7 +1,7 @@
import { base, defaultAvatarUrl } from '@/utils/config';
import { login } from '@/utils/https';
import { Subscribe } from '@/utils/subscribe';
import { getCurrentPageRoute, isArray } from '@/utils/util';
import { IIsLogin, Subscribe } from '@/utils/subscribe';
import { getCurrentPageRoute, getStorage, isArray, setStorage } from '@/utils/util';
// import { IStorage } from "@/utils/storage";
// const app = getApp();
@@ -17,18 +17,21 @@ Component({
hasTabBar: null,
},
attached() {
// this.setData({ isLogin: getStorage('isLogin') == 1 });
// console.log('attached');
Subscribe.on('isLogin', getCurrentPageRoute(), (data: any) => {
// console.log(data);
this.setData({ isLogin: data, loading: false });
// console.log('监听到 isLogin 变化:');
});
},
detached() {
// console.log('detached');
Subscribe.off('isLogin', getCurrentPageRoute());
lifetimes: {
attached() {
this.setData({ isLogin: getStorage('isLogin') == 1 });
// console.log('attached');
Subscribe.on<IIsLogin>('isLogin', getCurrentPageRoute(), (data) => {
// console.log(data);
setStorage('isLogin', data ? 1 : 0);
this.setData({ isLogin: data, loading: false });
// console.log('监听到 isLogin 变化:');
});
},
detached() {
// console.log('detached');
Subscribe.off('isLogin', getCurrentPageRoute());
},
},
data: {