Commit 90439cec authored by wxf's avatar wxf

feat: 调整字段名称,默认当前选中

parent 0d1ba467
......@@ -179,7 +179,7 @@
@click="handleDateItemClick(item)"
:class="{
'date-item-active': item.is_selected,
'date-item-disabled': item.is_open == 0,
'date-item-disabled': item.isOpen == 0,
}"
>
<view class="date-item-week">{{ item.week }}</view>
......@@ -195,12 +195,12 @@
@click="handleTimeItemClick(item)"
:class="{
'time-item-active': item.is_selected,
'time-item-disabled': item.is_open == 0,
'time-item-disabled': item.isOpen == 0,
}"
>
<view class="time-item-day" style="text-align: center">
<view>{{ item.time }}</view>
<view v-if="item.is_open == 0">{{ item.status }}</view>
<view v-if="item.isOpen == 0">{{ item.status }}</view>
</view>
</view>
</view>
......@@ -352,6 +352,8 @@ onMounted(async () => {
dateList.value = res.data.map((item, index) => ({
...item,
dayStr: formatDate(item.day),
// 如果日期是今天,则设置为选中
is_selected: item.day == formatDateCompare(),
}))
// 如果dateList 有值,则默认查询第一条数据的timeList
if (dateList.value.length > 0) {
......@@ -359,6 +361,18 @@ onMounted(async () => {
}
})
})
/**
* 时间格式化
* @param date 默认当前时间
*/
const formatDateCompare = (date = new Date()) => {
const y = date.getFullYear()
const m =
date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
const d = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
return `${y}-${m}-${d}`
}
/**
* 获取到访时间
* @param day 到访日期 2025-07-11
......@@ -494,7 +508,7 @@ const formatDate = (date) => {
* @param item 到访日期对象
*/
const handleDateItemClick = (item) => {
if (item.is_selected || item.is_open == 0) return
if (item.is_selected || item.isOpen == 0) return
dateList.value.forEach((item) => {
item.is_selected = false
})
......@@ -508,7 +522,7 @@ const handleDateItemClick = (item) => {
* @param item 到访时间对象
*/
const handleTimeItemClick = (item) => {
if (item.is_selected || item.is_open == 0) return
if (item.is_selected || item.isOpen == 0) return
timeList.value.forEach((item) => {
item.is_selected = false
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment