feat(积分页面): 添加日期和搜索框的清除功能并优化时间显示
添加清除按钮到日期选择器和搜索框,方便用户重置输入 优化时间显示格式为 YYYY-MM-DD HHss 调整分页参数从每页10条改为5条
Showing
1 changed file
with
39 additions
and
11 deletions
| ... | @@ -39,29 +39,35 @@ | ... | @@ -39,29 +39,35 @@ |
| 39 | <div class="p-3 bg-white space-y-3"> | 39 | <div class="p-3 bg-white space-y-3"> |
| 40 | <!-- 日期选择 --> | 40 | <!-- 日期选择 --> |
| 41 | <div class="flex items-center justify-between space-x-2"> | 41 | <div class="flex items-center justify-between space-x-2"> |
| 42 | - <div class="flex-1 bg-white border border-gray-200 rounded-lg h-9 flex items-center px-3 cursor-pointer" | 42 | + <div class="flex-1 bg-white border border-gray-200 rounded-lg h-9 flex items-center px-3 cursor-pointer relative" |
| 43 | @click="showStartDatePicker = true"> | 43 | @click="showStartDatePicker = true"> |
| 44 | <van-icon name="calendar-o" class="text-gray-400 mr-2" /> | 44 | <van-icon name="calendar-o" class="text-gray-400 mr-2" /> |
| 45 | - <span :class="startDate ? 'text-gray-800' : 'text-gray-400'" class="text-sm truncate"> | 45 | + <span :class="startDate ? 'text-gray-800' : 'text-gray-400'" class="text-sm truncate pr-4"> |
| 46 | {{ startDate || '开始日期' }} | 46 | {{ startDate || '开始日期' }} |
| 47 | </span> | 47 | </span> |
| 48 | + <van-icon v-if="startDate" name="clear" class="text-gray-300 absolute right-2 z-10" | ||
| 49 | + @click.stop="clearStartDate" /> | ||
| 48 | </div> | 50 | </div> |
| 49 | <span class="text-gray-400 text-sm">至</span> | 51 | <span class="text-gray-400 text-sm">至</span> |
| 50 | - <div class="flex-1 bg-white border border-gray-200 rounded-lg h-9 flex items-center px-3 cursor-pointer" | 52 | + <div class="flex-1 bg-white border border-gray-200 rounded-lg h-9 flex items-center px-3 cursor-pointer relative" |
| 51 | @click="showEndDatePicker = true"> | 53 | @click="showEndDatePicker = true"> |
| 52 | <van-icon name="calendar-o" class="text-gray-400 mr-2" /> | 54 | <van-icon name="calendar-o" class="text-gray-400 mr-2" /> |
| 53 | - <span :class="endDate ? 'text-gray-800' : 'text-gray-400'" class="text-sm truncate"> | 55 | + <span :class="endDate ? 'text-gray-800' : 'text-gray-400'" class="text-sm truncate pr-4"> |
| 54 | {{ endDate || '结束日期' }} | 56 | {{ endDate || '结束日期' }} |
| 55 | </span> | 57 | </span> |
| 58 | + <van-icon v-if="endDate" name="clear" class="text-gray-300 absolute right-2 z-10" | ||
| 59 | + @click.stop="clearEndDate" /> | ||
| 56 | </div> | 60 | </div> |
| 57 | </div> | 61 | </div> |
| 58 | 62 | ||
| 59 | <!-- 搜索框 --> | 63 | <!-- 搜索框 --> |
| 60 | - <div class="bg-white border border-gray-200 rounded-lg h-9 flex items-center px-3"> | 64 | + <div class="bg-white border border-gray-200 rounded-lg h-9 flex items-center px-3 relative"> |
| 61 | <van-icon name="search" class="text-gray-400 mr-2" size="16" /> | 65 | <van-icon name="search" class="text-gray-400 mr-2" size="16" /> |
| 62 | <input v-model="searchKeyword" type="text" placeholder="搜索活动或课程名称" | 66 | <input v-model="searchKeyword" type="text" placeholder="搜索活动或课程名称" |
| 63 | - class="flex-1 bg-transparent text-sm text-gray-800 placeholder-gray-400 outline-none" | 67 | + class="flex-1 bg-transparent text-sm text-gray-800 placeholder-gray-400 outline-none pr-6" |
| 64 | - @keyup.enter="onRefresh" /> | 68 | + @keyup.enter="onRefresh" @blur="onRefresh" /> |
| 69 | + <van-icon v-if="searchKeyword" name="clear" class="text-gray-300 absolute right-2 z-10" | ||
| 70 | + @click="clearSearch" /> | ||
| 65 | </div> | 71 | </div> |
| 66 | </div> | 72 | </div> |
| 67 | </div> | 73 | </div> |
| ... | @@ -76,7 +82,7 @@ | ... | @@ -76,7 +82,7 @@ |
| 76 | </div> | 82 | </div> |
| 77 | <div class="flex justify-between items-center"> | 83 | <div class="flex justify-between items-center"> |
| 78 | <div class="flex flex-col"> | 84 | <div class="flex flex-col"> |
| 79 | - <span class="text-gray-400 text-xs mb-1">{{ item.event_time }}</span> | 85 | + <span class="text-gray-400 text-xs mb-1">{{ formatTime(item.event_time) }}</span> |
| 80 | <span class="text-gray-400 text-xs">{{ item.event_type_desc }}</span> | 86 | <span class="text-gray-400 text-xs">{{ item.event_type_desc }}</span> |
| 81 | </div> | 87 | </div> |
| 82 | <div class="text-lg font-bold" | 88 | <div class="text-lg font-bold" |
| ... | @@ -117,6 +123,11 @@ const headerBg = 'https://cdn.ipadbiz.cn/mlaj/recall/img/962@2x.png' | ... | @@ -117,6 +123,11 @@ const headerBg = 'https://cdn.ipadbiz.cn/mlaj/recall/img/962@2x.png' |
| 117 | const bottleImg = 'https://cdn.ipadbiz.cn/mlaj/recall/img/pz02@2x.png' | 123 | const bottleImg = 'https://cdn.ipadbiz.cn/mlaj/recall/img/pz02@2x.png' |
| 118 | const indicatorImg = 'https://cdn.ipadbiz.cn/mlaj/recall/img/xian@2x.png' | 124 | const indicatorImg = 'https://cdn.ipadbiz.cn/mlaj/recall/img/xian@2x.png' |
| 119 | 125 | ||
| 126 | +const formatTime = (time) => { | ||
| 127 | + if (!time) return '' | ||
| 128 | + return dayjs(time).format('YYYY-MM-DD HH:mm:ss') | ||
| 129 | +} | ||
| 130 | + | ||
| 120 | useTitle('我的积分') | 131 | useTitle('我的积分') |
| 121 | const route = useRoute() | 132 | const route = useRoute() |
| 122 | const router = useRouter() | 133 | const router = useRouter() |
| ... | @@ -141,8 +152,8 @@ const list = ref([]) | ... | @@ -141,8 +152,8 @@ const list = ref([]) |
| 141 | const loading = ref(false) | 152 | const loading = ref(false) |
| 142 | const finished = ref(false) | 153 | const finished = ref(false) |
| 143 | const refreshing = ref(false) | 154 | const refreshing = ref(false) |
| 144 | -const page = ref(0) | 155 | +const page = ref(-1) |
| 145 | -const limit = ref(10) | 156 | +const limit = ref(5) |
| 146 | const balance = ref('0') | 157 | const balance = ref('0') |
| 147 | 158 | ||
| 148 | // 切换Tab | 159 | // 切换Tab |
| ... | @@ -174,6 +185,23 @@ const onConfirmEndDate = ({ selectedValues }) => { | ... | @@ -174,6 +185,23 @@ const onConfirmEndDate = ({ selectedValues }) => { |
| 174 | onRefresh() | 185 | onRefresh() |
| 175 | } | 186 | } |
| 176 | 187 | ||
| 188 | +// 清除日期 | ||
| 189 | +const clearStartDate = () => { | ||
| 190 | + startDate.value = '' | ||
| 191 | + onRefresh() | ||
| 192 | +} | ||
| 193 | + | ||
| 194 | +const clearEndDate = () => { | ||
| 195 | + endDate.value = '' | ||
| 196 | + onRefresh() | ||
| 197 | +} | ||
| 198 | + | ||
| 199 | +// 清除搜索 | ||
| 200 | +const clearSearch = () => { | ||
| 201 | + searchKeyword.value = '' | ||
| 202 | + onRefresh() | ||
| 203 | +} | ||
| 204 | + | ||
| 177 | // 加载列表 | 205 | // 加载列表 |
| 178 | const onLoad = async () => { | 206 | const onLoad = async () => { |
| 179 | const nextPage = page.value + 1 | 207 | const nextPage = page.value + 1 |
| ... | @@ -227,7 +255,7 @@ const onLoad = async () => { | ... | @@ -227,7 +255,7 @@ const onLoad = async () => { |
| 227 | const onRefresh = () => { | 255 | const onRefresh = () => { |
| 228 | finished.value = false | 256 | finished.value = false |
| 229 | loading.value = true | 257 | loading.value = true |
| 230 | - page.value = 0 | 258 | + page.value = -1 |
| 231 | refreshing.value = true | 259 | refreshing.value = true |
| 232 | onLoad() | 260 | onLoad() |
| 233 | } | 261 | } | ... | ... |
-
Please register or login to post a comment