添加组件等
This commit is contained in:
4
miniprogram/pages/components/date-now/date-now.json
Normal file
4
miniprogram/pages/components/date-now/date-now.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
55
miniprogram/pages/components/date-now/date-now.ts
Normal file
55
miniprogram/pages/components/date-now/date-now.ts
Normal 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()]}`,
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
3
miniprogram/pages/components/date-now/date-now.wxml
Normal file
3
miniprogram/pages/components/date-now/date-now.wxml
Normal file
@@ -0,0 +1,3 @@
|
||||
<view class="time-box">
|
||||
<view>{{date}} {{week}}</view>
|
||||
</view>
|
||||
5
miniprogram/pages/components/date-now/date-now.wxss
Normal file
5
miniprogram/pages/components/date-now/date-now.wxss
Normal file
@@ -0,0 +1,5 @@
|
||||
.time-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-bottom: 16rpx;
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user