utils.js
1.83 KB
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
import oauth from '@/apis/modules/oauth.js'
import clueApi from '@/apis/modules/clue.js'
const utils = {
async getstorelist() {
const result = await oauth.getStoreList();
return result
},
gettime() {
const now = new Date();
const formatTime = uni.$u.timeFormat(now,'yyyy-mm-dd hh:MM:ss')
console.log('当前时间:', formatTime);
return formatTime
},
// 获取今天的日期字符串
getTodayString() {
const today = new Date()
return uni.$u.timeFormat(today,'yyyy-mm-dd')
},
async gethy(e) {
let c1 = '暂无'
const result = await clueApi.getCustomerClues({
currentPage: 1,
pageSize: 1,
keyword: e
});
if(result.code == 200 && result.data.list.length>0){
c1 = result.data.list[0].id
}
return c1
},
// 格式化时间
formatTime(timestamp) {
if (!timestamp) return '无'
const date = new Date(timestamp)
return uni.$u.timeFormat(date,'yyyy-mm-dd hh:MM')
},
formatTimeday(timestamp) {
if (!timestamp) return '无'
const date = new Date(timestamp)
return uni.$u.timeFormat(date,'yyyy-mm-dd')
},
formatTimess(timestamp) {
if (!timestamp) return '无'
const date = new Date(timestamp)
return uni.$u.timeFormat(date,'yyyy-mm-dd hh:MM:ss')
},
// 获取今天的日期范围
getTodayRange() {
const today = new Date()
const startOfDay = new Date(today.getFullYear(), today.getMonth(), today.getDate())
const endOfDay = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59, 999)
return [startOfDay.getTime(), endOfDay.getTime()]
},
// 获取本月时间范围
getCurrentMonthRange() {
const today = new Date()
const startOfDay = new Date(today.getFullYear(), today.getMonth(), 1)
const endOfDay = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59, 999)
return [startOfDay.getTime(), endOfDay.getTime()]
},
};
export default utils;