[Update]新增萬年曆

master
kenyeh 3 years ago
parent 81d50ca5dc
commit 084e4f2696

File diff suppressed because it is too large Load Diff

@ -0,0 +1,8 @@
{
"ver": "1.2.9",
"uuid": "209fdb1e-fd30-4d03-b73f-ba45e94cc208",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}

@ -0,0 +1,452 @@
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "singleDate",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 5
},
{
"__id__": 8
}
],
"_active": true,
"_components": [
{
"__id__": 11
}
],
"_prefab": {
"__id__": 12
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 36,
"height": 36
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "check",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 176,
"g": 176,
"b": 176,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 36,
"height": 36
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "445524c2-2a0b-4053-960a-eb6e74a7383c"
},
"fileId": "8e4mOsJoJKd4hNqtrsbOnY",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "unCheck",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 6
}
],
"_prefab": {
"__id__": 7
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 36,
"height": 36
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "445524c2-2a0b-4053-960a-eb6e74a7383c"
},
"fileId": "a6Jd6b2sBE9btJwkwNrgKL",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "dateLabel",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 9
}
],
"_prefab": {
"__id__": 10
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 135,
"g": 58,
"b": 58,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 20.02,
"height": 22.68
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_string": "31",
"_N$string": "31",
"_fontSize": 18,
"_lineHeight": 18,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "445524c2-2a0b-4053-960a-eb6e74a7383c"
},
"fileId": "b8SBz+f1BE3Jo/GCgbc9VV",
"sync": false
},
{
"__type__": "35b86nrGPZKwbu8g+1+XD5Y",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"checkEvents": [],
"_isChecked": false,
"onNodeList": [
{
"__id__": 2
}
],
"offNodeList": [
{
"__id__": 5
}
],
"toggleSwitchType": 0,
"isDoNotEmitToggle": false,
"checkNode": {
"__id__": 2
},
"unCheckNode": {
"__id__": 5
},
"dateLabelNode": {
"__id__": 8
},
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "445524c2-2a0b-4053-960a-eb6e74a7383c"
},
"fileId": "",
"sync": false
}
]

@ -0,0 +1,8 @@
{
"ver": "1.2.9",
"uuid": "445524c2-2a0b-4053-960a-eb6e74a7383c",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}

@ -64,8 +64,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
128,
540,
-512,
180,
0,
0,
0,
@ -450,8 +450,8 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "",
"_N$string": "",
"_string": "20",
"_N$string": "20",
"_fontSize": 20,
"_lineHeight": 20,
"_enableWrapText": true,
@ -1068,8 +1068,8 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "",
"_N$string": "",
"_string": "無人機A",
"_N$string": "無人機A",
"_fontSize": 20,
"_lineHeight": 20,
"_enableWrapText": true,
@ -1532,8 +1532,8 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "",
"_N$string": "",
"_string": "12'34'56.7\"\"",
"_N$string": "12'34'56.7\"\"",
"_fontSize": 20,
"_lineHeight": 20,
"_enableWrapText": true,
@ -1892,8 +1892,8 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "",
"_N$string": "",
"_string": "98'76'54.0123\"\"",
"_N$string": "98'76'54.0123\"\"",
"_fontSize": 20,
"_lineHeight": 20,
"_enableWrapText": true,

Binary file not shown.

After

Width:  |  Height:  |  Size: 547 B

