纪念日调整

This commit is contained in:
limqhz
2022-12-01 17:21:12 +08:00
parent 526a7505a7
commit abdcb5661e
37 changed files with 705 additions and 6 deletions

View File

@@ -0,0 +1,41 @@
function setTwo(num){ return num<10 ? ('0'+num) : (''+num); };
export default class CountDown{
constructor(t){
if(t instanceof Array){
this.time =new Date().getTime()+ (new Date(t[1]).getTime() - new Date(t[0]).getTime());
}else{
this.time =/\//gi.test(t.toString()) ? (new Date(t).getTime()) : ( new Date().getTime()+parseInt(t));
}
}
timeOut (fn,t) {
let _now = new Date().getTime(),
json={},
count = Math.round((this.time - _now)/1000);
if(count <= 0) {
json = {day :'00',hour :'00',min :'00',sec :'00',ms :'00'}
fn.call(this, json)
this.endFn && this.endFn.call(this, json)
return;
};
json = {
day : setTwo(Math.floor(count/86400)), //天数
hour : setTwo(Math.floor(count/ (60 * 60) % 24 )), //小时
min : setTwo(Math.floor(count/60 % 60)), //分钟
sec : setTwo(Math.floor(count%60)), //秒
ms : setTwo((this.time - _now)%1000).substr(0,2) //豪秒
};
let _end = new Date().getTime();
let _diff = _now - _end; //误差
fn.call(this, json);
setTimeout(function(that){
that.timeOut(fn,t)
}, t ? (t) : 1000 - _diff,this)
}
end(fn){
this.endFn = fn;
}
run(fn,t){
this.timeOut(fn,t);
return this
}
};

View File

@@ -0,0 +1,69 @@
import CountDown from './countdown.js';
Component({
properties: {
showDay : {
type: null,
value: 0 ,
observer(val) {
this.setData({
dayOff : typeof val === 'string' ? JSON.parse(val) : val
});
}
},
format : {
type: null,
value: ''
},
showHour : {
type: null,
value: 1 ,
observer(val) {
this.setData({
hourOff :typeof val === 'string' ? JSON.parse(val) : val
});
}
},
showMin : {
type: null,
value: 1 ,
observer(val) {
this.setData({
minOff :typeof val === 'string' ? JSON.parse(val) : val
});
}
},
showSec : {
type: null,
value: 1 ,
observer(val) {
this.setData({
secOff :typeof val === 'string' ? JSON.parse(val) : val
});
}
},
index : {
type: null,
value: 0
},
time: {
type: null,
value: 0
}
},
data: {
dayOff : 0,
hourOff :1,
minOff :1,
secOff :1,
countTime: ''
},
attached(){
new CountDown(this.data.time).run(t=>{
this.setData({
countTime : t
});
}).end(()=>{
this.triggerEvent('end',{index : this.data.index})
});
}
})

View File

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

View File

@@ -0,0 +1,7 @@
<!--index.wxml-->
<view class="countDownView">
<view wx:if="{{dayOff}}"><text>{{countTime.day}}</text>{{format ? format : '天'}}</view>
<view wx:if="{{hourOff}}"><text>{{countTime.hour}}</text>{{format ? format : '时'}}</view>
<view wx:if="{{minOff}}"><text>{{countTime.min}}</text>{{format ? format : '分'}}</view>
<view wx:if="{{secOff}}"><text>{{countTime.sec}}</text>{{format ? '' : '秒'}}</view>
</view>

View File

@@ -0,0 +1,13 @@
.countDownView {
display: inline-block;
line-height: 1
}
.countDownView text {
padding: 0 3px;
margin: 0 2px;
}
.countDownView view {
display: inline-block;
}

View File

