doum
2026-01-29 e890eddcac0e51e67ce4e5ee8f69f58497c84af3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// 返回单位
export const formatNumber = (num) => {
    if (num >= 100000000) {
        return (num / 100000000).toFixed(1) + "亿";
    } else if (num >= 10000 && num < 100000000) {
        return (num / 10000).toFixed(1) + "w";
    } else if (num >= 1000) {
        return (num / 1000).toFixed(1) + "k";
    } else {
        return num.toString();
    }
}
 
// 安卓苹果日期格式转换
export const dateConversion = (date) => {
    const systemInfo = uni.getSystemInfoSync();
    if (systemInfo.osName === 'ios') {
        return date.replace(/-/g, "/")
    } else {
        return date
    }
}
 
 
/**
 * 获取两个时间段的所有选项,步长为15分钟
 * @param {*} startTime  开始时间 时间格式为 12:00
 * @param {*} endTime  结束时间 时间格式为 12:00
 * 返回 可选的数组
 */
export const getOptions = (startTime, endTime) => {
    const timeMap = {
        '00': 0,
        '15': 1,
        '30': 2,
        '45': 3
    }
    const numTotimeMap = ['00', '15', '30', '45']
    let [startHours, startMin] = startTime.split(':')
    let [endHours, endMin] = endTime.split(':')
    let len = endHours - startHours
    let res = []
    for (let i = 0; i < len + 1; i++) {
        let num = (i === 0 ? timeMap[startMin] : 0)
        let inlen = (i === len) ? timeMap[endMin] + 1 : 4
        for (let q = num; q < inlen; q++) {
            let hours = parseInt(startHours) + parseInt(i)
            let item = `${hours}:${numTotimeMap[q]}`
            res.push(item)
        }
    }
    return res;
}
 
// 对比时段大小
export const compareTime = (time1, time2) => {
    // 假设时间格式为 "HH:MM"
    const [hours1, minutes1] = time1.split(':').map(Number);
    const [hours2, minutes2] = time2.split(':').map(Number);
 
    // 转换为总分钟数
    const totalMinutes1 = hours1 * 60 + minutes1;
    const totalMinutes2 = hours2 * 60 + minutes2;
 
    if (totalMinutes1 < totalMinutes2) {
        return -1; // time1较小
    } else if (totalMinutes1 > totalMinutes2) {
        return 1; // time2较小
    } else {
        return 0; // 相等
    }
}
 
// 获取当前时分
export const getCurrentTimeWithZeroes = () => {
    const now = new Date();
    return now.toLocaleTimeString('en-US', {
        hour12: false,
        hour: '2-digit',
        minute: '2-digit'
    });
}
 
// 获取当天年月日
export const getFormattedDate = () => {
    const date = new Date();
    const year = date.getFullYear();
    const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 月份是从0开始的,所以+1
    const day = date.getDate().toString().padStart(2, '0');
    return `${year}-${month}-${day}`;
}
 
// 判断接单日期
export const getDayType = (days) => {
    const weekdays = [1, 2, 3, 4, 5];
    const weekends = [6, 7];
    
    if (days.every(day => weekdays.includes(day))) {
        return "周内";
    } else if (days.every(day => weekends.includes(day))) {
        return "周末";
    } else if (days.every(day => weekdays.includes(day) || weekends.includes(day))) {
        return "整周";
    }
}
 
// 返回评分说明
export const returnUserRating = (userRating) => {
    if (userRating > 4 && userRating <= 5) {
        return '超棒'
    } else if (userRating > 3 && userRating <= 4) {
        return '很好'
    } else if (userRating > 2 && userRating <= 3) {
        return '一般'
    } else if (userRating >= 0 && userRating <= 2) {
        return '很差'
    }
}
 
// 返回回复时长文字
export const rhuifuTimeName = (responseTime) => {
    if (responseTime >= 0 && responseTime <= 10) {
        return '回复很快'
    } else if (responseTime > 10 && responseTime <= 30) {
        return '回复一般'
    } else {
        return '回复较慢'
    }
}