2.4 组件结构调整,调整会员权限判断

This commit is contained in:
尚政杰
2026-02-04 17:43:41 +08:00
parent eeca65538c
commit 995ee7f220
274 changed files with 7191 additions and 2186 deletions

View File

@@ -20,8 +20,10 @@ const _sfc_main = {
//结束日期
selectYear: "",
Month: "",
calendarApiData: []
calendarApiData: [],
// 新增:存储接口返回的日历数据
selectedDateKey: ""
// 新增选中日期的唯一标识格式YYYY-MM-DD
};
},
created() {
@@ -70,8 +72,8 @@ const _sfc_main = {
};
},
/**
* 获取当天的item数据合并接口数据
*/
* 获取当天的item数据合并接口数据
*/
getTodayItem(year, month, day) {
const targetDate = `${year}-${month > 9 ? month : "0" + month}-${day > 9 ? day : "0" + day}`;
const currentMonthList = this.monthDateList[this.selectMonthIndex] || [];
@@ -88,30 +90,9 @@ const _sfc_main = {
// 示例:炸板率
};
},
/**
* 触发日期变更事件传递包含接口数据的item
*/
// emitDateChange(year, month, day, item) {
// const yearMonth = `${year}-${month > 9 ? month : '0' + month}`;
// const fullDate = `${year}-${month > 9 ? month : '0' + month}-${day > 9 ? day : '0' + day}`;
// this.$emit('date-change', {
// yearMonth,
// fullDate,
// item: item || { // 兜底无item时赋值空对象+默认值
// date: fullDate,
// year,
// month,
// day,
// zt_count: 0,
// top_sector: '-',
// zaban_rate: '0%'
// },
// year,
// month,
// day
// });
// },
emitDateChange(year, month, day, item, prevItem = { zt_count: 0 }) {
emitDateChange(year, month, day, item, prevItem = {
zt_count: 0
}) {
const yearMonth = `${year}-${month > 9 ? month : "0" + month}`;
const fullDate = `${year}-${month > 9 ? month : "0" + month}-${day > 9 ? day : "0" + day}`;
this.$emit("date-change", {
@@ -215,22 +196,14 @@ const _sfc_main = {
this.calendarApiData = res.data;
if (this.selectDateStr) {
const [year, month, day] = this.selectDateStr.split("-").map(Number);
this.emitDateChange(
year,
month,
day,
this.getTodayItem(year, month, day),
this.getPrevDayItem(year, month, day)
// 新增上一天数据
);
}
} else {
this.calendarApiData = [];
common_vendor.index.__f__("warn", "at components/LCCalendar/LCCalendar.vue:330", "日历接口返回数据格式异常", res);
common_vendor.index.__f__("warn", "at components/LCCalendar/LCCalendar.vue:316", "日历接口返回数据格式异常", res);
}
} catch (error) {
this.calendarApiData = [];
common_vendor.index.__f__("error", "at components/LCCalendar/LCCalendar.vue:334", "获取日历数据失败", error);
common_vendor.index.__f__("error", "at components/LCCalendar/LCCalendar.vue:320", "获取日历数据失败", error);
}
},
/**
@@ -328,6 +301,7 @@ const _sfc_main = {
*/
clickPreMonth() {
if (this.selectMonthIndex > 0) {
this.selectedDateKey = "";
this.selectMonthIndex--;
let monthList = this.monthDateList[this.selectMonthIndex];
let year = "";
@@ -351,8 +325,9 @@ const _sfc_main = {
this.endDateStr = year + "-" + (month > 9 ? month : "0" + month) + "-" + lastDay;
this.selectYear = year;
this.Month = month;
this.selectDateStr = this.startDateStr;
this.getCalendarCombinedData();
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:469", "点击上个月");
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:457", "点击上个月");
}
},
/**
@@ -360,6 +335,7 @@ const _sfc_main = {
*/
clickNextMonth() {
if (this.selectMonthIndex < this.monthDateList.length - 1) {
this.selectedDateKey = "";
this.selectMonthIndex++;
let monthList = this.monthDateList[this.selectMonthIndex];
let year = "";
@@ -381,12 +357,21 @@ const _sfc_main = {
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:498", "点击下个月");
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:489", "点击下个月");
this.selectYear = year;
this.Month = month;
this.selectDateStr = this.startDateStr;
this.getCalendarCombinedData();
}
},
/**
* 通用补零函数确保数字为两位数不足则前面补0
* @param {number|string} num - 需要补零的数字
* @returns {string} 补零后的字符串
*/
padZero(num) {
return String(num).padStart(2, "0");
},
monthChange(e) {
let currentDate = /* @__PURE__ */ new Date();
let currentYear = currentDate.getFullYear();
@@ -411,6 +396,7 @@ const _sfc_main = {
if (!item.isCurrentMonth)
return;
if (this.selectDateStr != item.date) {
this.selectedDateKey = item.date;
this.selectDateStr = item.date;
const apiData = this.getCalendarItemByDate(item.date) || {};
const mergedItem = {
@@ -451,36 +437,21 @@ const _sfc_main = {
this.chgStockData = mergedItem;
const [year, month, day] = item.date.split("-").map(Number);
this.emitDateChange(year, month, day, mergedItem, prevMergedItem);
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:580", "点击某天(含接口数据)", { current: mergedItem, prev: prevMergedItem });
common_vendor.index.__f__("log", "at components/LCCalendar/LCCalendar.vue:583", "点击某天(含接口数据)", {
current: mergedItem,
prev: prevMergedItem
});
}
}
// clickSelectDate(item, index) {
// if (!item.isCurrentMonth) return
// if (this.selectDateStr != item.date) {
// this.selectDateStr = item.date
// const apiData = this.getCalendarItemByDate(item.date) || {};
// const mergedItem = {
// ...item,
// zt_count: apiData.zt_count || 0,
// top_sector: apiData.top_sector || '-',
// zaban_rate: apiData.zaban_rate || '0%',
// isWeekend: index % 7 === 0 || index % 7 === 6
// };
// this.chgStockData = mergedItem;
// const [year, month, day] = item.date.split('-').map(Number);
// this.emitDateChange(year, month, day, mergedItem);
// uni.__f__('log','at components/LCCalendar/LCCalendar.vue:602','点击某天(含接口数据)', mergedItem);
// }
// }
}
};
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,
c: common_assets._imports_1$18,
d: common_vendor.t($data.selectDateStr),
e: common_assets._imports_1$2,
e: common_assets._imports_2$3,
f: common_vendor.o(($event) => $options.clickNextMonth()),
g: common_vendor.f($data.weekList, (item, index, i0) => {
return {
@@ -503,25 +474,27 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
g: common_vendor.t(((_e = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _e.top_sector) || "-"),
h: $options.getZtCountTextColor((_f = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _f.zt_count)
} : {}), {
i: common_vendor.n($options.getZtCountBgClass((_g = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _g.zt_count))
i: common_vendor.n($options.getZtCountBgClass((_g = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _g.zt_count)),
j: common_vendor.n($data.selectedDateKey === item.date ? "selected-border" : "")
}) : common_vendor.e({
j: !item.isCurrentMonth
k: !item.isCurrentMonth
}, !item.isCurrentMonth ? {} : common_vendor.e({
k: common_vendor.t(item.day),
l: index % 7 == 0 || index % 7 == 6 ? "#999999" : "#2A2A2A",
m: index % 7 == 0 || index % 7 == 6
l: common_vendor.t(item.day),
m: index % 7 == 0 || index % 7 == 6 ? "#999999" : "#2A2A2A",
n: index % 7 == 0 || index % 7 == 6
}, index % 7 == 0 || index % 7 == 6 ? {} : common_vendor.e({
n: ((_h = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _h.zt_count) > 0
o: ((_h = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _h.zt_count) > 0
}, ((_i = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _i.zt_count) > 0 ? {
o: common_vendor.t((_j = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _j.zt_count),
p: $options.getZtCountTextColor((_k = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _k.zt_count),
q: common_vendor.t(((_l = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _l.top_sector) || "-"),
r: $options.getZtCountTextColor((_m = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _m.zt_count)
p: common_vendor.t((_j = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _j.zt_count),
q: $options.getZtCountTextColor((_k = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _k.zt_count),
r: common_vendor.t(((_l = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _l.top_sector) || "-"),
s: $options.getZtCountTextColor((_m = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _m.zt_count)
} : {}), {
s: common_vendor.n($options.getZtCountBgClass((_n = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _n.zt_count))
t: common_vendor.n($options.getZtCountBgClass((_n = $options.getCalendarItemByDate(item.date)) == null ? void 0 : _n.zt_count)),
v: common_vendor.n($data.selectedDateKey === item.date ? "selected-border" : "")
})), {
t: index,
v: common_vendor.o(($event) => $options.clickSelectDate(item), index)
w: index,
x: common_vendor.o(($event) => $options.clickSelectDate(item, index), index)
});
})
};

View File

@@ -1 +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"><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="{{f}}"><image class="icon" src="{{e}}" mode="widthFix"></image></view></view><view style="display:grid;grid-template-columns:repeat(7, 1fr);gap:17rpx;margin:20rpx 0"><view wx:for="{{g}}" 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="{{h}}" wx:for-item="item" wx:key="t" class="item" bindtap="{{item.v}}"><block wx:if="{{item.a}}"><view class="{{['date', 'select', item.i]}}">{{item.b}} <view wx:if="{{item.c}}" style="color:#999999;font-size:18rpx">休市 </view><view wx:else style="text-align:center"><view wx:if="{{item.d}}"><view style="{{'font-size:18rpx' + ';' + ('color:' + item.f)}}">{{item.e}}家 </view><view style="{{'font-size:16rpx' + ';' + ('color:' + item.h)}}">{{item.g}}</view></view></view></view></block><block wx:else><block wx:if="{{item.j}}"></block><block wx:else><view class="{{['date', item.s]}}"><view style="{{'color:' + item.l}}">{{item.k}}</view><view wx:if="{{item.m}}" style="color:#999999;font-size:18rpx">休市 </view><view wx:else style="text-align:center"><view wx:if="{{item.n}}"><view style="{{'font-size:18rpx' + ';' + ('color:' + item.p)}}">{{item.o}}家 </view><view style="{{'font-size:16rpx' + ';' + ('color:' + item.r)}}">{{item.q}}</view></view></view></view></block></block></view></view></view>
<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"><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="{{f}}"><image class="icon" src="{{e}}" mode="widthFix"></image></view></view><view style="display:grid;grid-template-columns:repeat(7, 1fr);gap:17rpx;margin:20rpx 0"><view wx:for="{{g}}" 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="{{h}}" wx:for-item="item" wx:key="w" class="item" bindtap="{{item.x}}"><block wx:if="{{item.a}}"><view class="{{['date', 'select', item.i, item.j]}}">{{item.b}} <view wx:if="{{item.c}}" style="color:#999999;font-size:18rpx">休市 </view><view wx:else style="text-align:center"><view wx:if="{{item.d}}"><view style="{{'font-size:18rpx' + ';' + ('color:' + item.f)}}">{{item.e}}家 </view><view style="{{'font-size:16rpx' + ';' + ('color:' + item.h)}}">{{item.g}}</view></view></view></view></block><block wx:else><block wx:if="{{item.k}}"></block><block wx:else><view class="{{['date', item.t, item.v]}}"><view style="{{'color:' + item.m}}">{{item.l}}</view><view wx:if="{{item.n}}" style="color:#999999;font-size:18rpx">休市 </view><view wx:else style="text-align:center"><view wx:if="{{item.o}}"><view style="{{'font-size:18rpx' + ';' + ('color:' + item.q)}}">{{item.p}}家 </view><view style="{{'font-size:16rpx' + ';' + ('color:' + item.s)}}">{{item.r}}</view></view></view></view></block></block></view></view></view>

View File

@@ -49,6 +49,10 @@
.dateC .monthDateList .item .date .chg.down {
color: #38A169;
}
.dateC .monthDateList .item .date.selected-border {
border: 1px solid #FFCC00;
box-sizing: border-box;
}
.dateC .monthDateList .item .date.zt-bg-80 {
background-color: #FAEEFF;
}