@@ -0,0 +1,57 @@
---
title: Divider 分割符
description: 用于分割、组织、细化有一定逻辑的组织元素内容和页面结构。
spline: message
isComponent: true
---
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-100%25-blue" /></span>
## 引入
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
```json
"usingComponents": {
"t-divider": "tdesign-miniprogram/divider/divider"
}
```
### 主题定制
CSS 变量名|说明
--|--
--td-divider-color | 分割线颜色
--td-divider-content-color | 分割线文本颜色
## 代码演示
### 基础分割符
分割符主要是由直线和文字组成,通过`slot`传入分割线文案或者其他自定义内容,通过`layout`控制分隔符是垂直还是横向,`line-color`属性可定义线条颜色
<img src="https://tdesign.gtimg.com/miniprogram/readme/divider.png" width="375px" height="50%">
{{ base }}
### 文字 + 直线
{{ text-line }}
### 纯文字 + 分割
{{ text-only }}
## API
### Divider Props
| 名称 | 类型 | 默认值 | 说明 | 必传 |
| ---------------- | ------------- | ---------- | ---------------------------------------------------------------------------------------------------- | ---- |
| align | String | center | 文本位置仅在水平分割线有效。可选项left/right/center | N |
| content | String / Slot | - | 子元素 | N |
| dashed | Boolean | false | 是否虚线(仅在水平分割线有效) | N |
| external-classes | Array | - | 组件类名,分别用于设置 组件外层类名、分隔线类名 等。`['t-class', 't-class-line', 't-class-content']` | N |
| layout | String | horizontal | 分隔线类型有两种水平和垂直。可选项horizontal/vertical | N |
| line-color | String | - | 分隔线颜色 | N |
| theme | String | horizontal | 已废弃。请更为使用 `layout`。分隔线类型有两种水平和垂直。可选项horizontal/vertical | N |

13
components/divider/divider.d.ts vendored Normal file
View File

@@ -0,0 +1,13 @@
import { SuperComponent } from '../common/src/index';
export default class Divider extends SuperComponent {
externalClasses: string[];
options: {
addGlobalClass: boolean;
multipleSlots: boolean;
};
properties: import("./type").TdDividerProps;
data: {
prefix: string;
classPrefix: string;
};
}

View File

@@ -0,0 +1,30 @@
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { SuperComponent, wxComponent } from '../common/src/index';
import config from '../common/config';
import props from './props';
const { prefix } = config;
const name = `${prefix}-divider`;
let Divider = class Divider extends SuperComponent {
constructor() {
super(...arguments);
this.externalClasses = ['t-class', 't-class-content'];
this.options = {
addGlobalClass: true,
multipleSlots: true,
};
this.properties = props;
this.data = {
prefix,
classPrefix: name,
};
}
};
Divider = __decorate([
wxComponent()
], Divider);
export default Divider;

View File

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

View File

@@ -0,0 +1,11 @@
<view class="{{layout==='vertical'? classPrefix + '--vertical-center' : ''}}">
<view
class="{{prefix}}-class {{classPrefix}} {{classPrefix}}--{{layout}} {{classPrefix}}--{{align}} {{dashed? classPrefix + '--dashed' : ''}} "
style="{{ lineColor ? 'border-color: ' + lineColor + ';' : '' }}"
>
<view class="{{prefix}}-class-content {{classPrefix}}__content">
<view wx:if="{{content}}"> {{content}} </view>
<slot wx:else name="content" />
</view>
</view>
</view>

View File

