|
@@ -1,24 +1,44 @@
|
1
|
1
|
const toolClass = {
|
2
|
|
- dateFormat: (timestamp) => {
|
|
2
|
+ dateFormat: (timestamp, fmt) => {
|
|
3
|
+ if (!fmt) {
|
|
4
|
+ fmt = 'yyyy-MM-dd hh:mm'
|
|
5
|
+ }
|
|
6
|
+
|
3
|
7
|
let date = new Date(timestamp)
|
4
|
|
- let y = date.getFullYear()
|
5
|
|
- let m = date.getMonth() + 1
|
6
|
|
- let d = date.getDate()
|
7
|
|
- let h = date.getHours()
|
8
|
|
- let min = date.getMinutes()
|
9
|
|
- if (m < 10) {
|
10
|
|
- m = '0' + m
|
|
8
|
+ var o = {
|
|
9
|
+ 'M+': date.getMonth() + 1,
|
|
10
|
+ 'd+': date.getDate(),
|
|
11
|
+ 'h+': date.getHours(),
|
|
12
|
+ 'm+': date.getMinutes(),
|
|
13
|
+ 's+': date.getSeconds(),
|
|
14
|
+ 'q+': Math.floor((date.getMonth() + 3) / 3),
|
|
15
|
+ 'S': date.getMilliseconds()
|
11
|
16
|
}
|
12
|
|
- if (d < 10) {
|
13
|
|
- d = '0' + d
|
|
17
|
+ if (/(y+)/.test(fmt)) {
|
|
18
|
+ fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
|
14
|
19
|
}
|
15
|
|
- if (h < 10) {
|
16
|
|
- h = '0' + h
|
|
20
|
+ for (var k in o) {
|
|
21
|
+ if (new RegExp('(' + k + ')').test(fmt)) {
|
|
22
|
+ fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
|
|
23
|
+ }
|
17
|
24
|
}
|
18
|
|
- if (min < 10) {
|
19
|
|
- min = '0' + min
|
|
25
|
+ return fmt
|
|
26
|
+ },
|
|
27
|
+ UrlSearch: (urls) => {
|
|
28
|
+ let url = urls // 获取url中"?"符后的字串
|
|
29
|
+ let theRequest = {}
|
|
30
|
+ if (url.indexOf('?') !== -1) {
|
|
31
|
+ let str = url.substr(1)
|
|
32
|
+ let strs = str.split('&')
|
|
33
|
+ for (var i = 0; i < strs.length; i++) {
|
|
34
|
+ theRequest[strs[i].split('=')[0]] = unescape(strs[i].split('=')[1])
|
|
35
|
+ }
|
20
|
36
|
}
|
21
|
|
- return y + '-' + m + '-' + d + ' ' + h + ':' + min
|
|
37
|
+ return theRequest
|
|
38
|
+ },
|
|
39
|
+ getCode: (appid) => {
|
|
40
|
+ let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${wechatConfig.redirect_uri}&response_type=${wechatConfig.response_type}&scope=${wechatConfig.scope}&state=${wechatConfig.state}#wechat_redirect`
|
|
41
|
+ window.location.href = url
|
22
|
42
|
}
|
23
|
43
|
}
|
24
|
44
|
|