1.
This commit is contained in:
263
unpackage/dist/dev/mp-weixin/components/LCCalendar/LCCalendar.js
vendored
Normal file
263
unpackage/dist/dev/mp-weixin/components/LCCalendar/LCCalendar.js
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const common_assets = require("../../common/assets.js");
|
||||
const _sfc_main = {
|
||||
name: "LCCalendar",
|
||||
data() {
|
||||
return {
|
||||
weekList: ["日", "一", "二", "三", "四", "五", "六"],
|
||||
monthDateList: [],
|
||||
selectMonthIndex: 0,
|
||||
//选中月份下标
|
||||
selectMonth: "",
|
||||
//选中年月
|
||||
selectDateStr: "",
|
||||
//选中日期
|
||||
startDateStr: "",
|
||||
//开始日期
|
||||
endDateStr: ""
|
||||
//结束日期
|
||||
};
|
||||
},
|
||||
created() {
|
||||
let currentDate = /* @__PURE__ */ new Date();
|
||||
let currentYear = currentDate.getFullYear();
|
||||
let currentMonth = currentDate.getMonth() + 1;
|
||||
let currentDay = currentDate.getDate();
|
||||
this.selectMonthIndex = 20 * 12 + currentMonth - 1;
|
||||
this.selectMonth = currentYear + "年" + currentMonth + "月";
|
||||
this.startDateStr = currentYear + "-" + (currentMonth > 9 ? currentMonth : "0" + currentMonth) + "-01";
|
||||
this.endDateStr = this.selectDateStr = currentYear + "-" + (currentMonth > 9 ? currentMonth : "0" + currentMonth) + "-" + (currentDay > 9 ? currentDay : "0" + currentDay);
|
||||
this.generateMonthDateListData();
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:97", JSON.stringify(this.monthDateList[0]));
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 获取当前时间前一天的数据
|
||||
*/
|
||||
getYesterdayDateData() {
|
||||
let currentDate = /* @__PURE__ */ new Date();
|
||||
let selectDate = new Date(currentDate);
|
||||
selectDate.setDate(selectDate.getDate() - 1);
|
||||
let selectYear = selectDate.getFullYear();
|
||||
let selectMonth = selectDate.getMonth() + 1;
|
||||
let selectDay = selectDate.getDate();
|
||||
this.selectDateStr = selectYear + "-" + (selectMonth > 9 ? selectMonth : "0" + selectMonth) + "-" + (selectDay > 9 ? selectDay : "0" + selectDay);
|
||||
},
|
||||
/**
|
||||
* 生成日期数组
|
||||
*/
|
||||
generateMonthDateListData() {
|
||||
let currentDate = /* @__PURE__ */ new Date();
|
||||
let currentYear = currentDate.getFullYear();
|
||||
let currentMonth = currentDate.getMonth() + 1;
|
||||
let currentDay = currentDate.getDate();
|
||||
let monthDateList = [];
|
||||
for (var i = currentYear - 20; i < currentYear + 20; i++) {
|
||||
for (var j = 0; j < 12; j++) {
|
||||
let date = new Date(i, j + 1, 0);
|
||||
let firstDayOfMonth = new Date(i, j + 1, 0);
|
||||
firstDayOfMonth.setDate(1);
|
||||
let currentMonthDay = date.getDate();
|
||||
let firstDayWeek = firstDayOfMonth.getDay() + 1;
|
||||
let daysOfMonth = [];
|
||||
for (var k = 1; k <= currentMonthDay; k++) {
|
||||
let newDate = new Date(i, j + 1, 0);
|
||||
newDate.setDate(k);
|
||||
let newMonth = newDate.getMonth() + 1;
|
||||
let newDay = newDate.getDate();
|
||||
let time = newDate.getTime();
|
||||
let date2 = i + "-" + (newMonth > 9 ? newMonth : "0" + newMonth) + "-" + (newDay > 9 ? newDay : "0" + newDay);
|
||||
daysOfMonth.push({
|
||||
date: date2,
|
||||
year: i,
|
||||
month: newMonth,
|
||||
day: newDay,
|
||||
isToday: i == currentYear && newMonth == currentMonth && newDay == currentDay ? true : false,
|
||||
isCurrentMonth: true,
|
||||
isLastDay: newDay == currentMonthDay ? true : false,
|
||||
timestamp: time
|
||||
});
|
||||
}
|
||||
for (var k = 0; k < firstDayWeek - 1; k++) {
|
||||
let year = i;
|
||||
let month = j;
|
||||
if (j < 1) {
|
||||
year = i - 1;
|
||||
month = 12;
|
||||
}
|
||||
let lastMonthDay = new Date(year, month, 0).getDate();
|
||||
let newDate = new Date(year, month - 1, lastMonthDay - k);
|
||||
let newMonth = newDate.getMonth() + 1;
|
||||
let newDay = newDate.getDate();
|
||||
let time = newDate.getTime();
|
||||
let date2 = year + "-" + (newMonth > 9 ? newMonth : "0" + newMonth) + "-" + (newDay > 9 ? newDay : "0" + newDay);
|
||||
daysOfMonth.unshift({
|
||||
date: date2,
|
||||
year,
|
||||
month: newMonth,
|
||||
day: newDay,
|
||||
isToday: false,
|
||||
isCurrentMonth: false,
|
||||
isLastDay: false,
|
||||
timestamp: time
|
||||
});
|
||||
}
|
||||
let nextMonthFirstDay = new Date(i, j + 1, 1);
|
||||
let lastDayOfMonth = new Date(nextMonthFirstDay - 24 * 60 * 60 * 1e3);
|
||||
let lastDayWeek = lastDayOfMonth.getDay() + 1;
|
||||
for (var k = 1; k < 8 - lastDayWeek; k++) {
|
||||
let year = i;
|
||||
let month = j;
|
||||
if (month > 11) {
|
||||
month = 0;
|
||||
year++;
|
||||
}
|
||||
let newDate = new Date(year, month + 1, k);
|
||||
let newMonth = newDate.getMonth() + 1;
|
||||
let newDay = newDate.getDate();
|
||||
let time = newDate.getTime();
|
||||
let date2 = year + "-" + (newMonth > 9 ? newMonth : "0" + newMonth) + "-" + (newDay > 9 ? newDay : "0" + newDay);
|
||||
daysOfMonth.push({
|
||||
date: date2,
|
||||
year,
|
||||
month: newMonth,
|
||||
day: newDay,
|
||||
isToday: false,
|
||||
isCurrentMonth: false,
|
||||
isLastDay: false,
|
||||
timestamp: time
|
||||
});
|
||||
}
|
||||
monthDateList.push(daysOfMonth);
|
||||
}
|
||||
}
|
||||
this.monthDateList = monthDateList;
|
||||
},
|
||||
/**
|
||||
* 点击上个月
|
||||
*/
|
||||
clickPreMonth() {
|
||||
if (this.selectMonthIndex > 0) {
|
||||
this.selectMonthIndex--;
|
||||
let monthList = this.monthDateList[this.selectMonthIndex];
|
||||
let year = "";
|
||||
let month = "";
|
||||
for (let item of monthList) {
|
||||
if (item.isCurrentMonth) {
|
||||
year = item.year;
|
||||
month = item.month;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let lastDay = "";
|
||||
for (let item of monthList) {
|
||||
if (item.isLastDay) {
|
||||
lastDay = item.day;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.selectMonth = year + "年" + month + "月";
|
||||
this.startDateStr = year + "-" + (month > 9 ? month : "0" + month) + "-01";
|
||||
this.endDateStr = year + "-" + (month > 9 ? month : "0" + month) + "-" + lastDay;
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:241", "点击上个月");
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 点击下个月
|
||||
*/
|
||||
clickNextMonth() {
|
||||
if (this.selectMonthIndex < this.monthDateList.length - 1) {
|
||||
this.selectMonthIndex++;
|
||||
let monthList = this.monthDateList[this.selectMonthIndex];
|
||||
let year = "";
|
||||
let month = "";
|
||||
for (let item of monthList) {
|
||||
if (item.isCurrentMonth) {
|
||||
year = item.year;
|
||||
month = item.month;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let lastDay = "";
|
||||
for (let item of monthList) {
|
||||
if (item.isLastDay) {
|
||||
lastDay = item.day;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.selectMonth = year + "年" + month + "月";
|
||||
this.startDateStr = year + "-" + (month > 9 ? month : "0" + month) + "-01";
|
||||
this.endDateStr = year + "-" + (month > 9 ? month : "0" + month) + "-" + lastDay;
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:270", "点击下个月");
|
||||
}
|
||||
},
|
||||
monthChange(e) {
|
||||
let currentDate = /* @__PURE__ */ new Date();
|
||||
let currentYear = currentDate.getFullYear();
|
||||
let yearMonth = e.detail.value;
|
||||
let selectYear = parseInt(yearMonth.split("-")[0]);
|
||||
let selectMonth = parseInt(yearMonth.split("-")[1]);
|
||||
this.selectMonthIndex = (selectYear - (currentYear - 20)) * 12 + selectMonth - 1;
|
||||
this.selectMonth = selectYear + "年" + selectMonth + "月";
|
||||
this.startDateStr = selectYear + "-" + (selectMonth > 9 ? selectMonth : "0" + selectMonth) + "-01";
|
||||
let lastDayOfMonth = new Date(selectYear, selectMonth, 0);
|
||||
this.endDateStr = selectYear + "-" + (selectMonth > 9 ? selectMonth : "0" + selectMonth) + "-" + lastDayOfMonth.getDate();
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:287", "月份变更");
|
||||
},
|
||||
/**
|
||||
* 点击选择开始日期和结束日期
|
||||
* @param {Object} item
|
||||
*/
|
||||
clickSelectDate(item) {
|
||||
if (!item.isCurrentMonth)
|
||||
return;
|
||||
if (this.selectDateStr != item.date) {
|
||||
this.selectDateStr = item.date;
|
||||
this.chgStockData = item;
|
||||
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:298", "点击某天");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return {
|
||||
a: common_assets._imports_0$1,
|
||||
b: common_vendor.o(($event) => $options.clickPreMonth()),
|
||||
c: common_assets._imports_1$16,
|
||||
d: common_vendor.t($data.selectDateStr),
|
||||
e: common_vendor.o((...args) => $options.monthChange && $options.monthChange(...args)),
|
||||
f: common_assets._imports_2$3,
|
||||
g: common_vendor.o(($event) => $options.clickNextMonth()),
|
||||
h: common_vendor.f($data.weekList, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item),
|
||||
b: index
|
||||
};
|
||||
}),
|
||||
i: common_vendor.f($data.monthDateList[$data.selectMonthIndex], (item, index, i0) => {
|
||||
return common_vendor.e({
|
||||
a: item.date == $data.selectDateStr
|
||||
}, item.date == $data.selectDateStr ? common_vendor.e({
|
||||
b: common_vendor.t(item.day),
|
||||
c: index % 7 == 0 || index % 7 == 6
|
||||
}, index % 7 == 0 || index % 7 == 6 ? {} : {}, {
|
||||
d: common_vendor.n("date select " + (item.avg_change_pct ? _ctx.getRateUpOrDown(item.avg_change_pct) ? "down" : "up" : ""))
|
||||
}) : common_vendor.e({
|
||||
e: !item.isCurrentMonth
|
||||
}, !item.isCurrentMonth ? {} : common_vendor.e({
|
||||
f: common_vendor.t(item.day),
|
||||
g: index % 7 == 0 || index % 7 == 6 ? "#999999" : "#2A2A2A",
|
||||
h: index % 7 == 0 || index % 7 == 6
|
||||
}, index % 7 == 0 || index % 7 == 6 ? {} : {}, {
|
||||
i: common_vendor.n("date " + (item.avg_change_pct ? _ctx.getRateUpOrDown(item.avg_change_pct) ? "down" : "up" : ""))
|
||||
})), {
|
||||
j: index,
|
||||
k: common_vendor.o(($event) => $options.clickSelectDate(item), index)
|
||||
});
|
||||
})
|
||||
};
|
||||
}
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/components/LCCalendar/LCCalendar.js.map
|
||||
4
unpackage/dist/dev/mp-weixin/components/LCCalendar/LCCalendar.json
vendored
Normal file
4
unpackage/dist/dev/mp-weixin/components/LCCalendar/LCCalendar.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
1
unpackage/dist/dev/mp-weixin/components/LCCalendar/LCCalendar.wxml
vendored
Normal file
1
unpackage/dist/dev/mp-weixin/components/LCCalendar/LCCalendar.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view class="dateC"><view class="yearMonthC flex"><view class="btn" bindtap="{{b}}"><image class="icon" src="{{a}}" mode="widthFix"></image></view><view class="yearMonth flex1"><picker mode="date" fields="month" bindchange="{{e}}"><view style="display:flex;align-items:center;justify-content:center"><image style="width:26rpx;height:26rpx;margin-right:10rpx" src="{{c}}" mode="widthFix"></image><view style="color:#2B2B2B;font-size:32rpx;font-weight:bold">{{d}}</view></view></picker></view><view class="btn" bindtap="{{g}}"><image class="icon" src="{{f}}" mode="widthFix"></image></view></view><view style="display:grid;grid-template-columns:repeat(7, 1fr);gap:17rpx;margin:20rpx 0"><view wx:for="{{h}}" wx:for-item="item" wx:key="b" style="display:flex;align-items:center;justify-content:center;font-size:24rpx;color:#292621;font-weight:500">{{item.a}}</view></view><view class="monthDateList" style="display:grid;grid-template-columns:repeat(7, 1fr);gap:17rpx"><view wx:for="{{i}}" wx:for-item="item" wx:key="j" class="item" bindtap="{{item.k}}"><block wx:if="{{item.a}}"><view class="{{item.d}}">{{item.b}} <view wx:if="{{item.c}}" style="color:#999999;font-size:18rpx">休市 </view><view wx:else style="text-align:center"><view style="font-size:18rpx">66家</view><view style="font-size:16rpx">商业航天</view></view></view></block><block wx:else><block wx:if="{{item.e}}"></block><block wx:else><view class="{{item.i}}"><view style="{{'color:' + item.g}}">{{item.f}}</view><view wx:if="{{item.h}}" style="color:#999999;font-size:18rpx">休市 </view><view wx:else style="text-align:center"><view style="font-size:18rpx">66家</view><view style="font-size:16rpx">商业航天</view></view></view></block></block></view></view></view>
|
||||
75
unpackage/dist/dev/mp-weixin/components/LCCalendar/LCCalendar.wxss
vendored
Normal file
75
unpackage/dist/dev/mp-weixin/components/LCCalendar/LCCalendar.wxss
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
.dateC {
|
||||
background-color: white;
|
||||
box-shadow: 0 5rpx 10rpx 0 rgba(127, 127, 127, 0.1);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.dateC .yearMonthC {
|
||||
height: 70rpx;
|
||||
border-radius: 35rpx;
|
||||
}
|
||||
.dateC .yearMonthC .btn {
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
.dateC .yearMonthC .btn .icon {
|
||||
width: 13rpx;
|
||||
height: auto;
|
||||
}
|
||||
.dateC .yearMonthC .yearMonth {
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
color: #070707;
|
||||
text-align: center;
|
||||
}
|
||||
.dateC .weekList .item {
|
||||
line-height: 72rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: 500;
|
||||
color: #A7A7A7;
|
||||
text-align: center;
|
||||
}
|
||||
.dateC .monthDateList .item .date {
|
||||
background-color: #f8f8f8;
|
||||
padding: 10rpx 0;
|
||||
border-radius: 10rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
color: #2A2A2A;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
.dateC .monthDateList .item .date .chg {
|
||||
font-size: 18rpx;
|
||||
}
|
||||
.dateC .monthDateList .item .date .chg.up {
|
||||
color: #EC3440;
|
||||
}
|
||||
.dateC .monthDateList .item .date .chg.down {
|
||||
color: #38A169;
|
||||
}
|
||||
.dateC .monthDateList .item .date.up {
|
||||
background-color: #FFD6D9;
|
||||
}
|
||||
.dateC .monthDateList .item .date.down {
|
||||
background-color: #CEF1DE;
|
||||
}
|
||||
.dateC .monthDateList .item .date.select.up {
|
||||
background-color: #EC3440;
|
||||
color: white;
|
||||
}
|
||||
.dateC .monthDateList .item .date.select.up .chg {
|
||||
color: white;
|
||||
}
|
||||
.dateC .monthDateList .item .date.select.down {
|
||||
background-color: #38A169;
|
||||
color: white;
|
||||
}
|
||||
.dateC .monthDateList .item .date.select.down .chg {
|
||||
color: white;
|
||||
}
|
||||
.dateC .monthDateList .item .date.notCurrentMonth {
|
||||
background-color: #FCFCFC;
|
||||
color: #999;
|
||||
}
|
||||
Reference in New Issue
Block a user