@@ -0,0 +1,100 @@
.t-float-left {
float: left;
}
.t-float-right {
float: right;
}
@keyframes tdesign-fade-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.hotspot-expanded.relative {
position: relative;
}
.hotspot-expanded::after {
content: '';
display: block;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
transform: scale(1.5);
}
page {
--td-divider-color: #e7e7e7;
--td-divider-content-color: rgba(0, 0, 0, 0.4);
}
.t-divider--horizontal {
display: flex;
align-items: center;
color: var(--td-divider-color);
border-color: var(--td-divider-color);
border-style: solid;
border-width: 0;
margin-top: 20rpx;
margin-bottom: 20rpx;
}
.t-divider--horizontal::before,
.t-divider--horizontal::after {
display: block;
flex: 1;
box-sizing: border-box;
border-color: inherit;
border-style: inherit;
border-width: 1rpx 0 0;
}
.t-divider--horizontal::before {
content: '';
}
.t-divider--horizontal .t-divider__content:not(:empty) {
margin: 0 24rpx;
}
.t-divider--vertical {
display: flex;
flex-direction: column;
height: 1em;
margin: 0 16rpx;
color: var(--td-divider-color);
border-color: var(--td-divider-color);
border-style: solid;
border-width: 0;
}
.t-divider--vertical::before,
.t-divider--vertical::after {
content: '';
display: block;
flex: 1;
box-sizing: border-box;
border-color: inherit;
border-style: inherit;
border-width: 0 1rpx 0 0;
}
.t-divider--vertical-center {
display: flex;
align-items: center;
height: 100%;
}
.t-divider--dashed {
border-style: dashed;
}
.t-divider__content {
font-size: 24rpx;
line-height: 40rpx;
color: var(--td-divider-content-color);
}
.t-divider--center::after,
.t-divider--left::after,
.t-divider--right::after {
content: '';
}
.t-divider--left::before {
max-width: 60rpx;
}
.t-divider--right::after {
max-width: 60rpx;
}

3
components/divider/props.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
import { TdDividerProps } from './type';
declare const props: TdDividerProps;
export default props;

View File

@@ -0,0 +1,29 @@
const props = {
align: {
type: String,
value: 'center',
},
content: {
type: String,
},
dashed: {
type: Boolean,
value: false,
},
externalClasses: {
type: Array,
},
layout: {
type: String,
value: 'horizontal',
},
lineColor: {
type: String,
value: '',
},
theme: {
type: String,
value: 'horizontal',
},
};
export default props;

37
components/divider/type.d.ts vendored Normal file
View File

@@ -0,0 +1,37 @@
export interface TdDividerProps {
align?: {
type: StringConstructor;
value?: 'left' | 'right' | 'center';
required?: boolean;
};
content?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
dashed?: {
type: BooleanConstructor;
value?: boolean;
required?: boolean;
};
externalClasses?: {
type: ArrayConstructor;
value?: ['t-class', 't-class-line', 't-class-content'];
required?: boolean;
};
layout?: {
type: StringConstructor;
value?: 'horizontal' | 'vertical';
required?: boolean;
};
lineColor?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
theme?: {
type: StringConstructor;
value?: 'horizontal' | 'vertical';
required?: boolean;
};
}

View File

@@ -0,0 +1,2 @@
;
export {};

View File

@@ -0,0 +1,47 @@
---
title: Empty 空内容
description: 用于空状态时的占位提示。
spline: data
isComponent: true
---
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-100%25-blue" /></span>
## 引入
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
```json
"usingComponents": {
"t-empty": "tdesign-miniprogram/empty/empty"
}
```
## 代码演示
### 图标空状态
{{ base }}
### 自定义图片空状态
{{ imageEmpty }}
### 带操作空状态
{{ buttonEmpty }}
### 空页面
{{ pageEmpty }}
## API
### Empty Props
| 名称 | 类型 | 默认值 | 说明 | 必传 |
| ---------------- | ------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------- | ---- |
| action | Slot | - | 操作按钮 | N |
| description | String / Slot | - | 描述文字 | N |
| external-classes | Array | - | 组件类名,分别用于设置 组件外层类名、文本描述类名、图片类名、操作按钮类名。`['t-class', 't-class-description', 't-class-image', 't-class-actions']` | N |
| icon | String | - | 图标名称 | N |
| image | String / Slot | - | 图片地址 | N |

11
components/empty/empty.d.ts vendored Normal file
View File

