utils.js
4.2 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
const utils = {
getweekDay(time) {
let temp_data = new Date(time)
if (temp_data.getDay() === 0) return "星期天"
if (temp_data.getDay() === 1) return "星期一"
if (temp_data.getDay() === 2) return "星期二"
if (temp_data.getDay() === 3) return "星期三"
if (temp_data.getDay() === 4) return "星期四"
if (temp_data.getDay() === 5) return "星期五"
if (temp_data.getDay() === 6) return "星期六"
},
getweekDayZhou(time) {
let temp_data = new Date(time)
if (temp_data.getDay() === 0) return "周日"
if (temp_data.getDay() === 1) return "周一"
if (temp_data.getDay() === 2) return "周二"
if (temp_data.getDay() === 3) return "周三"
if (temp_data.getDay() === 4) return "周四"
if (temp_data.getDay() === 5) return "周五"
if (temp_data.getDay() === 6) return "周六"
},
dateFormat(time) {
let date = new Date(time);
let year = date.getFullYear();
// 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
// 拼接
return year + "-" + month + "-" + day + " " + hours + ":" + minutes;
},
dateFormatYear(time) {
let date = new Date(time);
let year = date.getFullYear();
// 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
// 拼接
return year + "-" + month + "-" + day;
},
getTimeByISO(time) {
let temp_data = new Date(time).toJSON()
let bj_time = new Date(+new Date(temp_data) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(
/\.[\d]{3}Z/, '')
return bj_time
},
getWebView(header, top, height) {
let wv = plus.webview.create("", "square-webview", {
additionalHttpHeaders: {
header: header,
},
plusrequire: "none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
'uni-app': 'none', //不加载uni-app渲染层框架,避免样式冲突
top: top,
height: height,
})
wv.overrideUrlLoading({
mode: "reject"
}, (e) => {
console.log('-------拦截请求', e.url)
if (e.url.indexOf("?zq") !== -1) {
let tempData = {
url: e.url,
}
uni.navigateTo({
url: `/pages/notitle_h5/notitle_h5?info=${encodeURIComponent(JSON.stringify(tempData))}`
})
} else if (e.url.indexOf("login") !== -1) {
uni.navigateTo({
url: `/pages/login_account/login_account`
})
} else if (e.url.indexOf("?ydn_back") !== -1) {
uni.navigateBack({
})
} else {
if (e.url === 'https://app.ydniu.com/' || e.url === 'https://app.ydniu.com') {
uni.navigateBack({
})
}
}
})
return wv
},
getPassUrl() {
return 'https://app.ydniu.com/sports,https://app.ydniu.com/jczq/index'
},
getCurrentState(state, time) {
var result = "未";
switch (state) {
case 4:
case 10:
case 12:
result = "完";
break;
case 2:
result = "中场";
break;
case 5:
result = "中断";
break;
case 6:
result = "取消";
break;
case 13:
result = "延期";
break;
case 14:
result = "腰斩";
break;
case 15:
result = "待定";
break;
default:
if (state == 3) {
result = (time / (1000 * 60) + 45) + "'";
if ((time / (1000 * 60)) > 45) {
result = 90 + "+";
}
} else if (state == 1) {
result = time / (1000 * 60) + "'";
if (time / (1000 * 60) > 45) {
result = 45 + "+";
} else if (time / (1000 * 60) == 0) {
result = 1 + "'";
}
} else {
result = time / (1000 * 60) + "'";
}
break;
}
return result
}
}
export default utils;