From 49dbce22d17d8fa13eed021bc073b9fa553488fe Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 28 Apr 2025 23:30:24 +0800 Subject: [PATCH] =?UTF-8?q?reactor=EF=BC=9A=E5=B0=86=20getWeekTimes?= =?UTF-8?q?=E3=80=81getMonthTimes=20=E6=8A=BD=E5=88=B0=20utils=20=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E5=A4=8D=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/commission/commission-ranking.vue | 35 +----------------------- pages/commission/promoter.vue | 36 +------------------------ sheep/helper/utils.js | 25 +++++++++++++++++ sheep/util/index.js | 0 4 files changed, 27 insertions(+), 69 deletions(-) delete mode 100644 sheep/util/index.js diff --git a/pages/commission/commission-ranking.vue b/pages/commission/commission-ranking.vue index 6a250167..50fc76fe 100644 --- a/pages/commission/commission-ranking.vue +++ b/pages/commission/commission-ranking.vue @@ -60,7 +60,7 @@ import BrokerageApi from '@/sheep/api/trade/brokerage'; import { fen2yuan } from '@/sheep/hooks/useGoods'; import _ from 'lodash-es'; - import { resetPagination } from '@/sheep/helper/utils'; + import { resetPagination, getWeekTimes, getMonthTimes } from '@/sheep/helper/utils'; const tabMaps = ['周排行', '月排行']; @@ -130,39 +130,6 @@ getBrokerageRankList(); }); - // TODO 芋艿:此处可考虑抽离 - /** - * 获得当前周的开始和结束时间 - */ - function getWeekTimes() { - const today = new Date(); - const dayOfWeek = today.getDay(); - return [ - new Date(today.getFullYear(), today.getMonth(), today.getDate() - dayOfWeek, 0, 0, 0), - new Date( - today.getFullYear(), - today.getMonth(), - today.getDate() + (6 - dayOfWeek), - 23, - 59, - 59, - ), - ]; - } - - /** - * 获得当前月的开始和结束时间 - */ - function getMonthTimes() { - const today = new Date(); - const year = today.getFullYear(); - const month = today.getMonth(); - const startDate = new Date(year, month, 1, 0, 0, 0); - const nextMonth = new Date(year, month + 1, 1); - const endDate = new Date(nextMonth.getTime() - 1); - return [startDate, endDate]; - } - // 加载更多 function loadMore() { if (state.loadStatus === 'noMore') { diff --git a/pages/commission/promoter.vue b/pages/commission/promoter.vue index 486908f7..2dfcc2b3 100644 --- a/pages/commission/promoter.vue +++ b/pages/commission/promoter.vue @@ -55,8 +55,8 @@ import { onLoad, onReachBottom } from '@dcloudio/uni-app'; import { reactive } from 'vue'; import _ from 'lodash-es'; - import { resetPagination } from '@/sheep/helper/utils'; import BrokerageApi from '@/sheep/api/trade/brokerage'; + import { resetPagination, getWeekTimes, getMonthTimes } from '@/sheep/helper/utils'; const tabMaps = ['周排行', '月排行']; @@ -129,40 +129,6 @@ function formatDate(date) { return sheep.$helper.timeFormat(date, 'yyyy-mm-dd hh:MM:ss'); } - - // TODO 芋艿:此处可考虑抽离 - // 此处可考虑抽离 - /** - * 获得当前周的开始和结束时间 - */ - function getWeekTimes() { - const today = new Date(); - const dayOfWeek = today.getDay(); - return [ - new Date(today.getFullYear(), today.getMonth(), today.getDate() - dayOfWeek, 0, 0, 0), - new Date( - today.getFullYear(), - today.getMonth(), - today.getDate() + (6 - dayOfWeek), - 23, - 59, - 59, - ), - ]; - } - - /** - * 获得当前月的开始和结束时间 - */ - function getMonthTimes() { - const today = new Date(); - const year = today.getFullYear(); - const month = today.getMonth(); - const startDate = new Date(year, month, 1, 0, 0, 0); - const nextMonth = new Date(year, month + 1, 1); - const endDate = new Date(nextMonth.getTime() - 1); - return [startDate, endDate]; - }