@@ -0,0 +1,11 @@
import { SuperComponent } from '../common/src/index';
export default class extends SuperComponent {
options: {
multipleSlots: boolean;
};
externalClasses: string[];
properties: import("./type").TdEmptyProps;
data: {
classPrefix: string;
};
}

28
components/empty/empty.js Normal file
View File

@@ -0,0 +1,28 @@
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { SuperComponent, wxComponent } from '../common/src/index';
import props from './props';
import config from '../common/config';
const { prefix } = config;
const name = `${prefix}-empty`;
let default_1 = class extends SuperComponent {
constructor() {
super(...arguments);
this.options = {
multipleSlots: true,
};
this.externalClasses = ['t-class', 't-class-description', 't-class-image'];
this.properties = props;
this.data = {
classPrefix: name,
};
}
};
default_1 = __decorate([
wxComponent()
], default_1);
export default default_1;

View File

@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"t-icon": "../icon/icon"
}
}

View File

@@ -0,0 +1,21 @@
<wxs src="./empty.wxs" module="utils" />
<view class="t-class {{classPrefix}}">
<view class="{{classPrefix}}__content">
<image
wx:if="{{image}}"
class="{{classPrefix}}__img t-class-image"
src="{{image}}"
mode="aspectFit"
/>
<t-icon wx:elif="{{icon}}" size="192rpx" name="{{icon}}" color="rgba(0, 0, 0, .26)" />
<slot wx:else name="image" class="{{classPrefix}}__img t-class-image" />
<view wx:if="{{description}}" class="{{classPrefix}}__description t-class-description"
>{{description}}</view
>
<slot wx:else name="description" class="{{classPrefix}}__description t-class-description}" />
<view class="{{classPrefix}}__actions t-class-actions">
<slot name="action" />
</view>
</view>
</view>

View File

@@ -0,0 +1,12 @@
var REGEXP = getRegExp('^\d+(\.\d+)?$');
function addUnit(value) {
if (value == null) {
return undefined;
}
return REGEXP.test('' + value) ? value + 'px' : value;
}
module.exports = {
addUnit: addUnit,
};

View File

@@ -0,0 +1,48 @@
.t-float-left {
float: left;
}
.t-float-right {
float: right;
}
@keyframes tdesign-fade-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.hotspot-expanded.relative {
position: relative;
}
.hotspot-expanded::after {
content: '';
display: block;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
transform: scale(1.5);
}
.t-empty {
display: flex;
flex-direction: column;
}
.t-empty__content {
text-align: center;
}
.t-empty__img {
width: 100rpx;
height: 100rpx;
}
.t-empty__description {
margin-top: 48rpx;
text-align: center;
color: rgba(0, 0, 0, 0.4);
font-size: 28rpx;
line-height: 44rpx;
}
.t-empty__description + .t-empty__actions:not(:empty) {
margin-top: 48rpx;
}

3
components/empty/props.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
import { TdEmptyProps } from './type';
declare const props: TdEmptyProps;
export default props;

16
components/empty/props.js Normal file
View File

@@ -0,0 +1,16 @@
const props = {
description: {
type: String,
},
externalClasses: {
type: Array,
},
icon: {
type: String,
value: '',
},
image: {
type: String,
},
};
export default props;

22
components/empty/type.d.ts vendored Normal file
View File

@@ -0,0 +1,22 @@
export interface TdEmptyProps {
description?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
externalClasses?: {
type: ArrayConstructor;
value?: ['t-class', 't-class-description', 't-class-image', 't-class-actions'];
required?: boolean;
};
icon?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
image?: {
type: StringConstructor;
value?: string;
required?: boolean;
};
}

2
components/empty/type.js Normal file
View File

@@ -0,0 +1,2 @@
;
export {};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

BIN
images/baby.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
images/birthday.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
images/life.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
images/love.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

View File

