Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦想橡皮擦
uni-starter
提交
f9ef3751
U
uni-starter
项目概览
梦想橡皮擦
/
uni-starter
与 Fork 源项目一致
Fork自
DCloud / uni-starter
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-starter
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f9ef3751
编写于
7月 22, 2021
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. 调整使用正则表达式配置强制登陆功能的写法,解决在小程序端的兼容问题。 2. 新增签到功能(培养用户习惯,提升用户粘性)。支持:每日签到奖励、周期性连续7日签到,奖励翻倍。
上级
710a0132
变更
20
展开全部
隐藏空白更改
内联
并排
Showing
20 changed file
with
2053 addition
and
1629 deletion
+2053
-1629
changelog.md
changelog.md
+3
-0
common/appInit.js
common/appInit.js
+5
-5
package.json
package.json
+4
-5
pages/grid/grid.vue
pages/grid/grid.vue
+1
-2
pages/ucenter/ucenter.vue
pages/ucenter/ucenter.vue
+13
-5
static/uni-sign-in/background.png
static/uni-sign-in/background.png
+0
-0
uni-starter.config.js
uni-starter.config.js
+2
-2
uni_modules/uni-calendar/changelog.md
uni_modules/uni-calendar/changelog.md
+4
-2
uni_modules/uni-calendar/components/uni-calendar/calendar.js
uni_modules/uni-calendar/components/uni-calendar/calendar.js
+546
-546
uni_modules/uni-calendar/components/uni-calendar/uni-calendar-item.vue
...ni-calendar/components/uni-calendar/uni-calendar-item.vue
+148
-148
uni_modules/uni-calendar/components/uni-calendar/uni-calendar.vue
...les/uni-calendar/components/uni-calendar/uni-calendar.vue
+491
-491
uni_modules/uni-calendar/components/uni-calendar/util.js
uni_modules/uni-calendar/components/uni-calendar/util.js
+343
-343
uni_modules/uni-calendar/package.json
uni_modules/uni-calendar/package.json
+83
-80
uni_modules/uni-calendar/readme.md
uni_modules/uni-calendar/readme.md
+7
-0
uni_modules/uni-sign-in/changelog.md
uni_modules/uni-sign-in/changelog.md
+0
-0
uni_modules/uni-sign-in/components/uni-sign-in/uni-sign-in.vue
...odules/uni-sign-in/components/uni-sign-in/uni-sign-in.vue
+220
-0
uni_modules/uni-sign-in/package.json
uni_modules/uni-sign-in/package.json
+76
-0
uni_modules/uni-sign-in/readme.md
uni_modules/uni-sign-in/readme.md
+1
-0
uni_modules/uni-sign-in/uniCloud/cloudfunctions/uni-clientDB-actions/signIn.js
...in/uniCloud/cloudfunctions/uni-clientDB-actions/signIn.js
+65
-0
uni_modules/uni-sign-in/uniCloud/database/opendb-sign-in.schema.json
.../uni-sign-in/uniCloud/database/opendb-sign-in.schema.json
+41
-0
未找到文件。
changelog.md
浏览文件 @
f9ef3751
## 1.0.40(2021-07-22)
1.
调整使用正则表达式配置强制登陆功能的写法,解决在小程序端的兼容问题。
2.
新增签到功能(培养用户习惯,提升用户粘性)。支持:每日签到奖励、周期性连续7日签到,奖励翻倍。
## 1.0.39(2021-07-19)
1.
强制登陆配置,新增白名单模式
2.
强制登陆配置,支持正则表达式
...
...
common/appInit.js
浏览文件 @
f9ef3751
...
...
@@ -337,9 +337,9 @@ export default async function() {
let
pass
=
true
//pattern
if
(
needLogin
)
{
pass
=
needLogin
.
every
((
item
)
=>
{
if
(
item
.
slice
(
0
,
8
)
==
'
pattern:
'
)
{
return
!
eval
(
item
.
slice
(
8
,
item
.
length
)).
test
(
url
)
pass
=
needLogin
.
every
((
item
)
=>
{
if
(
typeof
(
item
)
==
'
object
'
&&
item
.
pattern
){
return
!
item
.
pattern
.
test
(
url
)
}
return
url
!=
item
})
...
...
@@ -347,8 +347,8 @@ export default async function() {
}
if
(
visitor
&&!
inLoginPage
)
{
pass
=
visitor
.
some
((
item
)
=>
{
if
(
item
.
slice
(
0
,
8
)
==
'
pattern:
'
)
{
return
eval
(
item
.
slice
(
8
,
item
.
length
))
.
test
(
url
)
if
(
typeof
(
item
)
==
'
object
'
&&
item
.
pattern
)
{
return
item
.
pattern
.
test
(
url
)
}
return
url
==
item
})
...
...
package.json
浏览文件 @
f9ef3751
{
"id"
:
"uni-starter"
,
"displayName"
:
"uni-starter"
,
"version"
:
"1.0.
39
"
,
"version"
:
"1.0.
40
"
,
"description"
:
"云端一体应用快速开发基本项目模版"
,
"keywords"
:
[
"uni-starter"
,
"login"
,
"登录
模版
"
,
"
uniCloud
"
,
"
搜索
"
"登录"
,
"
搜索
"
,
"
uni-id例子
"
],
"repository"
:
"https://codechina.csdn.net/dcloud/uni-starter.git"
,
"engines"
:
{
...
...
pages/grid/grid.vue
浏览文件 @
f9ef3751
...
...
@@ -23,7 +23,7 @@
<uni-grid
:column=
"3"
:highlight=
"true"
@
change=
"change"
>
<template
v-for=
"(item,i) in gridList"
>
<uni-grid-item
:index=
"i"
:key=
"i"
v-if=
"i
<
3
||
i
>
3
&&
i
<
7&&
hasLogin
||
i
>
7
&&
uniIDHasRole('admin')"
v-if=
"i
<
3
||
i
>
2
&&
i
<
6&&
hasLogin
||
i
>
5
&&
uniIDHasRole('admin')"
>
<view
class=
"grid-item-box"
style=
"background-color: #fff;"
>
<image
:src=
"'/static/grid/c'+(i+1)+'.png'"
class=
"image"
mode=
"aspectFill"
/>
...
...
@@ -31,7 +31,6 @@
</view>
</uni-grid-item>
</
template
>
</uni-grid>
</view>
</view>
...
...
pages/ucenter/ucenter.vue
浏览文件 @
f9ef3751
<
template
>
<view
class=
"center"
>
<uni-sign-in
ref=
"signIn"
></uni-sign-in>
<view
class=
"userInfo"
@
click.capture=
"toUserInfo"
>
<uni-file-picker
v-if=
"userInfo.avatar_file"
v-model=
"userInfo.avatar_file"
fileMediatype=
"image"
:del-icon=
"false"
return-type=
"object"
:image-styles=
"listStyles"
disablePreview
...
...
@@ -59,7 +60,12 @@
}
],
ucenterList
:
[
[
[
{
"
title
"
:
'
签到有奖
'
,
"
event
"
:
'
signIn
'
,
"
icon
"
:
"
compose
"
},
// #ifdef APP-PLUS
{
"
title
"
:
'
去评分
'
,
...
...
@@ -148,6 +154,9 @@
uni
.
navigateTo
({
url
:
"
/pages/ucenter/settings/settings
"
})
},
signIn
(){
//签到
this
.
$refs
.
signIn
.
open
()
},
/**
* 个人中心项目列表点击事件
...
...
@@ -211,17 +220,16 @@
uni
.
showLoading
({
mask
:
true
})
db
.
collection
(
"
uni-id-scores
"
).
where
(
'
user_id == $env.uid
'
).
field
(
'
score,balance
'
).
get
().
then
((
res
)
=>
{
db
.
collection
(
"
uni-id-scores
"
).
where
(
'
"user_id" == $env.uid
'
).
field
(
'
score,balance
'
).
get
().
then
((
res
)
=>
{
uni
.
hideLoading
()
console
.
log
(
res
);
const
data
=
res
.
result
.
data
[
0
];
let
msg
=
''
;
msg
=
data
?
(
'
当前积分为
'
+
data
.
balanc
e
)
:
'
当前无积分
'
;
msg
=
data
?
(
'
当前积分为
'
+
data
.
scor
e
)
:
'
当前无积分
'
;
uni
.
showToast
({
title
:
msg
,
icon
:
'
none
'
});
}).
finally
(()
=>
{
uni
.
hideLoading
()
})
},
async
share
()
{
...
...
static/uni-sign-in/background.png
0 → 100644
浏览文件 @
f9ef3751
91.3 KB
uni-starter.config.js
浏览文件 @
f9ef3751
...
...
@@ -29,13 +29,13 @@ module.exports = {
* 注意:黑名单与白名单模式二选一
*/
// "needLogin" : [
//
"pattern:/^\\/pages\\/userinfo.*/
", //支持正则表达式
//
{pattern:/^\/pages\/list.*/}
", //支持正则表达式
// "/uni_modules/uni-news-favorite/pages/uni-news-favorite/list",
// "/uni_modules/uni-feedback/pages/uni-feedback/add"
// ],
"
visitor
"
:
[
"
/
"
,
//注意入口页必须直接写 "/"
"
pattern:/^
\\
/pages
\\
/list.*/
"
,
//支持正则表达式
{
"
pattern
"
:
/^
\
/
pages
\
/
list
.
*
/}
, /
/
支持正则表达式
"
/pages/grid/grid
"
,
"
/pages/ucenter/ucenter
"
,
"
/pages/ucenter/about/about
"
,
...
...
uni_modules/uni-calendar/changelog.md
浏览文件 @
f9ef3751
## 1.3.15(2021-02-04)
-
调整为uni_modules目录规范
## 1.3.16(2021-05-12)
-
新增 组件示例地址
## 1.3.15(2021-02-04)
-
调整为uni_modules目录规范
uni_modules/uni-calendar/components/uni-calendar/calendar.js
浏览文件 @
f9ef3751
此差异已折叠。
点击以展开。
uni_modules/uni-calendar/components/uni-calendar/uni-calendar-item.vue
浏览文件 @
f9ef3751
<
template
>
<view
class=
"uni-calendar-item__weeks-box"
:class=
"
{
'uni-calendar-item--disable':weeks.disable,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate
&&
weeks.isDay,
<
template
>
<view
class=
"uni-calendar-item__weeks-box"
:class=
"
{
'uni-calendar-item--disable':weeks.disable,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate
&&
weeks.isDay,
'uni-calendar-item--checked':(calendar.fullDate === weeks.fullDate
&&
!weeks.isDay) ,
'uni-calendar-item--before-checked':weeks.beforeMultiple,
'uni-calendar-item--before-checked':weeks.beforeMultiple,
'uni-calendar-item--multiple': weeks.multiple,
'uni-calendar-item--after-checked':weeks.afterMultiple,
}"
'uni-calendar-item--after-checked':weeks.afterMultiple,
}"
@click="choiceDate(weeks)">
<view
class=
"uni-calendar-item__weeks-box-item"
>
<text
v-if=
"selected&&weeks.extraInfo"
class=
"uni-calendar-item__weeks-box-circle"
></text>
<text
class=
"uni-calendar-item__weeks-box-text"
:class=
"
{
'uni-calendar-item--isDay-text': weeks.isDay,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate
&&
weeks.isDay,
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate
&&
!weeks.isDay,
<text
v-if=
"selected&&weeks.extraInfo"
class=
"uni-calendar-item__weeks-box-circle"
></text>
<text
class=
"uni-calendar-item__weeks-box-text"
:class=
"
{
'uni-calendar-item--isDay-text': weeks.isDay,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate
&&
weeks.isDay,
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate
&&
!weeks.isDay,
'uni-calendar-item--before-checked':weeks.beforeMultiple,
'uni-calendar-item--multiple': weeks.multiple,
'uni-calendar-item--after-checked':weeks.afterMultiple,
'uni-calendar-item--disable':weeks.disable,
}">
{{
weeks
.
date
}}
</text>
<text
v-if=
"!lunar&&!weeks.extraInfo && weeks.isDay"
class=
"uni-calendar-item__weeks-lunar-text"
:class=
"
{
'uni-calendar-item--isDay-text':weeks.isDay,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate
&&
weeks.isDay,
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate
&&
!weeks.isDay,
'uni-calendar-item--after-checked':weeks.afterMultiple,
'uni-calendar-item--disable':weeks.disable,
}">
{{
weeks
.
date
}}
</text>
<text
v-if=
"!lunar&&!weeks.extraInfo && weeks.isDay"
class=
"uni-calendar-item__weeks-lunar-text"
:class=
"
{
'uni-calendar-item--isDay-text':weeks.isDay,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate
&&
weeks.isDay,
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate
&&
!weeks.isDay,
'uni-calendar-item--before-checked':weeks.beforeMultiple,
'uni-calendar-item--multiple': weeks.multiple,
'uni-calendar-item--after-checked':weeks.afterMultiple,
}">今天
</text>
<text
v-if=
"lunar&&!weeks.extraInfo"
class=
"uni-calendar-item__weeks-lunar-text"
:class=
"
{
'uni-calendar-item--isDay-text':weeks.isDay,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate
&&
weeks.isDay,
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate
&&
!weeks.isDay,
'uni-calendar-item--after-checked':weeks.afterMultiple,
}">今天
</text>
<text
v-if=
"lunar&&!weeks.extraInfo"
class=
"uni-calendar-item__weeks-lunar-text"
:class=
"
{
'uni-calendar-item--isDay-text':weeks.isDay,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate
&&
weeks.isDay,
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate
&&
!weeks.isDay,
'uni-calendar-item--before-checked':weeks.beforeMultiple,
'uni-calendar-item--multiple': weeks.multiple,
'uni-calendar-item--after-checked':weeks.afterMultiple,
'uni-calendar-item--disable':weeks.disable,
}">
{{
weeks
.
isDay
?
'
今天
'
:
(
weeks
.
lunar
.
IDayCn
===
'
初一
'
?
weeks
.
lunar
.
IMonthCn
:
weeks
.
lunar
.
IDayCn
)
}}
</text>
<text
v-if=
"weeks.extraInfo&&weeks.extraInfo.info"
class=
"uni-calendar-item__weeks-lunar-text"
:class=
"
{
'uni-calendar-item--extra':weeks.extraInfo.info,
'uni-calendar-item--isDay-text':weeks.isDay,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate
&&
weeks.isDay,
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate
&&
!weeks.isDay,
'uni-calendar-item--after-checked':weeks.afterMultiple,
'uni-calendar-item--disable':weeks.disable,
}">
{{
weeks
.
isDay
?
'
今天
'
:
(
weeks
.
lunar
.
IDayCn
===
'
初一
'
?
weeks
.
lunar
.
IMonthCn
:
weeks
.
lunar
.
IDayCn
)
}}
</text>
<text
v-if=
"weeks.extraInfo&&weeks.extraInfo.info"
class=
"uni-calendar-item__weeks-lunar-text"
:class=
"
{
'uni-calendar-item--extra':weeks.extraInfo.info,
'uni-calendar-item--isDay-text':weeks.isDay,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate
&&
weeks.isDay,
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate
&&
!weeks.isDay,
'uni-calendar-item--before-checked':weeks.beforeMultiple,
'uni-calendar-item--multiple': weeks.multiple,
'uni-calendar-item--after-checked':weeks.afterMultiple,
'uni-calendar-item--disable':weeks.disable,
}">
{{
weeks
.
extraInfo
.
info
}}
</text>
</view>
</view>
</
template
>
<
script
>
export
default
{
props
:
{
weeks
:
{
type
:
Object
,
default
()
{
return
{}
}
},
calendar
:
{
type
:
Object
,
default
:
()
=>
{
return
{}
}
},
selected
:
{
type
:
Array
,
default
:
()
=>
{
return
[]
}
},
lunar
:
{
type
:
Boolean
,
default
:
false
}
},
methods
:
{
'uni-calendar-item--after-checked':weeks.afterMultiple,
'uni-calendar-item--disable':weeks.disable,
}">
{{
weeks
.
extraInfo
.
info
}}
</text>
</view>
</view>
</
template
>
<
script
>
export
default
{
props
:
{
weeks
:
{
type
:
Object
,
default
()
{
return
{}
}
},
calendar
:
{
type
:
Object
,
default
:
()
=>
{
return
{}
}
},
selected
:
{
type
:
Array
,
default
:
()
=>
{
return
[]
}
},
lunar
:
{
type
:
Boolean
,
default
:
false
}
},
methods
:
{
choiceDate
(
weeks
)
{
this
.
$emit
(
'
change
'
,
weeks
)
}
}
}
</
script
>
<
style
lang=
"scss"
scoped
>
.uni-calendar-item__weeks-box
{
flex
:
1
;
/* #ifndef APP-NVUE */
display
:
flex
;
/* #endif */
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
}
.uni-calendar-item__weeks-box-text
{
font-size
:
$uni-font-size-base
;
color
:
$uni-text-color
;
}
.uni-calendar-item__weeks-lunar-text
{
font-size
:
$uni-font-size-sm
;
color
:
$uni-text-color
;
}
.uni-calendar-item__weeks-box-item
{
position
:
relative
;
/* #ifndef APP-NVUE */
display
:
flex
;
/* #endif */
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
width
:
100rpx
;
height
:
100rpx
;
}
.uni-calendar-item__weeks-box-circle
{
position
:
absolute
;
top
:
5px
;
right
:
5px
;
width
:
8px
;
height
:
8px
;
border-radius
:
8px
;
background-color
:
$uni-color-error
;
}
.uni-calendar-item--disable
{
background-color
:
rgba
(
249
,
249
,
249
,
$uni-opacity-disabled
);
color
:
$uni-text-color-disable
;
}
.uni-calendar-item--isDay-text
{
color
:
$uni-color-primary
;
}
.uni-calendar-item--isDay
{
background-color
:
$uni-color-primary
;
opacity
:
0
.8
;
color
:
#fff
;
}
.uni-calendar-item--extra
{
color
:
$uni-color-error
;
opacity
:
0
.8
;
}
.uni-calendar-item--checked
{
background-color
:
$uni-color-primary
;
color
:
#fff
;
opacity
:
0
.8
;
}
.uni-calendar-item--multiple
{
background-color
:
$uni-color-primary
;
color
:
#fff
;
opacity
:
0
.8
;
this
.
$emit
(
'
change
'
,
weeks
)
}
}
}
</
script
>
<
style
lang=
"scss"
scoped
>
.uni-calendar-item__weeks-box
{
flex
:
1
;
/* #ifndef APP-NVUE */
display
:
flex
;
/* #endif */
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
}
.uni-calendar-item__weeks-box-text
{
font-size
:
$uni-font-size-base
;
color
:
$uni-text-color
;
}
.uni-calendar-item__weeks-lunar-text
{
font-size
:
$uni-font-size-sm
;
color
:
$uni-text-color
;
}
.uni-calendar-item__weeks-box-item
{
position
:
relative
;
/* #ifndef APP-NVUE */
display
:
flex
;
/* #endif */
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
width
:
100rpx
;
height
:
100rpx
;
}
.uni-calendar-item__weeks-box-circle
{
position
:
absolute
;
top
:
5px
;
right
:
5px
;
width
:
8px
;
height
:
8px
;
border-radius
:
8px
;
background-color
:
$uni-color-error
;
}
.uni-calendar-item--disable
{
background-color
:
rgba
(
249
,
249
,
249
,
$uni-opacity-disabled
);
color
:
$uni-text-color-disable
;
}
.uni-calendar-item--isDay-text
{
color
:
$uni-color-primary
;
}
.uni-calendar-item--isDay
{
background-color
:
$uni-color-primary
;
opacity
:
0
.8
;
color
:
#fff
;
}
.uni-calendar-item--extra
{
color
:
$uni-color-error
;
opacity
:
0
.8
;
}
.uni-calendar-item--checked
{
background-color
:
$uni-color-primary
;
color
:
#fff
;
opacity
:
0
.8
;
}
.uni-calendar-item--multiple
{
background-color
:
$uni-color-primary
;
color
:
#fff
;
opacity
:
0
.8
;
}
.uni-calendar-item--before-checked
{
background-color
:
#ff5a5f
;
...
...
@@ -166,5 +166,5 @@
.uni-calendar-item--after-checked
{
background-color
:
#ff5a5f
;
color
:
#fff
;
}
}
</
style
>
uni_modules/uni-calendar/components/uni-calendar/uni-calendar.vue
浏览文件 @
f9ef3751
此差异已折叠。
点击以展开。
uni_modules/uni-calendar/components/uni-calendar/util.js
浏览文件 @
f9ef3751
import
CALENDAR
from
'
./calendar.js
'
class
Calendar
{
constructor
({
date
,
selected
,
startDate
,
endDate
,
range
}
=
{})
{
// 当前日期
this
.
date
=
this
.
getDate
(
new
Date
())
// 当前初入日期
// 打点信息
this
.
selected
=
selected
||
[];
// 范围开始
this
.
startDate
=
startDate
// 范围结束
this
.
endDate
=
endDate
this
.
range
=
range
// 多选状态
this
.
cleanMultipleStatus
()
// 每周日期
this
.
weeks
=
{}
// this._getWeek(this.date.fullDate)
}
/**
* 设置日期
* @param {Object} date
*/
setDate
(
date
)
{
this
.
selectDate
=
this
.
getDate
(
date
)
this
.
_getWeek
(
this
.
selectDate
.
fullDate
)
}
/**
* 清理多选状态
*/
cleanMultipleStatus
()
{
this
.
multipleStatus
=
{
before
:
''
,
after
:
''
,
data
:
[]
}
}
/**
* 重置开始日期
*/
resetSatrtDate
(
startDate
)
{
// 范围开始
this
.
startDate
=
startDate
}
/**
* 重置结束日期
*/
resetEndDate
(
endDate
)
{
// 范围结束
this
.
endDate
=
endDate
}
/**
* 获取任意时间
*/
getDate
(
date
,
AddDayCount
=
0
,
str
=
'
day
'
)
{
if
(
!
date
)
{
date
=
new
Date
()
}
if
(
typeof
date
!==
'
object
'
)
{
date
=
date
.
replace
(
/-/g
,
'
/
'
)
}
const
dd
=
new
Date
(
date
)
switch
(
str
)
{
case
'
day
'
:
dd
.
setDate
(
dd
.
getDate
()
+
AddDayCount
)
// 获取AddDayCount天后的日期
break
case
'
month
'
:
if
(
dd
.
getDate
()
===
31
)
{
dd
.
setDate
(
dd
.
getDate
()
+
AddDayCount
)
}
else
{
dd
.
setMonth
(
dd
.
getMonth
()
+
AddDayCount
)
// 获取AddDayCount天后的日期
}
break
case
'
year
'
:
dd
.
setFullYear
(
dd
.
getFullYear
()
+
AddDayCount
)
// 获取AddDayCount天后的日期
break
}
const
y
=
dd
.
getFullYear
()
const
m
=
dd
.
getMonth
()
+
1
<
10
?
'
0
'
+
(
dd
.
getMonth
()
+
1
)
:
dd
.
getMonth
()
+
1
// 获取当前月份的日期,不足10补0
const
d
=
dd
.
getDate
()
<
10
?
'
0
'
+
dd
.
getDate
()
:
dd
.
getDate
()
// 获取当前几号,不足10补0
return
{
fullDate
:
y
+
'
-
'
+
m
+
'
-
'
+
d
,
year
:
y
,
month
:
m
,
date
:
d
,
day
:
dd
.
getDay
()
}
}
/**
* 获取上月剩余天数
*/
_getLastMonthDays
(
firstDay
,
full
)
{
let
dateArr
=
[]
for
(
let
i
=
firstDay
;
i
>
0
;
i
--
)
{
const
beforeDate
=
new
Date
(
full
.
year
,
full
.
month
-
1
,
-
i
+
1
).
getDate
()
dateArr
.
push
({
date
:
beforeDate
,
month
:
full
.
month
-
1
,
lunar
:
this
.
getlunar
(
full
.
year
,
full
.
month
-
1
,
beforeDate
),
disable
:
true
})
}
return
dateArr
}
/**
* 获取本月天数
*/
_currentMonthDys
(
dateData
,
full
)
{
let
dateArr
=
[]
let
fullDate
=
this
.
date
.
fullDate
for
(
let
i
=
1
;
i
<=
dateData
;
i
++
)
{
let
isinfo
=
false
let
nowDate
=
full
.
year
+
'
-
'
+
(
full
.
month
<
10
?
full
.
month
:
full
.
month
)
+
'
-
'
+
(
i
<
10
?
'
0
'
+
i
:
i
)
// 是否今天
let
isDay
=
fullDate
===
nowDate
// 获取打点信息
let
info
=
this
.
selected
&&
this
.
selected
.
find
((
item
)
=>
{
if
(
this
.
dateEqual
(
nowDate
,
item
.
date
))
{
return
item
}
})
// 日期禁用
let
disableBefore
=
true
let
disableAfter
=
true
if
(
this
.
startDate
)
{
let
dateCompBefore
=
this
.
dateCompare
(
this
.
startDate
,
fullDate
)
disableBefore
=
this
.
dateCompare
(
dateCompBefore
?
this
.
startDate
:
fullDate
,
nowDate
)
import
CALENDAR
from
'
./calendar.js
'
class
Calendar
{
constructor
({
date
,
selected
,
startDate
,
endDate
,
range
}
=
{})
{
// 当前日期
this
.
date
=
this
.
getDate
(
new
Date
())
// 当前初入日期
// 打点信息
this
.
selected
=
selected
||
[];
// 范围开始
this
.
startDate
=
startDate
// 范围结束
this
.
endDate
=
endDate
this
.
range
=
range
// 多选状态
this
.
cleanMultipleStatus
()
// 每周日期
this
.
weeks
=
{}
// this._getWeek(this.date.fullDate)
}
/**
* 设置日期
* @param {Object} date
*/
setDate
(
date
)
{
this
.
selectDate
=
this
.
getDate
(
date
)
this
.
_getWeek
(
this
.
selectDate
.
fullDate
)
}
/**
* 清理多选状态
*/
cleanMultipleStatus
()
{
this
.
multipleStatus
=
{
before
:
''
,
after
:
''
,
data
:
[]
}
}
/**
* 重置开始日期
*/
resetSatrtDate
(
startDate
)
{
// 范围开始
this
.
startDate
=
startDate
}
/**
* 重置结束日期
*/
resetEndDate
(
endDate
)
{
// 范围结束
this
.
endDate
=
endDate
}
/**
* 获取任意时间
*/
getDate
(
date
,
AddDayCount
=
0
,
str
=
'
day
'
)
{
if
(
!
date
)
{
date
=
new
Date
()
}
if
(
typeof
date
!==
'
object
'
)
{
date
=
date
.
replace
(
/-/g
,
'
/
'
)
}
const
dd
=
new
Date
(
date
)
switch
(
str
)
{
case
'
day
'
:
dd
.
setDate
(
dd
.
getDate
()
+
AddDayCount
)
// 获取AddDayCount天后的日期
break
case
'
month
'
:
if
(
dd
.
getDate
()
===
31
)
{
dd
.
setDate
(
dd
.
getDate
()
+
AddDayCount
)
}
else
{
dd
.
setMonth
(
dd
.
getMonth
()
+
AddDayCount
)
// 获取AddDayCount天后的日期
}
break
case
'
year
'
:
dd
.
setFullYear
(
dd
.
getFullYear
()
+
AddDayCount
)
// 获取AddDayCount天后的日期
break
}
const
y
=
dd
.
getFullYear
()
const
m
=
dd
.
getMonth
()
+
1
<
10
?
'
0
'
+
(
dd
.
getMonth
()
+
1
)
:
dd
.
getMonth
()
+
1
// 获取当前月份的日期,不足10补0
const
d
=
dd
.
getDate
()
<
10
?
'
0
'
+
dd
.
getDate
()
:
dd
.
getDate
()
// 获取当前几号,不足10补0
return
{
fullDate
:
y
+
'
-
'
+
m
+
'
-
'
+
d
,
year
:
y
,
month
:
m
,
date
:
d
,
day
:
dd
.
getDay
()
}
}
/**
* 获取上月剩余天数
*/
_getLastMonthDays
(
firstDay
,
full
)
{
let
dateArr
=
[]
for
(
let
i
=
firstDay
;
i
>
0
;
i
--
)
{
const
beforeDate
=
new
Date
(
full
.
year
,
full
.
month
-
1
,
-
i
+
1
).
getDate
()
dateArr
.
push
({
date
:
beforeDate
,
month
:
full
.
month
-
1
,
lunar
:
this
.
getlunar
(
full
.
year
,
full
.
month
-
1
,
beforeDate
),
disable
:
true
})
}
return
dateArr
}
/**
* 获取本月天数
*/
_currentMonthDys
(
dateData
,
full
)
{
let
dateArr
=
[]
let
fullDate
=
this
.
date
.
fullDate
for
(
let
i
=
1
;
i
<=
dateData
;
i
++
)
{
let
isinfo
=
false
let
nowDate
=
full
.
year
+
'
-
'
+
(
full
.
month
<
10
?
full
.
month
:
full
.
month
)
+
'
-
'
+
(
i
<
10
?
'
0
'
+
i
:
i
)
// 是否今天
let
isDay
=
fullDate
===
nowDate
// 获取打点信息
let
info
=
this
.
selected
&&
this
.
selected
.
find
((
item
)
=>
{
if
(
this
.
dateEqual
(
nowDate
,
item
.
date
))
{
return
item
}
})
// 日期禁用
let
disableBefore
=
true
let
disableAfter
=
true
if
(
this
.
startDate
)
{
let
dateCompBefore
=
this
.
dateCompare
(
this
.
startDate
,
fullDate
)
disableBefore
=
this
.
dateCompare
(
dateCompBefore
?
this
.
startDate
:
fullDate
,
nowDate
)
}
if
(
this
.
endDate
)
{
let
dateCompAfter
=
this
.
dateCompare
(
fullDate
,
this
.
endDate
)
disableAfter
=
this
.
dateCompare
(
nowDate
,
dateCompAfter
?
this
.
endDate
:
fullDate
)
}
if
(
this
.
endDate
)
{
let
dateCompAfter
=
this
.
dateCompare
(
fullDate
,
this
.
endDate
)
disableAfter
=
this
.
dateCompare
(
nowDate
,
dateCompAfter
?
this
.
endDate
:
fullDate
)
let
multiples
=
this
.
multipleStatus
.
data
let
checked
=
false
let
multiplesStatus
=
-
1
if
(
this
.
range
)
{
if
(
multiples
)
{
multiplesStatus
=
multiples
.
findIndex
((
item
)
=>
{
return
this
.
dateEqual
(
item
,
nowDate
)
})
}
if
(
multiplesStatus
!==
-
1
)
{
checked
=
true
}
}
let
data
=
{
fullDate
:
nowDate
,
year
:
full
.
year
,
date
:
i
,
multiple
:
this
.
range
?
checked
:
false
,
beforeMultiple
:
this
.
dateEqual
(
this
.
multipleStatus
.
before
,
nowDate
),
afterMultiple
:
this
.
dateEqual
(
this
.
multipleStatus
.
after
,
nowDate
),
month
:
full
.
month
,
lunar
:
this
.
getlunar
(
full
.
year
,
full
.
month
,
i
),
disable
:
!
disableBefore
||
!
disableAfter
,
isDay
}
let
multiples
=
this
.
multipleStatus
.
data
let
checked
=
false
let
multiplesStatus
=
-
1
if
(
this
.
range
)
{
if
(
multiples
)
{
multiplesStatus
=
multiples
.
findIndex
((
item
)
=>
{
return
this
.
dateEqual
(
item
,
nowDate
)
})
}
if
(
multiplesStatus
!==
-
1
)
{
checked
=
true
}
}
let
data
=
{
fullDate
:
nowDate
,
year
:
full
.
year
,
date
:
i
,
multiple
:
this
.
range
?
checked
:
false
,
beforeMultiple
:
this
.
dateEqual
(
this
.
multipleStatus
.
before
,
nowDate
),
afterMultiple
:
this
.
dateEqual
(
this
.
multipleStatus
.
after
,
nowDate
),
month
:
full
.
month
,
lunar
:
this
.
getlunar
(
full
.
year
,
full
.
month
,
i
),
disable
:
!
disableBefore
||
!
disableAfter
,
isDay
}
if
(
info
)
{
data
.
extraInfo
=
info
}
dateArr
.
push
(
data
)
}
return
dateArr
}
/**
* 获取下月天数
*/
_getNextMonthDays
(
surplus
,
full
)
{
let
dateArr
=
[]
for
(
let
i
=
1
;
i
<
surplus
+
1
;
i
++
)
{
dateArr
.
push
({
date
:
i
,
month
:
Number
(
full
.
month
)
+
1
,
lunar
:
this
.
getlunar
(
full
.
year
,
Number
(
full
.
month
)
+
1
,
i
),
disable
:
true
})
}
return
dateArr
}
/**
* 获取当前日期详情
* @param {Object} date
*/
getInfo
(
date
)
{
if
(
!
date
)
{
date
=
new
Date
()
}
const
dateInfo
=
this
.
canlender
.
find
(
item
=>
item
.
fullDate
===
this
.
getDate
(
date
).
fullDate
)
return
dateInfo
}
/**
* 比较时间大小
*/
dateCompare
(
startDate
,
endDate
)
{
// 计算截止时间
startDate
=
new
Date
(
startDate
.
replace
(
'
-
'
,
'
/
'
).
replace
(
'
-
'
,
'
/
'
))
// 计算详细项的截止时间
endDate
=
new
Date
(
endDate
.
replace
(
'
-
'
,
'
/
'
).
replace
(
'
-
'
,
'
/
'
))
if
(
startDate
<=
endDate
)
{
return
true
}
else
{
return
false
}
}
/**
* 比较时间是否相等
*/
dateEqual
(
before
,
after
)
{
// 计算截止时间
before
=
new
Date
(
before
.
replace
(
'
-
'
,
'
/
'
).
replace
(
'
-
'
,
'
/
'
))
// 计算详细项的截止时间
after
=
new
Date
(
after
.
replace
(
'
-
'
,
'
/
'
).
replace
(
'
-
'
,
'
/
'
))
if
(
before
.
getTime
()
-
after
.
getTime
()
===
0
)
{
return
true
}
else
{
return
false
}
}
/**
* 获取日期范围内所有日期
* @param {Object} begin
* @param {Object} end
*/
geDateAll
(
begin
,
end
)
{
var
arr
=
[]
var
ab
=
begin
.
split
(
'
-
'
)
var
ae
=
end
.
split
(
'
-
'
)
var
db
=
new
Date
()
db
.
setFullYear
(
ab
[
0
],
ab
[
1
]
-
1
,
ab
[
2
])
var
de
=
new
Date
()
de
.
setFullYear
(
ae
[
0
],
ae
[
1
]
-
1
,
ae
[
2
])
var
unixDb
=
db
.
getTime
()
-
24
*
60
*
60
*
1000
var
unixDe
=
de
.
getTime
()
-
24
*
60
*
60
*
1000
for
(
var
k
=
unixDb
;
k
<=
unixDe
;)
{
k
=
k
+
24
*
60
*
60
*
1000
arr
.
push
(
this
.
getDate
(
new
Date
(
parseInt
(
k
))).
fullDate
)
}
return
arr
}
/**
* 计算阴历日期显示
*/
getlunar
(
year
,
month
,
date
)
{
return
CALENDAR
.
solar2lunar
(
year
,
month
,
date
)
}
/**
* 设置打点
*/
setSelectInfo
(
data
,
value
)
{
this
.
selected
=
value
this
.
_getWeek
(
data
)
}
/**
* 获取多选状态
*/
setMultiple
(
fullDate
)
{
let
{
before
,
after
if
(
info
)
{
data
.
extraInfo
=
info
}
dateArr
.
push
(
data
)
}
return
dateArr
}
/**
* 获取下月天数
*/
_getNextMonthDays
(
surplus
,
full
)
{
let
dateArr
=
[]
for
(
let
i
=
1
;
i
<
surplus
+
1
;
i
++
)
{
dateArr
.
push
({
date
:
i
,
month
:
Number
(
full
.
month
)
+
1
,
lunar
:
this
.
getlunar
(
full
.
year
,
Number
(
full
.
month
)
+
1
,
i
),
disable
:
true
})
}
return
dateArr
}
/**
* 获取当前日期详情
* @param {Object} date
*/
getInfo
(
date
)
{
if
(
!
date
)
{
date
=
new
Date
()
}
const
dateInfo
=
this
.
canlender
.
find
(
item
=>
item
.
fullDate
===
this
.
getDate
(
date
).
fullDate
)
return
dateInfo
}
/**
* 比较时间大小
*/
dateCompare
(
startDate
,
endDate
)
{
// 计算截止时间
startDate
=
new
Date
(
startDate
.
replace
(
'
-
'
,
'
/
'
).
replace
(
'
-
'
,
'
/
'
))
// 计算详细项的截止时间
endDate
=
new
Date
(
endDate
.
replace
(
'
-
'
,
'
/
'
).
replace
(
'
-
'
,
'
/
'
))
if
(
startDate
<=
endDate
)
{
return
true
}
else
{
return
false
}
}
/**
* 比较时间是否相等
*/
dateEqual
(
before
,
after
)
{
// 计算截止时间
before
=
new
Date
(
before
.
replace
(
'
-
'
,
'
/
'
).
replace
(
'
-
'
,
'
/
'
))
// 计算详细项的截止时间
after
=
new
Date
(
after
.
replace
(
'
-
'
,
'
/
'
).
replace
(
'
-
'
,
'
/
'
))
if
(
before
.
getTime
()
-
after
.
getTime
()
===
0
)
{
return
true
}
else
{
return
false
}
}
/**
* 获取日期范围内所有日期
* @param {Object} begin
* @param {Object} end
*/
geDateAll
(
begin
,
end
)
{
var
arr
=
[]
var
ab
=
begin
.
split
(
'
-
'
)
var
ae
=
end
.
split
(
'
-
'
)
var
db
=
new
Date
()
db
.
setFullYear
(
ab
[
0
],
ab
[
1
]
-
1
,
ab
[
2
])
var
de
=
new
Date
()
de
.
setFullYear
(
ae
[
0
],
ae
[
1
]
-
1
,
ae
[
2
])
var
unixDb
=
db
.
getTime
()
-
24
*
60
*
60
*
1000
var
unixDe
=
de
.
getTime
()
-
24
*
60
*
60
*
1000
for
(
var
k
=
unixDb
;
k
<=
unixDe
;)
{
k
=
k
+
24
*
60
*
60
*
1000
arr
.
push
(
this
.
getDate
(
new
Date
(
parseInt
(
k
))).
fullDate
)
}
return
arr
}
/**
* 计算阴历日期显示
*/
getlunar
(
year
,
month
,
date
)
{
return
CALENDAR
.
solar2lunar
(
year
,
month
,
date
)
}
/**
* 设置打点
*/
setSelectInfo
(
data
,
value
)
{
this
.
selected
=
value
this
.
_getWeek
(
data
)
}
/**
* 获取多选状态
*/
setMultiple
(
fullDate
)
{
let
{
before
,
after
}
=
this
.
multipleStatus
if
(
!
this
.
range
)
return
if
(
before
&&
after
)
{
this
.
multipleStatus
.
before
=
''
this
.
multipleStatus
.
after
=
''
this
.
multipleStatus
.
data
=
[]
if
(
!
this
.
range
)
return
if
(
before
&&
after
)
{
this
.
multipleStatus
.
before
=
''
this
.
multipleStatus
.
after
=
''
this
.
multipleStatus
.
data
=
[]
}
else
{
if
(
!
before
)
{
this
.
multipleStatus
.
before
=
fullDate
}
else
{
this
.
multipleStatus
.
after
=
fullDate
if
(
this
.
dateCompare
(
this
.
multipleStatus
.
before
,
this
.
multipleStatus
.
after
))
{
this
.
multipleStatus
.
data
=
this
.
geDateAll
(
this
.
multipleStatus
.
before
,
this
.
multipleStatus
.
after
);
}
else
{
this
.
multipleStatus
.
data
=
this
.
geDateAll
(
this
.
multipleStatus
.
after
,
this
.
multipleStatus
.
before
);
}
}
}
this
.
_getWeek
(
fullDate
)
}
/**
* 获取每周数据
* @param {Object} dateData
*/
_getWeek
(
dateData
)
{
const
{
fullDate
,
year
,
month
,
date
,
day
}
=
this
.
getDate
(
dateData
)
let
firstDay
=
new
Date
(
year
,
month
-
1
,
1
).
getDay
()
let
currentDay
=
new
Date
(
year
,
month
,
0
).
getDate
()
let
dates
=
{
lastMonthDays
:
this
.
_getLastMonthDays
(
firstDay
,
this
.
getDate
(
dateData
)),
// 上个月末尾几天
currentMonthDys
:
this
.
_currentMonthDys
(
currentDay
,
this
.
getDate
(
dateData
)),
// 本月天数
nextMonthDays
:
[],
// 下个月开始几天
weeks
:
[]
}
let
canlender
=
[]
const
surplus
=
42
-
(
dates
.
lastMonthDays
.
length
+
dates
.
currentMonthDys
.
length
)
dates
.
nextMonthDays
=
this
.
_getNextMonthDays
(
surplus
,
this
.
getDate
(
dateData
))
canlender
=
canlender
.
concat
(
dates
.
lastMonthDays
,
dates
.
currentMonthDys
,
dates
.
nextMonthDays
)
let
weeks
=
{}
// 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天
for
(
let
i
=
0
;
i
<
canlender
.
length
;
i
++
)
{
if
(
i
%
7
===
0
)
{
weeks
[
parseInt
(
i
/
7
)]
=
new
Array
(
7
)
}
weeks
[
parseInt
(
i
/
7
)][
i
%
7
]
=
canlender
[
i
]
this
.
multipleStatus
.
after
=
fullDate
if
(
this
.
dateCompare
(
this
.
multipleStatus
.
before
,
this
.
multipleStatus
.
after
))
{
this
.
multipleStatus
.
data
=
this
.
geDateAll
(
this
.
multipleStatus
.
before
,
this
.
multipleStatus
.
after
);
}
else
{
this
.
multipleStatus
.
data
=
this
.
geDateAll
(
this
.
multipleStatus
.
after
,
this
.
multipleStatus
.
before
);
}
}
}
this
.
canlender
=
canlender
this
.
weeks
=
weeks
}
//静态方法
// static init(date) {
// if (!this.instance) {
// this.instance = new Calendar(date);
// }
// return this.instance;
// }
}
this
.
_getWeek
(
fullDate
)
}
/**
* 获取每周数据
* @param {Object} dateData
*/
_getWeek
(
dateData
)
{
const
{
fullDate
,
year
,
month
,
date
,
day
}
=
this
.
getDate
(
dateData
)
let
firstDay
=
new
Date
(
year
,
month
-
1
,
1
).
getDay
()
let
currentDay
=
new
Date
(
year
,
month
,
0
).
getDate
()
let
dates
=
{
lastMonthDays
:
this
.
_getLastMonthDays
(
firstDay
,
this
.
getDate
(
dateData
)),
// 上个月末尾几天
currentMonthDys
:
this
.
_currentMonthDys
(
currentDay
,
this
.
getDate
(
dateData
)),
// 本月天数
nextMonthDays
:
[],
// 下个月开始几天
weeks
:
[]
}
let
canlender
=
[]
const
surplus
=
42
-
(
dates
.
lastMonthDays
.
length
+
dates
.
currentMonthDys
.
length
)
dates
.
nextMonthDays
=
this
.
_getNextMonthDays
(
surplus
,
this
.
getDate
(
dateData
))
canlender
=
canlender
.
concat
(
dates
.
lastMonthDays
,
dates
.
currentMonthDys
,
dates
.
nextMonthDays
)
let
weeks
=
{}
// 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天
for
(
let
i
=
0
;
i
<
canlender
.
length
;
i
++
)
{
if
(
i
%
7
===
0
)
{
weeks
[
parseInt
(
i
/
7
)]
=
new
Array
(
7
)
}
weeks
[
parseInt
(
i
/
7
)][
i
%
7
]
=
canlender
[
i
]
}
this
.
canlender
=
canlender
this
.
weeks
=
weeks
}
//静态方法
// static init(date) {
// if (!this.instance) {
// this.instance = new Calendar(date);
// }
// return this.instance;
// }
}
export
default
Calendar
uni_modules/uni-calendar/package.json
浏览文件 @
f9ef3751
{
"id"
:
"uni-calendar"
,
"displayName"
:
"Calendar 日历"
,
"version"
:
"1.3.15"
,
"description"
:
"日历组件"
,
"keywords"
:
[
"日历"
,
"打卡"
,
"日历选择"
],
"repository"
:
"https://github.com/dcloudio/uni-ui"
,
"engines"
:
{
"HBuilderX"
:
""
},
"directories"
:
{
"example"
:
"../../temps/example_temps"
},
"dcloudext"
:
{
"category"
:
[
"前端组件"
,
"通用组件"
],
"sale"
:
{
"regular"
:
{
"price"
:
"0.00"
},
"sourcecode"
:
{
"price"
:
"0.00"
}
},
"contact"
:
{
"qq"
:
""
},
"declaration"
:
{
"ads"
:
"无"
,
"data"
:
"无"
,
"permissions"
:
"无"
},
"npmurl"
:
"https://www.npmjs.com/package/@dcloudio/uni-ui"
},
"uni_modules"
:
{
"dependencies"
:
[],
"encrypt"
:
[],
"platforms"
:
{
"cloud"
:
{
"tcb"
:
"y"
,
"aliyun"
:
"y"
},
"client"
:
{
"App"
:
{
"app-vue"
:
"y"
,
"app-nvue"
:
"y"
},
"H5-mobile"
:
{
"Safari"
:
"y"
,
"Android Browser"
:
"y"
,
"微信浏览器(Android)"
:
"y"
,
"QQ浏览器(Android)"
:
"y"
},
"H5-pc"
:
{
"Chrome"
:
"y"
,
"IE"
:
"y"
,
"Edge"
:
"y"
,
"Firefox"
:
"y"
,
"Safari"
:
"y"
},
"小程序"
:
{
"微信"
:
"y"
,
"阿里"
:
"y"
,
"百度"
:
"y"
,
"字节跳动"
:
"y"
,
"QQ"
:
"y"
},
"快应用"
:
{
"华为"
:
"u"
,
"联盟"
:
"u"
}
}
}
}
{
"id"
:
"uni-calendar"
,
"displayName"
:
"uni-calendar 日历"
,
"version"
:
"1.3.16"
,
"description"
:
"日历组件"
,
"keywords"
:
[
"uni-ui"
,
"uniui"
,
"日历"
,
""
,
"打卡"
,
"日历选择"
],
"repository"
:
"https://github.com/dcloudio/uni-ui"
,
"engines"
:
{
"HBuilderX"
:
""
},
"directories"
:
{
"example"
:
"../../temps/example_temps"
},
"dcloudext"
:
{
"category"
:
[
"前端组件"
,
"通用组件"
],
"sale"
:
{
"regular"
:
{
"price"
:
"0.00"
},
"sourcecode"
:
{
"price"
:
"0.00"
}
},
"contact"
:
{
"qq"
:
""
},
"declaration"
:
{
"ads"
:
"无"
,
"data"
:
"无"
,
"permissions"
:
"无"
},
"npmurl"
:
"https://www.npmjs.com/package/@dcloudio/uni-ui"
},
"uni_modules"
:
{
"dependencies"
:
[],
"encrypt"
:
[],
"platforms"
:
{
"cloud"
:
{
"tcb"
:
"y"
,
"aliyun"
:
"y"
},
"client"
:
{
"App"
:
{
"app-vue"
:
"y"
,
"app-nvue"
:
"y"
},
"H5-mobile"
:
{
"Safari"
:
"y"
,
"Android Browser"
:
"y"
,
"微信浏览器(Android)"
:
"y"
,
"QQ浏览器(Android)"
:
"y"
},
"H5-pc"
:
{
"Chrome"
:
"y"
,
"IE"
:
"y"
,
"Edge"
:
"y"
,
"Firefox"
:
"y"
,
"Safari"
:
"y"
},
"小程序"
:
{
"微信"
:
"y"
,
"阿里"
:
"y"
,
"百度"
:
"y"
,
"字节跳动"
:
"y"
,
"QQ"
:
"y"
},
"快应用"
:
{
"华为"
:
"u"
,
"联盟"
:
"u"
}
}
}
}
}
\ No newline at end of file
uni_modules/uni-calendar/readme.md
浏览文件 @
f9ef3751
## Calendar 日历
> **组件名:uni-calendar**
> 代码块: `uCalendar`
日历组件
> **注意事项**
> 为了避免错误使用,给大家带来不好的开发体验,请在使用组件前仔细阅读下面的注意事项,可以帮你避免一些错误。
> - 本组件农历转换使用的js是 [@1900-2100区间内的公历、农历互转](https://github.com/jjonline/calendar.js)
> - 仅支持自定义组件模式
...
...
@@ -94,3 +96,8 @@ export default {
## 组件示例
点击查看:
[
https://hellouniapp.dcloud.net.cn/pages/extUI/calendar/calendar
](
https://hellouniapp.dcloud.net.cn/pages/extUI/calendar/calendar
)
\ No newline at end of file
uni_modules/uni-sign-in/changelog.md
0 → 100644
浏览文件 @
f9ef3751
uni_modules/uni-sign-in/components/uni-sign-in/uni-sign-in.vue
0 → 100644
浏览文件 @
f9ef3751
<
template
>
<view>
<uni-popup
ref=
"popup"
type=
"center"
>
<image
class=
"background-img"
src=
"@/static/uni-sign-in/background.png"
mode=
"width"
>
</image>
<view
class=
"content"
>
<view
class=
"main"
>
<text
class=
"title"
>
今日签到成功
</text>
<text
class=
"total"
>
本轮已签到
{{
signInRes
.
days
.
length
}}
天
</text>
<text
class=
"scores"
>
当前积分:
{{
signInRes
.
score
}}
</text>
</view>
<view>
<view
class=
"days-box"
>
<view
class=
"days"
v-for=
"(item,index) in weekdays"
:key=
"index"
>
<uni-icons
v-if=
"signInRes.days.includes(item-1)"
class=
"icon active"
color=
"#FFFFFF"
type=
"checkmarkempty"
></uni-icons>
<template
v-else
>
<uni-icons
v-if=
"item
<signInRes.n
"
class=
"icon active"
color=
"#FFFFFF"
type=
"closeempty"
></uni-icons>
<uni-icons
v-else
class=
"icon"
type=
"checkmarkempty"
color=
"#FFFFFF"
></uni-icons>
</
template
>
<
template
v-if=
"signInRes.days.includes(item-1)||item>signInRes.n"
>
<text
class=
"day"
:class=
"
{grey:item>signInRes.n}">第
{{
item
}}
天
</text>
</
template
>
<text
v-else
class=
"day"
>
缺卡
</text>
</view>
</view>
<view
class=
"tip-box"
>
<text
class=
"tip"
>
签到一次得10积分
</text>
<view
class=
"row"
>
<text
class=
"tip"
>
连续签到7天可多得
</text>
<text
class=
"red"
>
50
</text>
<text
class=
"tip"
>
积分
</text>
</view>
</view>
</view>
<uni-icons
@
click=
"closeMe"
class=
"close-icon"
type=
"closeempty"
size=
"20"
color=
"#AAAAAA"
></uni-icons>
</view>
</uni-popup>
</view>
</template>
<
script
>
const
db
=
uniCloud
.
database
();
const
signInTable
=
db
.
collection
(
'
opendb-sign-in
'
)
export
default
{
name
:
"
uni-signIn
"
,
data
()
{
return
{
total
:
0
,
scores
:
0
,
weekdays
:
[
1
,
2
,
3
,
4
,
5
,
6
,
7
],
signInRes
:
{
days
:
[],
n
:
0
}
}
},
mounted
()
{},
methods
:
{
closeMe
(
e
)
{
this
.
$refs
.
popup
.
close
()
},
async
open
()
{
uni
.
showLoading
({
mask
:
true
});
const
date
=
new
Date
(
new
Date
().
toLocaleDateString
()).
getTime
()
let
res
=
await
signInTable
.
action
(
'
signIn
'
)
.
where
(
`'user_id' == $env.uid && 'date' ==
${
date
}
&& 'isDelete' == false`
)
.
get
()
this
.
signInRes
=
res
.
result
console
.
log
(
res
);
if
(
res
.
result
.
data
.
length
)
{
uni
.
hideLoading
()
uni
.
showToast
({
title
:
'
今日已签过
'
,
duration
:
3000
,
icon
:
'
none
'
});
}
else
{
let
res
=
await
signInTable
.
action
(
'
signIn
'
).
add
({});
console
.
log
(
res
);
uni
.
hideLoading
()
this
.
signInRes
=
res
.
result
if
(
this
.
signInRes
.
days
.
length
==
7
){
uni
.
showToast
({
title
:
"
你已完成7日连续签到,获得60积分!
"
,
icon
:
"
none
"
,
duration
:
5000
})
}
else
{
uni
.
showToast
({
title
:
"
签到成功,获得10积分!
"
,
icon
:
"
none
"
,
duration
:
5000
})
}
}
this
.
$refs
.
popup
.
open
()
}
}
}
</
script
>
<
style
lang=
"scss"
>
.background-img
{
width
:
600rpx
;
height
:
600rpx
;
}
.content
{
position
:
absolute
;
width
:
600rpx
;
height
:
600rpx
;
justify-content
:
space-around
;
align-items
:
center
;
border-radius
:
10px
;
z-index
:
5
;
}
.background-img
,
.content
{
top
:
0
;
}
.main
{
align-items
:
center
;
}
.title
{
font-size
:
44rpx
;
color
:
#FFFFFF
;
font-weight
:
600
;
}
.total
{
background-color
:
#FFFFFF
;
color
:
#ed5200
;
text-align
:
center
;
border-radius
:
100px
;
font-size
:
30rpx
;
margin
:
16rpx
0
;
width
:
230rpx
;
}
.scores
{
text-align
:
center
;
color
:
#FFFFFF
;
}
.days-box
{
flex-direction
:
row
;
}
.days
{
margin
:
12rpx
;
font-size
:
19rpx
;
justify-content
:
center
;
align-items
:
center
;
color
:
#f8692c
;
}
.grey
{
color
:
#C0C0C0
;
}
.days-box
.icon
{
background-color
:
#feefeb
;
border-radius
:
100px
;
height
:
50rpx
;
line-height
:
50rpx
;
justify-content
:
center
;
width
:
50rpx
;
margin-bottom
:
6rpx
;
}
.days-box
.icon.active
{
background-image
:
linear-gradient
(
to
top
,
#FF9002
,
#FF5100
);
background-color
:
#ffff7f
;
}
.content
,
.days-box
{
padding
:
26rpx
;
}
.tip-box
{
justify-content
:
center
;
}
.tip-box
.row
{
flex-direction
:
row
;
justify-content
:
center
;
}
.tip
,
.red
{
text-align
:
center
;
font-size
:
24rpx
;
color
:
#999999
;
height
:
30rpx
;
line-height
:
30rpx
;
}
.red
{
color
:
#ff0000
;
}
.close-icon
{
margin-bottom
:
-180rpx
;
background-color
:
#FFFFFF
;
border-radius
:
100px
;
text-align
:
center
;
height
:
46rpx
;
line-height
:
46rpx
;
width
:
46rpx
;
}
</
style
>
uni_modules/uni-sign-in/package.json
0 → 100644
浏览文件 @
f9ef3751
{
"id"
:
"uni-sign-in"
,
"displayName"
:
"uni-sign-in"
,
"version"
:
"1.0.0"
,
"description"
:
"uni-sign-in"
,
"keywords"
:
[
"uni-sign-in"
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^3.1.0"
},
"dcloudext"
:
{
"category"
:
[
"uniCloud"
,
"云端一体页面模板"
],
"sale"
:
{
"regular"
:
{
"price"
:
"0.00"
},
"sourcecode"
:
{
"price"
:
"0.00"
}
},
"contact"
:
{
"qq"
:
""
},
"declaration"
:
{
"ads"
:
""
,
"data"
:
""
,
"permissions"
:
""
},
"npmurl"
:
""
},
"uni_modules"
:
{
"dependencies"
:
[],
"encrypt"
:
[],
"platforms"
:
{
"cloud"
:
{
"tcb"
:
"u"
,
"aliyun"
:
"u"
},
"client"
:
{
"App"
:
{
"app-vue"
:
"u"
,
"app-nvue"
:
"u"
},
"H5-mobile"
:
{
"Safari"
:
"u"
,
"Android Browser"
:
"u"
,
"微信浏览器(Android)"
:
"u"
,
"QQ浏览器(Android)"
:
"u"
},
"H5-pc"
:
{
"Chrome"
:
"u"
,
"IE"
:
"u"
,
"Edge"
:
"u"
,
"Firefox"
:
"u"
,
"Safari"
:
"u"
},
"小程序"
:
{
"微信"
:
"u"
,
"阿里"
:
"u"
,
"百度"
:
"u"
,
"字节跳动"
:
"u"
,
"QQ"
:
"u"
},
"快应用"
:
{
"华为"
:
"u"
,
"联盟"
:
"u"
}
}
}
}
}
\ No newline at end of file
uni_modules/uni-sign-in/readme.md
0 → 100644
浏览文件 @
f9ef3751
# uni-sign-in
\ No newline at end of file
uni_modules/uni-sign-in/uniCloud/cloudfunctions/uni-clientDB-actions/signIn.js
0 → 100644
浏览文件 @
f9ef3751
// 开发文档:https://uniapp.dcloud.io/uniCloud/clientdb?id=action
const
db
=
uniCloud
.
database
();
const
dbCmd
=
db
.
command
const
signInTable
=
db
.
collection
(
'
opendb-sign-in
'
);
const
scoresTable
=
db
.
collection
(
'
uni-id-scores
'
);
module
.
exports
=
{
before
:
async
(
state
,
event
)
=>
{
// console.log({state});
if
(
state
.
type
==
'
create
'
){
let
date
=
new
Date
(
new
Date
().
toLocaleDateString
()).
getTime
()
let
{
total
}
=
await
signInTable
.
where
({
user_id
:
state
.
auth
.
uid
,
date
,
isDelete
:
false
}).
count
()
console
.
log
(
total
);
if
(
total
){
throw
new
Error
(
"
今天已经签到
"
)
}
state
.
newData
.
date
=
date
state
.
newData
.
isDelete
=
false
}
},
after
:
async
(
state
,
event
,
error
,
result
)
=>
{
if
(
error
)
{
throw
error
}
let
date
=
new
Date
(
new
Date
().
toLocaleDateString
()).
getTime
()
//查最近7天的签到情况
let
{
data
:
signInData
}
=
await
signInTable
.
where
({
user_id
:
state
.
auth
.
uid
,
date
:
dbCmd
.
gte
(
date
-
3600
*
24
*
6
*
1000
),
isDelete
:
false
}).
get
()
let
allDate
=
signInData
.
map
(
item
=>
item
.
date
)
//今天是本轮签到的第几天
const
n
=
(
date
-
Math
.
min
(...
allDate
)
)
/
3600
/
24
/
1000
+
1
;
//换成数字--第几天
let
days
=
signInData
.
map
(
item
=>
{
return
(
n
*
10000
-
(
date
-
item
.
date
)
/
3600
/
24
/
1000
*
10000
)
/
10000
-
1
})
if
(
state
.
type
==
'
create
'
){
if
(
n
==
7
){
//如果已经满一轮就软删除之前的内容
let
setIsDeleteRes
=
await
signInTable
.
where
({
user_id
:
state
.
auth
.
uid
,
date
:
dbCmd
.
neq
(
date
)
}).
update
({
isDelete
:
true
})
console
.
log
({
setIsDeleteRes
});
}
//给加积分
let
addScores
=
await
scoresTable
.
where
({
user_id
:
state
.
auth
.
uid
}).
update
({
user_id
:
state
.
auth
.
uid
,
score
:
dbCmd
.
inc
(
n
==
7
?
60
:
10
)
//如果是第七天就多加50分,也就是60分
})
console
.
log
({
addScores
});
}
//查出来有多少积分
let
{
data
:[{
score
}]}
=
await
scoresTable
.
where
({
user_id
:
state
.
auth
.
uid
}).
get
()
return
{...
result
,
score
,
signInData
,
n
,
days
}
}
}
uni_modules/uni-sign-in/uniCloud/database/opendb-sign-in.schema.json
0 → 100644
浏览文件 @
f9ef3751
//
文档教程:
https://uniapp.dcloud.net.cn/uniCloud/schema
{
"bsonType"
:
"object"
,
"required"
:
[],
"permission"
:
{
"read"
:
"auth.uid == doc.user_id"
,
"create"
:
"auth.uid != null && 'signIn' in action"
,
"update"
:
false
,
"delete"
:
false
},
"properties"
:
{
"_id"
:
{
"description"
:
"ID,系统自动生成"
},
"user_id"
:{
"forceDefaultValue"
:{
"$env"
:
"uid"
}
},
"date"
:{
"bsonType"
:
"timestamp"
,
"description"
:
"签到的日期时间戳"
,
"permission"
:{
"write"
:
false
}
},
"create_time"
:{
"bsonType"
:
"timestamp"
,
"description"
:
"签到的时间戳"
,
"forceDefaultValue"
:{
"$env"
:
"now"
}
},
"ip"
:{
"bsonType"
:
"string"
,
"forceDefaultValue"
:{
"$env"
:
"clientIP"
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录