@ -0,0 +1,36 @@
{
"ver": "2.3.5",
"uuid": "cea29b8d-3aa6-478d-985f-fee264d871cb",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 18,
"height": 28,
"platformSettings": {},
"subMetas": {
"arrow_next": {
"ver": "1.0.4",
"uuid": "223204ed-bd90-4918-910b-7a7df51b7b4f",
"rawTextureUuid": "cea29b8d-3aa6-478d-985f-fee264d871cb",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0.5,
"offsetY": 0,
"trimX": 1,
"trimY": 0,
"width": 17,
"height": 28,
"rawWidth": 18,
"rawHeight": 28,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

@ -0,0 +1,36 @@
{
"ver": "2.3.5",
"uuid": "ac45b49a-4520-4504-8510-5eaac0cee9af",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 18,
"height": 28,
"platformSettings": {},
"subMetas": {
"arrow_prev": {
"ver": "1.0.4",
"uuid": "28dda0b8-8b57-4bd4-9a82-b471bdf8967a",
"rawTextureUuid": "ac45b49a-4520-4504-8510-5eaac0cee9af",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0.5,
"offsetY": 0,
"trimX": 1,
"trimY": 0,
"width": 17,
"height": 28,
"rawWidth": 18,
"rawHeight": 28,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

@ -78,13 +78,13 @@
"_active": true,
"_components": [
{
"__id__": 15
"__id__": 17
},
{
"__id__": 16
"__id__": 18
},
{
"__id__": 17
"__id__": 19
}
],
"_prefab": null,
@ -252,6 +252,9 @@
},
{
"__id__": 13
},
{
"__id__": 15
}
],
"_active": true,
@ -599,6 +602,52 @@
"fileId": "",
"sync": true
},
{
"__type__": "cc.Node",
"_objFlags": 0,
"_parent": {
"__id__": 5
},
"_prefab": {
"__id__": 16
},
"_name": "calendar",
"_active": true,
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
512,
180,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "fcMHEijz5CrpvTu2Hy/C8L"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 15
},
"asset": {
"__uuid__": "209fdb1e-fd30-4d03-b73f-ba45e94cc208"
},
"fileId": "",
"sync": true
},
{
"__type__": "cc.Canvas",
"_name": "",

@ -0,0 +1,134 @@
cc.Class({
extends: cc.Component,
properties: {
},
// use this for initialization
onLoad: function () {
var date = new Date()
var newyear = date.getFullYear();
var newmonth = date.getMonth();
var newday = date.getDate();
// 获取这月有多少天
var currentDay = this.getMonthsDay(newyear, newmonth);
// 获取当月第一天星期几
var firstDay = this.getMonthFirst(newyear, newmonth);
var lastMonth = (newmonth - 1) >= 0 ? (newmonth - 1) : 12;
this.node.getChildByName('data').getChildByName(`year`).getComponent(cc.Label).string = newyear + " 年";
this.node.getChildByName('data').getChildByName(`month`).getComponent(cc.Label).string = (newmonth + 1) + " 月";
var lastDay = this.getMonthsDay(newyear, lastMonth);
var newlastDay = lastDay;
for(var i = firstDay - 1; i >= 0; i--) {
this.node.getChildByName('title1').getChildByName(`item${i}`).color = new cc.Color(192,192,192);
this.node.getChildByName('title1').getChildByName(`item${i}`).getComponent(cc.Label).string = newlastDay--;
}
cc.dd.log(`lastMonth:${lastMonth} newmonth:${newmonth} firstDay:${firstDay} currentDay:${currentDay} lastDay:${lastDay} `);
var newCurrentDay = 1;
for (var i = firstDay; i <= 6; i++) {
if (newCurrentDay == newday) {
this.node.getChildByName('title1').getChildByName(`item${i}`).color = new cc.Color(65,205,225);
}
this.node.getChildByName('title1').getChildByName(`item${i}`).getComponent(cc.Label).string = newCurrentDay++;
}
var num = 1;
var number = 0;
for(var i = newCurrentDay; i <= currentDay; i++) {
if ((i - newCurrentDay) % 7 === 0) {
num++;
number = 0;
}
if (i == newday) {
this.node.getChildByName(`title${num}`).getChildByName(`item${number}`).color = new cc.Color(65,205,225);
}
this.node.getChildByName(`title${num}`).getChildByName(`item${number++}`).getComponent(cc.Label).string = i;
}
if (number <= 6) {
var index = 1;
for (var i = number; i <=6; i++) {
this.node.getChildByName(`title${num}`).getChildByName(`item${number}`).color = new cc.Color(192,192,192);
this.node.getChildByName(`title${num}`).getChildByName(`item${number++}`).getComponent(cc.Label).string = index++;
}
}
/**
* var date = new Date()
*
* // 获取年份
* var newyear = data.getFullYear()
*
* // 获取月份
* var newmonth = data.getMonth()
*
*
* // 获取今日日期
* var newday = data.getDate()
*
* // 获取今天星期几
* data.getDay()
*
* // 获取这月第一天星期几
* var s = new Date(newYear, newmonth, 1);
* firstday = s.getDay()
*/
},
// 获取那年那月有多少天
getMonthsDay(year, month) {
var year = year;
var month = month;
if (arguments.length == 0) {
var date = new Date();
year = date.getFullYear();
month = data.getMonth();
}
if (arguments.length == 1) {
var date = new Date();
month = data.getMonth();
}
var monthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)) {
monthDays[1] = 29;
}
return monthDays[month];
},
// 获取这个月第一天星期几
getMonthFirst(year, month) {
var year = year;
var month = month;
if (arguments.length == 0) {
var date = new Date();
year = date.getFullYear();
month = data.getMonth();
}
if (arguments.length == 1) {
var date = new Date();
month = data.getMonth();
}
var newDate = new Date(year, month, 1);
return newDate.getDay();
},
});

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "2a23a12d-b7af-4528-a740-34286399a2fa",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "f84abc0e-cab4-47b4-8f78-98266a5ec04a",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

@ -0,0 +1,174 @@
import BaseComp from "../external/BaseComp";
import { CustomToggle } from "../external/CustomToggleItem";
import SingleDateItem from "./SingleDateItem";
const { ccclass, property } = cc._decorator;
@ccclass
export default class Calender extends BaseComp {
@property(cc.Prefab)
dateItem: cc.Prefab = null
@property(cc.Node)
dateContent: cc.Node = null
@property(cc.Label)
yearLabel: cc.Label = null
@property(cc.Label)
monthLabel: cc.Label = null
showMonth: number = 0
showYear: number = 0
nowSelectMonth: number = 0
nowSelectYear: number = 0
nowSelectDate: number = 0
onLoad() {
let date = new Date()
let newYear = date.getFullYear()
let newMonth = date.getMonth()
let newDay = date.getDate()
this.nowSelectMonth = newMonth
this.nowSelectYear = newYear
this.showMonth = newMonth + 1
this.monthLabel.string = `${this.showMonth}`
this.showYear = newYear
this.yearLabel.string = `${this.showYear}`
// 當月有多少天
let currentDay = this.getMonthsDay(newYear, newMonth)
// 當月第一天星期幾
let firstDay = this.getMonthFirst(newYear, newMonth)
//要給layout自動排列,所以每個月的第一天,前面會用空的item去填滿,因此會創造出空白天數 + 當月天數
let totalDateItem = currentDay + firstDay
for (let i = 0; i < totalDateItem; i++) {
let dateItem = cc.instantiate(this.dateItem)
dateItem.parent = this.dateContent
let dateItemComp = dateItem.getComponent(SingleDateItem)
if (i < firstDay) {
dateItemComp.setBlank()
} else {
let date = i - (firstDay - 1)
dateItemComp.reset()
dateItemComp.setDate(date)
if (date === newDay) {
dateItemComp.isChecked = true
this.nowSelectDate = newDay
}
}
}
}
onChangeArrowClick(event: cc.Event, customEventData: string) {
let delta = Number(customEventData)
this.showMonth += delta
if (this.showMonth > 12) {
this.showYear += 1
this.showMonth = 1
}
if (this.showMonth < 1) {
this.showYear -= 1
this.showMonth = 12
}
this.monthLabel.string = `${this.showMonth}`
this.yearLabel.string = `${this.showYear}`
this.updateAllDate()
}
updateAllDate() {
let currentMonth = this.showMonth - 1 //date的month是0-base,即0 = 1月, 11 = 12月
// 获取这月有多少天
let currentDay = this.getMonthsDay(this.showYear, currentMonth)
// 获取当月第一天星期几
let firstDay = this.getMonthFirst(this.showYear, currentMonth)
this.dateContent.children.forEach(item => {
item?.getComponent(SingleDateItem).setBlank()
})
let totalDateItem = currentDay + firstDay
for (let i = 0; i < totalDateItem; i++) {
let date = i - (firstDay - 1)
const isMatchSelectedDate = ():boolean => {
return this.nowSelectDate === date && this.nowSelectMonth === currentMonth && this.nowSelectYear === this.showYear
}
let isExistItem = this.dateContent.children[i]
let dateItemComp: SingleDateItem = null
if (isExistItem) {
//已經存在就改數字,改顯示
dateItemComp = isExistItem.getComponent(SingleDateItem)
} else {
//表示沒item,那就創出來放上去
let dateItem = cc.instantiate(this.dateItem)
dateItem.parent = this.dateContent
dateItemComp = dateItem.getComponent(SingleDateItem)
}
if (i < firstDay) {
dateItemComp.setBlank()
} else {
dateItemComp.reset()
dateItemComp.setDate(date)
dateItemComp.isChecked = isMatchSelectedDate()
}
}
}
onDateSelected(toggle: CustomToggle) {
this.nowSelectDate = toggle.node.getComponent(SingleDateItem).date
this.nowSelectMonth = this.showMonth - 1
this.nowSelectYear = this.showYear
}
// 那年那月有多少天
getMonthsDay(year: number, month: number) {
let _year = year
let _month = month
let date = new Date()
if (arguments.length == 0) {
_year = date.getFullYear()
_month = date.getMonth()
}
if (arguments.length == 1) {
_month = date.getMonth()
}
let monthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if ((_year % 4 == 0) && (_year % 100 != 0) || (_year % 400 == 0)) {
monthDays[1] = 29
}
return monthDays[_month]
}
// 這個月第一天是星期幾
getMonthFirst(year: number, month: number) {
let _year = year
let _month = month
let date = new Date()
if (arguments.length == 0) {
_year = date.getFullYear()
_month = date.getMonth()
}
if (arguments.length == 1) {
_month = date.getMonth()
}
let newDate = new Date(_year, _month, 1)
return newDate.getDay()
}
}

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "af0570d3-1c4a-4134-9b22-835132ad0b53",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

@ -0,0 +1,45 @@
import { CustomToggle } from "../external/CustomToggleItem";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SingleDateItem extends CustomToggle {
@property(cc.Node)
checkNode: cc.Node = null
@property(cc.Node)
unCheckNode: cc.Node = null
@property(cc.Node)
dateLabelNode: cc.Node = null
protected _date: number
get date(): number {
return this._date
}
set date(d: number) {
this._date = d
}
reset() {
this.isChecked = false
this.checkNode.active = false
this.unCheckNode.active = true
this.dateLabelNode.active = true
}
/**
* calander使layout,西
*/
setBlank() {
this.isChecked = false
this.checkNode.active = false
this.unCheckNode.active = false
this.dateLabelNode.active = false
}
setDate(date: number) {
this.date = date
this.dateLabelNode.getComponent(cc.Label).string = `${date}`
}
}

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "35b869eb-18f6-4ac1-bbbc-83ed7e5c3e58",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
Loading…
Cancel
Save