-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.js
97 lines (92 loc) · 2.51 KB
/
util.js
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
var app = getApp()
function formatTime(date) {
var year = date.getFullYear()
var month = date.getMonth() + 1
var day = date.getDate()
var hour = date.getHours()
var minute = date.getMinutes()
var second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
function getMessage(id,obj){
wx.request({
url: app.globalData.ip+'/getMsg.php',
data: {
id:id
},
method: "POST",
header: {
// 'Content-Type': 'application/json'
},
success: function(res) {
obj.setData({
message:res.data
})
},
fail:function(err){
console.log(err);
}
})
}
function getUser(obj){
obj.setData({
hidden: false
})
wx.request({
url: app.globalData.ip+'/getUser.php',
data: {},
header: {
'Content-Type': 'application/json'
},
success: function(res) {
setTimeout(function(){
obj.setData({
list:res.data,
hidden: true,
toast1Hidden:false,
toastText:"拿到数据"
})
wx.stopPullDownRefresh()
},3000)
},
fail:function(err){
setTimeout(function(){
obj.setData({
list:res.data,
hidden: true,
toast1Hidden:false,
toastText:"请检查server"
})
wx.stopPullDownRefresh()
},3000)
console.log(err);
}
})
}
function getMoments(obj){
wx.request({
url: app.globalData.ip+'/getMoments.php',
data: {},
header: {
'Content-Type': 'application/json'
},
success: function(res) {
obj.setData({
moments:res.data
})
},
fail:function(err){
console.log(err);
}
})
}
function formatNumber(n) {
n = n.toString()
return n[1] ? n : '0' + n
}
module.exports = {
formatTime: formatTime,
getMessage: getMessage,
getUser: getUser,
getMoments:getMoments
}