Commit ffe0e8d1 by Lin

Merge branch 'saas+v5.8.3' of http://192.168.3.233:8090/glsx/gl_tape into saas+v5.8.3

2 parents 19857bb6 f83300e2
...@@ -22,35 +22,15 @@ ...@@ -22,35 +22,15 @@
</view> </view>
<view class="filter-row"> <view class="filter-row">
<input <input class="filter-input" v-model="keyword" placeholder="关键字过滤,如 StoragePathMerge / PathUtils" confirm-type="search" />
class="filter-input"
v-model="keyword"
placeholder="关键字过滤,如 StoragePathMerge / PathUtils"
confirm-type="search"
/>
</view> </view>
<view class="level-row"> <view class="level-row">
<text <text v-for="lv in levelOptions" :key="lv.value" :class="['level-chip', { active: levelFilter === lv.value }]" @tap="levelFilter = lv.value">{{ lv.label }}</text>
v-for="lv in levelOptions"
:key="lv.value"
:class="['level-chip', { active: levelFilter === lv.value }]"
@tap="levelFilter = lv.value"
>{{ lv.label }}</text>
</view> </view>
<scroll-view <scroll-view class="log-scroll" scroll-y :scroll-into-view="scrollIntoView" :scroll-with-animation="false">
class="log-scroll" <view v-for="item in displayLines" :key="item.id" :id="'log-' + item.id" :class="['log-line', 'level-' + item.level]">
scroll-y
:scroll-into-view="scrollIntoView"
:scroll-with-animation="false"
>
<view
v-for="item in displayLines"
:key="item.id"
:id="'log-' + item.id"
:class="['log-line', 'level-' + item.level]"
>
<text class="log-time">{{ item.time }}</text> <text class="log-time">{{ item.time }}</text>
<text class="log-tag">[{{ item.level }}]</text> <text class="log-tag">[{{ item.level }}]</text>
<text class="log-text">{{ item.text }}</text> <text class="log-text">{{ item.text }}</text>
...@@ -59,12 +39,7 @@ ...@@ -59,12 +39,7 @@
</scroll-view> </scroll-view>
<view class="tag-row"> <view class="tag-row">
<text <text v-for="tag in quickTags" :key="tag.label" :class="['tag-chip', { active: keyword === tag.value }]" @tap="setKeyword(tag.value)">{{ tag.label }}</text>
v-for="tag in quickTags"
:key="tag.label"
:class="['tag-chip', { active: keyword === tag.value }]"
@tap="setKeyword(tag.value)"
>{{ tag.label }}</text>
</view> </view>
</view> </view>
</view> </view>
...@@ -252,9 +227,7 @@ export default { ...@@ -252,9 +227,7 @@ export default {
}, },
onCopy() { onCopy() {
const kw = (this.keyword || '').trim() const kw = (this.keyword || '').trim()
let list = this._isMergeKeyword(kw) let list = this._isMergeKeyword(kw) ? [...loadPersistedMergeLogs(), ...FloatLogBus.getMergeLines()] : FloatLogBus.getLines()
? [...loadPersistedMergeLogs(), ...FloatLogBus.getMergeLines()]
: FloatLogBus.getLines()
if (this.levelFilter !== 'all') { if (this.levelFilter !== 'all') {
list = list.filter(l => l.level === this.levelFilter) list = list.filter(l => l.level === this.levelFilter)
} }
...@@ -262,9 +235,7 @@ export default { ...@@ -262,9 +235,7 @@ export default {
if (kw && !this._isMergeKeyword(kw)) { if (kw && !this._isMergeKeyword(kw)) {
list = list.filter(l => l.text.toLowerCase().includes(kwLower)) list = list.filter(l => l.text.toLowerCase().includes(kwLower))
} }
const text = list const text = list.map(l => `${l.time} [${l.level}] ${l.text}`).join('\n')
.map(l => `${l.time} [${l.level}] ${l.text}`)
.join('\n')
if (!text) { if (!text) {
uni.showToast({ title: '无内容', icon: 'none' }) uni.showToast({ title: '无内容', icon: 'none' })
return return
...@@ -310,7 +281,7 @@ export default { ...@@ -310,7 +281,7 @@ export default {
.float-log-fab { .float-log-fab {
position: fixed; position: fixed;
right: 24rpx; right: 24rpx;
bottom: 120rpx; bottom: 20rpx;
width: 120rpx; width: 120rpx;
height: 120rpx; height: 120rpx;
z-index: 99999; z-index: 99999;
......
<template> <template>
<view class="date-list"> <view v-if="ready && days.length" class="date-list">
<picker-view class="picker picker_max" :value="dateValues" indicator-class="indicator" @change="changeDate"> <picker-view class="picker picker_max" :value="dateValues" indicator-class="indicator" @change="changeDate">
<picker-view-column> <picker-view-column>
<template v-for="(item, index) in days"> <template v-for="(item, index) in days">
...@@ -29,158 +29,155 @@ import dayjs from 'dayjs' ...@@ -29,158 +29,155 @@ import dayjs from 'dayjs'
export default { export default {
name: 'DateTime', name: 'DateTime',
inject: ['userInfo'], inject: ['userInfo'],
props: {
defaultTime: {
type: String,
default: ''
}
},
data () { data () {
return { return {
hours: [], hours: [],
days: [], days: [],
minutes: [], minutes: [],
dateValues: [], dateValues: [0],
hourValues: [], hourValues: [0],
minuteValues: [], minuteValues: [0],
loading: true ready: false,
currentDate: '',
currentHour: '',
currentMinute: ''
} }
}, },
props: {
},
mounted () {
this.initDate()
},
methods: { methods: {
initDate () { getList () {
this.dateValues = [] this.ready = false
this.hourValues = [] this.initDate()
this.minuteValues = []
const today = new Date()
this.getDateList('2019/01/01', new Date(today.getFullYear(), today.getMonth(), today.getDate()))
}, },
getDateList (starDay, endDay) { buildDayList () {
const arr = []; const days = []
const dates = []; const start = dayjs('2019-01-01').startOf('day')
const end = dayjs().startOf('day')
// 设置两个日期UTC时间 let cur = start
const db = new Date(starDay); while (cur.isBefore(end) || cur.isSame(end, 'day')) {
const de = new Date(endDay); days.push(cur.format('YYYY/MM/DD'))
// 获取两个日期GTM时间 cur = cur.add(1, 'day')
const s = db.getTime() - 24 * 60 * 60 * 1000;
const d = de.getTime() - 24 * 60 * 60 * 1000;
// 获取到两个日期之间的每一天的毫秒数
for (let i = s; i <= d;) {
i = i + 24 * 60 * 60 * 1000;
arr.push(parseInt(String(i)));
}
// 获取每一天的时间 YY-MM-DD
for (const j in arr) {
const time = new Date(arr[j]);
const year = time.getFullYear();
const mouth = time.getMonth() + 1 >= 10 ? time.getMonth() + 1 : '0' + (time.getMonth() + 1);
const day = time.getDate() >= 10 ? time.getDate() : '0' + time.getDate();
const YYMMDD = year + '/' + mouth + '/' + day;
dates.push(YYMMDD);
} }
this.getHourList(dates) return days
},
buildHourList (isToday) {
const len = isToday ? dayjs().hour() + 1 : 24
return Array.from({ length: len }, (_, i) => String(i).padStart(2, '0'))
},
buildMinuteList (isToday, hour) {
const now = dayjs()
const isCurrentHour = isToday && hour === now.format('HH')
const len = isCurrentHour ? now.minute() + 1 : 60
return Array.from({ length: len }, (_, i) => String(i).padStart(2, '0'))
}, },
getHourList (days) { pickIndex (list, value, fallbackLast) {
const hours = [], today = new Date(); const index = list.indexOf(value)
for (let hour = 0; hour < today.getHours() + 1; hour++) { if (index >= 0) return index
hours.push(hour.toString().padStart(2, '0')); return fallbackLast ? Math.max(list.length - 1, 0) : 0
},
applyPickerValues (dateValues, hourValues, minuteValues) {
this.$nextTick(() => {
this.dateValues = dateValues
this.hourValues = hourValues
this.minuteValues = minuteValues
this.ready = true
this.$emit('onComplete')
})
},
initDate () {
const days = this.buildDayList()
if (!days.length) {
this.days = []
this.hours = []
this.minutes = []
this.ready = false
this.$emit('onComplete')
return
} }
this.getMinuteList(days, hours) const today = dayjs()
}, const todayStr = today.format('YYYY/MM/DD')
getMinuteList (days, hours) { let currentDate = todayStr
const minutes = []; let currentHour = today.format('HH')
const today = new Date() let currentMinute = today.format('mm')
for (let minute = 0; minute < today.getMinutes() + 1; minute++) {
minutes.push(minute.toString().padStart(2, '0')); if (this.defaultTime) {
const parsed = dayjs(this.defaultTime.replace(/-/g, '/'))
if (parsed.isValid()) {
currentDate = parsed.format('YYYY/MM/DD')
currentHour = parsed.format('HH')
currentMinute = parsed.format('mm')
}
} }
// 设置默认时间
let { dateValues, hourValues, minuteValues } = this
const HOUR_STR = today.getHours().toString().padStart(2, '0')
const MUNTUE_STR = today.getMinutes().toString().padStart(2, '0')
// const defalutHIndex = hours.indexOf(HOUR_STR)
// const defalutMIndex = minutes.indexOf(MUNTUE_STR)
dateValues.push(days.length + 1)
hourValues.push(hours.length + 1)
minuteValues.push(minutes.length + 1)
this.currentDate = dayjs().format('YYYY/MM/DD')
this.currentHour = HOUR_STR
this.currentMinute = MUNTUE_STR
this.hours = hours const isToday = currentDate === todayStr
const hours = this.buildHourList(isToday)
const minutes = this.buildMinuteList(isToday, currentHour)
if (!hours.includes(currentHour)) currentHour = hours[hours.length - 1]
if (!minutes.includes(currentMinute)) currentMinute = minutes[minutes.length - 1]
this.currentDate = currentDate
this.currentHour = currentHour
this.currentMinute = currentMinute
this.days = days this.days = days
this.hours = hours
this.minutes = minutes this.minutes = minutes
this.dateValues = dateValues
this.hourValues = hourValues
this.minuteValues = minuteValues
this.loading = false
setTimeout(() => {
this.minuteValues = minuteValues
this.loading = false
}, 100)
this.$emit('onComplete')
},
changeDate (e) {
const { days } = this
const { value } = e.detail
const index = value[0]
console.log( days[index],days,index)
this.currentDate = days[index]
// 选择过去时间需要重新初始化时分
const today = dayjs().format('YYYY/MM/DD')
const timeType = this.currentDate != today ? 1 : 0
this.getAllTimeOrPartTime(timeType)
},
changeHour (e) {
const { hours, days, dateValues } = this
const { value } = e.detail
const index = value[0]
this.currentHour = hours[index]
// 处理当前天切换别的小时,别的分不能选后面分到60的问题 this.applyPickerValues(
// const dayIndex = dateValues[0] [this.pickIndex(days, currentDate, true)],
// this.currentDate = days[dayIndex] [this.pickIndex(hours, currentHour, true)],
const today = dayjs().format('YYYY/MM/DD') [this.pickIndex(minutes, currentMinute, true)]
const timeType = this.currentDate != today ? 1 : 0 )
this.getAllTimeOrPartTimeMinute(timeType)
}, },
changeMinutes (e) { changeDate (e) {
const { minutes } = this const index = e.detail.value[0]
const { value } = e.detail const date = this.days[index]
const index = value[0] if (!date) return
this.currentMinute = minutes[index] this.currentDate = date
}, const isToday = this.currentDate === dayjs().format('YYYY/MM/DD')
getAllTimeOrPartTime (type) { this.hours = this.buildHourList(isToday)
const today = new Date() if (!this.hours.includes(this.currentHour)) {
const hours = [], minutes = [], hour_len = type == 1 ? 24 : today.getHours() + 1, minute_len = type == 1 ? 60 : today.getMinutes() + 1; this.currentHour = this.hours[this.hours.length - 1]
for (let hour = 0; hour < hour_len; hour++) {
hours.push(hour.toString().padStart(2, '0'));
}
for (let minute = 0; minute < minute_len; minute++) {
minutes.push(minute.toString().padStart(2, '0'));
} }
this.hours = hours const minutes = this.buildMinuteList(isToday, this.currentHour)
this.minutes = minutes this.minutes = minutes
if (!this.minutes.includes(this.currentMinute)) {
this.currentMinute = this.minutes[this.minutes.length - 1]
}
this.$nextTick(() => {
this.hourValues = [this.pickIndex(this.hours, this.currentHour, true)]
this.minuteValues = [this.pickIndex(this.minutes, this.currentMinute, true)]
})
}, },
getAllTimeOrPartTimeMinute (type) { changeHour (e) {
const today = new Date() const index = e.detail.value[0]
const currentHour = today.getHours() const hour = this.hours[index]
const timeType = this.currentHour != currentHour ? 1 : 0 if (hour == null) return
const minutes = [], minute_len = type == 1 || timeType == 1 ? 60 : today.getMinutes() + 1; this.currentHour = hour
for (let minute = 0; minute < minute_len; minute++) { const isToday = this.currentDate === dayjs().format('YYYY/MM/DD')
minutes.push(minute.toString().padStart(2, '0')); this.minutes = this.buildMinuteList(isToday, this.currentHour)
if (!this.minutes.includes(this.currentMinute)) {
this.currentMinute = this.minutes[this.minutes.length - 1]
} }
this.minutes = minutes this.$nextTick(() => {
this.minuteValues = [this.pickIndex(this.minutes, this.currentMinute, true)]
})
},
changeMinutes (e) {
const index = e.detail.value[0]
const minute = this.minutes[index]
if (minute == null) return
this.currentMinute = minute
}, },
getResult () { getResult () {
console.log(this.currentDate,this.currentHour,this.currentMinute) const str = `${this.currentDate} ${this.currentHour}:${this.currentMinute}:00`
let str = '' return dayjs(str.replace(/-/g, '/')).format('YYYY/MM/DD HH:mm:ss')
str = this.currentDate + ' ' + this.currentHour + ':' + this.currentMinute + ":00"
const result = dayjs(str).format('YYYY/MM/DD HH:mm:ss')
return result
} }
} }
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</template> </template>
<view v-if="componentObject[popupType]" :class="['popup-body', { 'hide-footer': componentObject[popupType].hideFooter }, { 'hide-search': componentObject[popupType].hideSearch }, { 'hide-footer-search': componentObject[popupType].hideFooter && componentObject[popupType].hideSearch }]"> <view v-if="componentObject[popupType]" :class="['popup-body', { 'hide-footer': componentObject[popupType].hideFooter }, { 'hide-search': componentObject[popupType].hideSearch }, { 'hide-footer-search': componentObject[popupType].hideFooter && componentObject[popupType].hideSearch }]">
<scroll-view scroll-y :class="['popup-scroll-view', { show: componentObject[popupType].loadComplete }]"> <scroll-view scroll-y :class="['popup-scroll-view', { show: componentObject[popupType].loadComplete }]">
<component :is="componentObject[popupType].name" :params.sync="componentObject[popupType]" :data="data" :dataKey="dataKey" :isDefeatOrder="isDefeatOrder" :defaultTime="defaultTime" :positionTypeList="positionTypeList" :show-marketing-icon="showMarketingIcon" :boutique-order-types-only="boutiqueOrderTypesOnly" ref="componentRef" @choose="chooseContent = $event" @openSkuPopup="openSkuPopup" @onComplete="componentObject[popupType].loadComplete = true" @confirm="confirm"></component> <component :is="componentObject[popupType].name" :params.sync="componentObject[popupType]" :data="data" :dataKey="dataKey" :isDefeatOrder="isDefeatOrder" :defaultTime="datePickerDefaultTime" :positionTypeList="positionTypeList" :show-marketing-icon="showMarketingIcon" :boutique-order-types-only="boutiqueOrderTypesOnly" ref="componentRef" @choose="chooseContent = $event" @openSkuPopup="openSkuPopup" @onComplete="componentObject[popupType].loadComplete = true" @confirm="confirm"></component>
<template v-if="componentObject[popupType].noData"> <template v-if="componentObject[popupType].noData">
<view class="nothing flex">暂无数据</view> <view class="nothing flex">暂无数据</view>
</template> </template>
...@@ -171,6 +171,11 @@ export default { ...@@ -171,6 +171,11 @@ export default {
const { sceneType } = uni.$storage.get('userInfo') const { sceneType } = uni.$storage.get('userInfo')
return sceneType return sceneType
}, },
datePickerDefaultTime () {
if (this.defaultTime) return this.defaultTime
const data = this.data || {}
return data.pay2Time || data.successDate || ''
}
}, },
mounted () { mounted () {
}, },
...@@ -187,6 +192,9 @@ export default { ...@@ -187,6 +192,9 @@ export default {
}) })
}, },
open () { open () {
if (this.componentObject[this.popupType]) {
this.componentObject[this.popupType].loadComplete = false
}
this.$refs.popup.open() this.$refs.popup.open()
// 等待当前 tick 的响应式 watcher(如 externalData → cacheData)执行完再初始化 // 等待当前 tick 的响应式 watcher(如 externalData → cacheData)执行完再初始化
this.$nextTick(() => { this.$nextTick(() => {
......
...@@ -392,11 +392,15 @@ export default { ...@@ -392,11 +392,15 @@ export default {
total_price += Number(item.finalPrice) || 0 total_price += Number(item.finalPrice) || 0
}) })
const raw = data
const customer = raw.customer || {}
data = { data = {
...data.customer, ...customer,
...data.payOrder, ...raw.payOrder,
...data, ...raw,
packageGoodsList: data.packageGoodsList, customerPhone: customer.customerPhone || raw.customerPhone,
customerName: customer.customerName || raw.customerName,
packageGoodsList: raw.packageGoodsList,
couponName, couponName,
total_price: Number(utils.decimal(total_price, 2)).toFixed(2) total_price: Number(utils.decimal(total_price, 2)).toFixed(2)
} }
......
...@@ -66,10 +66,7 @@ ...@@ -66,10 +66,7 @@
<view class="meal-box" v-for="(item, index) in orderInfo.packageGoodsList"> <view class="meal-box" v-for="(item, index) in orderInfo.packageGoodsList">
<view class="meal-hd flex justify-between align-center"> <view class="meal-hd flex justify-between align-center">
<view class="meal-hd-name flex align-center"> <view class="meal-hd-name flex align-center">
<view <view v-if="shouldShowMarketingIcon(item)" class="sprite-icon icon-activeIcon marketing-icon"></view>
v-if="shouldShowMarketingIcon(item)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<view>{{ item.packageAlias || item.packageName }}</view> <view>{{ item.packageAlias || item.packageName }}</view>
</view> </view>
<view class="price">¥{{ item.finalPrice }}</view> <view class="price">¥{{ item.finalPrice }}</view>
...@@ -94,10 +91,7 @@ ...@@ -94,10 +91,7 @@
<view class="good" v-for="(item, index) in orderInfo.subOrderList" :key="index"> <view class="good" v-for="(item, index) in orderInfo.subOrderList" :key="index">
<view class="flex justify-between align-center mb-20"> <view class="flex justify-between align-center mb-20">
<view class="good-name flex align-center"> <view class="good-name flex align-center">
<view <view v-if="shouldShowMarketingIcon(item)" class="sprite-icon icon-activeIcon marketing-icon"></view>
v-if="shouldShowMarketingIcon(item)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<text class="good-name-text text-hide">商品名称:{{ replaceItemText(item.upgradeGoodsName) || '' }}</text> <text class="good-name-text text-hide">商品名称:{{ replaceItemText(item.upgradeGoodsName) || '' }}</text>
</view> </view>
<text class="good-price">¥{{ item.finalPrice }}</text> <text class="good-price">¥{{ item.finalPrice }}</text>
...@@ -357,12 +351,7 @@ export default { ...@@ -357,12 +351,7 @@ export default {
const rejected = { status: '驳回', statusColor: '#f56c6c' } const rejected = { status: '驳回', statusColor: '#f56c6c' }
return [ return [
{ {
name: '区域经理', name: '运营',
value: '1',
...(status === 1 ? pending : [2, 3, 4].includes(status) ? approved : empty)
},
{
name: '线上运营',
value: '2', value: '2',
...(status === 1 ? empty : status === 2 ? pending : status === 3 ? approved : status === 4 ? rejected : empty) ...(status === 1 ? empty : status === 2 ? pending : status === 3 ? approved : status === 4 ? rejected : empty)
} }
...@@ -491,13 +480,18 @@ export default { ...@@ -491,13 +480,18 @@ export default {
}) })
} }
const raw = data
const customer = raw.customer || {}
data = { data = {
...data.customer, ...customer,
...data.payOrder, ...raw.payOrder,
...data, ...raw,
packageGoodsList: data.packageGoodsList, // 根级 customerPhone 常为 null,会覆盖 customer 内真实手机号
customerPhone: customer.customerPhone || raw.customerPhone,
customerName: customer.customerName || raw.customerName,
packageGoodsList: raw.packageGoodsList,
couponName, couponName,
total_price: data.selectPayType == 0 ? 0 : Number(utils.decimal(total_price, 2)).toFixed(2) total_price: raw.selectPayType == 0 ? 0 : Number(utils.decimal(total_price, 2)).toFixed(2)
} }
if (data.customerCoupon) { if (data.customerCoupon) {
data.customerCoupon.customerCouponCode = data.customerCoupon.customerCouponCode.split('-')[0] data.customerCoupon.customerCouponCode = data.customerCoupon.customerCouponCode.split('-')[0]
...@@ -584,11 +578,15 @@ export default { ...@@ -584,11 +578,15 @@ export default {
}, },
getWorkWechatLiveQRCode() { getWorkWechatLiveQRCode() {
this.customerService = '' this.customerService = ''
let { failCustomerService, defaultCustomerService } = this const { failCustomerService, defaultCustomerService, orderInfo } = this
let { orderCode, customerPhone: phoneNumber, selectPayType } = this.orderInfo const { orderCode, selectPayType } = orderInfo
// console.log(orderCode, phoneNumber, selectPayType) const phoneNumber = orderInfo.customerPhone || orderInfo.customer?.customerPhone
// 订单状态 1-升级订单 2-战败订单 // 订单状态 1-升级订单 2-战败订单
let orderType = selectPayType == 0 ? 2 : 1 const orderType = selectPayType == 0 ? 2 : 1
if (!phoneNumber) {
this.customerService = defaultCustomerService
return
}
uni.$api.boutiqueApi uni.$api.boutiqueApi
.getWorkWechatLiveQRCode({ .getWorkWechatLiveQRCode({
orderCode, orderCode,
...@@ -602,7 +600,9 @@ export default { ...@@ -602,7 +600,9 @@ export default {
this.customerService = defaultCustomerService this.customerService = defaultCustomerService
} }
}) })
// }, 3000) .catch(() => {
this.customerService = failCustomerService
})
}, },
/** 获取服务商是否使用膜卷号 */ /** 获取服务商是否使用膜卷号 */
getServiceFilmRollSetting(yqMerchantId) { getServiceFilmRollSetting(yqMerchantId) {
......
<template> <template>
<view class="date-list"> <view v-if="ready && days.length" class="date-list">
<picker-view class="picker picker_max" :value="dateValues" indicator-class="indicator" @change="changeDate"> <picker-view class="picker picker_max" :value="dateValues" indicator-class="indicator" @change="changeDate">
<picker-view-column> <picker-view-column>
<template v-for="(item, index) in days"> <template v-for="(item, index) in days">
...@@ -29,160 +29,141 @@ import dayjs from 'dayjs' ...@@ -29,160 +29,141 @@ import dayjs from 'dayjs'
export default { export default {
name: 'DateTime', name: 'DateTime',
inject: ['userInfo'], inject: ['userInfo'],
data() { data () {
return { return {
hours: [], hours: [],
days: [], days: [],
minutes: [], minutes: [],
dateValues: [], dateValues: [0],
hourValues: [], hourValues: [0],
minuteValues: [], minuteValues: [0],
loading: true ready: false,
currentDate: '',
currentHour: '',
currentMinute: ''
} }
}, },
props: { props: {
params: Object,
}, startDate: String,
endDate: String
mounted() {
this.initDate()
}, },
methods: { methods: {
initDate() { getList () {
this.dateValues = [] this.ready = false
this.hourValues = [] this.initDate()
this.minuteValues = []
const today = new Date()
this.getDateList('2019/01/01', new Date(today.getFullYear(), today.getMonth(), today.getDate()))
}, },
getDateList(starDay, endDay) { buildDayList () {
const arr = []; const days = []
const dates = []; const start = dayjs((this.startDate || '2019-01-01').replace(/\//g, '-')).startOf('day')
const end = dayjs((this.endDate || dayjs().format('YYYY-MM-DD')).replace(/\//g, '-')).startOf('day')
// 设置两个日期UTC时间 if (!start.isValid() || !end.isValid() || end.isBefore(start)) return days
const db = new Date(starDay); let cur = start
const de = new Date(endDay); while (cur.isBefore(end) || cur.isSame(end, 'day')) {
// 获取两个日期GTM时间 days.push(cur.format('YYYY/MM/DD'))
const s = db.getTime() - 24 * 60 * 60 * 1000; cur = cur.add(1, 'day')
const d = de.getTime() - 24 * 60 * 60 * 1000;
// 获取到两个日期之间的每一天的毫秒数
for (let i = s; i <= d;) {
i = i + 24 * 60 * 60 * 1000;
arr.push(parseInt(String(i)));
}
// 获取每一天的时间 YY-MM-DD
for (const j in arr) {
const time = dayjs(arr[j]);
if (!time.isValid()) continue; // 跳过无效日期
const year = time.year();
const month = time.month() + 1; // 注意:dayjs 的 month() 返回 0-11
const day = time.date();
const mouthStr = month >= 10 ? month : '0' + month;
const dayStr = day >= 10 ? day : '0' + day;
const YYMMDD = year + '/' + mouthStr + '/' + dayStr;
dates.push(YYMMDD);
} }
this.getHourList(dates) return days
}, },
getHourList(days) { buildHourList (isToday) {
const hours = [], today = new Date(); const len = isToday ? dayjs().hour() + 1 : 24
for (let hour = 0; hour < today.getHours() + 1; hour++) { return Array.from({ length: len }, (_, i) => String(i).padStart(2, '0'))
hours.push(hour.toString().padStart(2, '0')); },
} buildMinuteList (isToday, hour) {
const now = dayjs()
this.getMinuteList(days, hours) const isCurrentHour = isToday && hour === now.format('HH')
const len = isCurrentHour ? now.minute() + 1 : 60
return Array.from({ length: len }, (_, i) => String(i).padStart(2, '0'))
},
pickIndex (list, value, fallbackLast) {
const index = list.indexOf(value)
if (index >= 0) return index
return fallbackLast ? Math.max(list.length - 1, 0) : 0
}, },
getMinuteList(days, hours) { applyPickerValues (dateValues, hourValues, minuteValues) {
const minutes = []; this.$nextTick(() => {
const today = new Date() this.dateValues = dateValues
for (let minute = 0; minute < today.getMinutes() + 1; minute++) { this.hourValues = hourValues
minutes.push(minute.toString().padStart(2, '0')); this.minuteValues = minuteValues
this.ready = true
this.$emit('onComplete')
})
},
initDate () {
const days = this.buildDayList()
if (!days.length) {
this.days = []
this.hours = []
this.minutes = []
this.ready = false
this.$emit('onComplete')
return
} }
// 设置默认时间
let { dateValues, hourValues, minuteValues } = this
const HOUR_STR = today.getHours().toString().padStart(2, '0')
const MUNTUE_STR = today.getMinutes().toString().padStart(2, '0')
// const defalutHIndex = hours.indexOf(HOUR_STR)
// const defalutMIndex = minutes.indexOf(MUNTUE_STR)
dateValues.push(days.length + 1)
hourValues.push(hours.length + 1)
minuteValues.push(minutes.length + 1)
this.currentDate = dayjs().format('YYYY/MM/DD')
this.currentHour = HOUR_STR
this.currentMinute = MUNTUE_STR
this.hours = hours const today = dayjs()
const todayStr = today.format('YYYY/MM/DD')
const currentDate = todayStr
const currentHour = today.format('HH')
const currentMinute = today.format('mm')
const hours = this.buildHourList(true)
const minutes = this.buildMinuteList(true, currentHour)
this.currentDate = currentDate
this.currentHour = currentHour
this.currentMinute = currentMinute
this.days = days this.days = days
this.hours = hours
this.minutes = minutes this.minutes = minutes
this.dateValues = dateValues
this.hourValues = hourValues
this.minuteValues = minuteValues
this.loading = false
setTimeout(() => {
this.minuteValues = minuteValues
this.loading = false
}, 100)
this.$emit('onComplete')
},
changeDate(e) {
const { days } = this
const { value } = e.detail
const index = value[0]
this.currentDate = days[index]
// 选择过去时间需要重新初始化时分
const today = dayjs().format('YYYY/MM/DD')
const timeType = this.currentDate != today ? 1 : 0
this.getAllTimeOrPartTime(timeType)
},
changeHour(e) {
const { hours, days, dateValues } = this
const { value } = e.detail
const index = value[0]
this.currentHour = hours[index]
// 处理当前天切换别的小时,别的分不能选后面分到60的问题 this.applyPickerValues(
// const dayIndex = dateValues[0] [this.pickIndex(days, currentDate, true)],
// this.currentDate = days[dayIndex] [this.pickIndex(hours, currentHour, true)],
const today = dayjs().format('YYYY/MM/DD') [this.pickIndex(minutes, currentMinute, true)]
const timeType = this.currentDate != today ? 1 : 0 )
this.getAllTimeOrPartTimeMinute(timeType)
},
changeMinutes(e) {
const { minutes } = this
const { value } = e.detail
const index = value[0]
this.currentMinute = minutes[index]
}, },
getAllTimeOrPartTime(type) { changeDate (e) {
const today = new Date() const index = e.detail.value[0]
const hours = [], minutes = [], hour_len = type == 1 ? 24 : today.getHours() + 1, minute_len = type == 1 ? 60 : today.getMinutes() + 1; const date = this.days[index]
for (let hour = 0; hour < hour_len; hour++) { if (!date) return
hours.push(hour.toString().padStart(2, '0')); this.currentDate = date
} const isToday = this.currentDate === dayjs().format('YYYY/MM/DD')
for (let minute = 0; minute < minute_len; minute++) { this.hours = this.buildHourList(isToday)
minutes.push(minute.toString().padStart(2, '0')); if (!this.hours.includes(this.currentHour)) {
this.currentHour = this.hours[this.hours.length - 1]
} }
this.hours = hours const minutes = this.buildMinuteList(isToday, this.currentHour)
this.minutes = minutes this.minutes = minutes
if (!this.minutes.includes(this.currentMinute)) {
this.currentMinute = this.minutes[this.minutes.length - 1]
}
this.$nextTick(() => {
this.hourValues = [this.pickIndex(this.hours, this.currentHour, true)]
this.minuteValues = [this.pickIndex(this.minutes, this.currentMinute, true)]
})
}, },
getAllTimeOrPartTimeMinute(type) { changeHour (e) {
const today = new Date() const index = e.detail.value[0]
const currentHour = today.getHours() const hour = this.hours[index]
const timeType = this.currentHour != currentHour ? 1 : 0 if (hour == null) return
const minutes = [], minute_len = type == 1 || timeType == 1 ? 60 : today.getMinutes() + 1; this.currentHour = hour
for (let minute = 0; minute < minute_len; minute++) { const isToday = this.currentDate === dayjs().format('YYYY/MM/DD')
minutes.push(minute.toString().padStart(2, '0')); this.minutes = this.buildMinuteList(isToday, this.currentHour)
if (!this.minutes.includes(this.currentMinute)) {
this.currentMinute = this.minutes[this.minutes.length - 1]
} }
this.minutes = minutes this.$nextTick(() => {
this.minuteValues = [this.pickIndex(this.minutes, this.currentMinute, true)]
})
},
changeMinutes (e) {
const index = e.detail.value[0]
const minute = this.minutes[index]
if (minute == null) return
this.currentMinute = minute
}, },
getResult() { getResult () {
let str = '' const str = `${this.currentDate} ${this.currentHour}:${this.currentMinute}:00`
str = this.currentDate + ' ' + this.currentHour + ':' + this.currentMinute return dayjs(str.replace(/-/g, '/')).format('YYYY/MM/DD HH:mm:ss')
// + ":00"
const result = dayjs(str).format('YYYY-MM-DD HH:mm')
return result
} }
} }
} }
...@@ -193,11 +174,9 @@ export default { ...@@ -193,11 +174,9 @@ export default {
height: 100%; height: 100%;
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr);
.picker { .picker {
height: 100%; height: 100%;
text-align: center; text-align: center;
.view { .view {
display: flex; display: flex;
align-items: center; align-items: center;
...@@ -206,7 +185,6 @@ export default { ...@@ -206,7 +185,6 @@ export default {
height: toRpx(72); height: toRpx(72);
} }
} }
/deep/.indicator { /deep/.indicator {
height: toRpx(72); height: toRpx(72);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!