@@ -1,8 +1,15 @@
Page({
data: {
aIconList: ['check-rectangle','star-filled','notification','circle'],
},
onLoad: function (options) {
dataEmpty: false,
anniversaryList: [
{'title':'老公的工作纪念日','type':'life','dateType':'农历','date':'2018/12/30','repeat':'3','nextDate':'2022/12/30'},
{'title':'结婚纪念日','type':'love','dateType':'公历','date':'2017/12/30','repeat':'4','nextDate':'2022/12/30'},
{'title':'真正的操作的纪念日','type':'life','dateType':'公历','date':'2017/12/30','repeat':'4','nextDate':'2022/12/30'},
{'title':'宝宝出生日期','type':'baby','dateType':'公历','date':'2017/12/30','repeat':'4','nextDate':'2022/12/30'},
{'title':'王xx的生日','type':'birthday','dateType':'公历','date':'2017/12/30','repeat':'4','nextDate':'2022/12/30'},
{'title':'天才的生日','type':'birthday','dateType':'公历','date':'2017/12/30','repeat':'4','nextDate':'2022/12/30'},
{'title':'大家爱送到家我i的生日','type':'birthday','dateType':'公历','date':'2017/12/30','repeat':'4','nextDate':'2022/12/30'},
],
}
});

View File

@@ -1,5 +1,10 @@
{
"usingComponents": {
"foot-tab": "../foot-tab/foot-tab"
"foot-tab": "../foot-tab/foot-tab",
"t-empty": "/components/empty/empty",
"t-fab": "/components/fab/fab",
"t-badge": "/components/badge/badge",
"t-countdown": "/components/countdown/index",
"t-divider": "/components/divider/divider"
}
}

View File

@@ -1,5 +1,27 @@
<!--pages/message/index.wxml-->
<text>纪念日</text>
<view class="contentView">
<view wx:for="{{anniversaryList}}" wx:key="index" class="anniversary">
<image wx:if="{{ item.type == 'birthday' }}" src="/images/birthday.jpg"/>
<image wx:elif="{{ item.type == 'love' }}" src="/images/love.png"/>
<image wx:elif="{{ item.type == 'baby' }}" src="/images/baby.png"/>
<image wx:else src="/images/life.jpg"></image>
<view class="title">
{{item.title}}
</view>
<view class="remark">
<view class="countdown">
<text>距离{{item.repeat}}周年</text>
<t-countdown time="{{item.nextDate}}" showDay="{{true}}" />
</view>
<view class="countdown">
<text>今天{{item.repeat}}周年啦!</text>
</view>
</view>
<t-divider content="✿✿✿---■Quinn■---✿✿✿" />
</view>
</view>
<t-empty wx:if="{{dataEmpty}}" t-class="empty-cls" icon="info-circle-filled" description="暂无纪念日" />
<t-fab icon="add" bind:click="handleClick"></t-fab>
<view>
<foot-tab iconList="{{aIconList}}"/>
</view>

View File

@@ -0,0 +1,27 @@
.empty-cls {
margin-top: 250rpx !important;
}
.contentView{
padding-bottom: 50px;
}
.anniversary{
height: 300rpx;
margin: 10rpx 20rpx;
border: 5px ridge #f0a1a8;
border-radius: 5px;
}
image{
width: 100%;
height: 120rpx;
}
.title {
padding-left: 10rpx;
font-size: 38rpx;
}
.remark {
padding-left: 10rpx;
margin-top: 5rpx;
font-size: 28rpx;
line-height: 28rpx;
color: #999999;
}

View File

@@ -51,6 +51,8 @@ Page({
taskList: [],
over: false
};
console.log(data)
console.log(data.over)
let listData = this.data.delayList || [];
pageData.requesting = false;
if (type === 'refresh') {

View File

@@ -228,7 +228,7 @@ export default {
*/
taskList(params) {
return new Promise(x => {
let job = {data:'test'};
let job = {data:{over:true}};
x(job)
console.log(x + '请求成功');
wx.hideLoading();