util.js
2.0 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
var t = [], e = function(t) {
return (t = t.toString())[1] ? t : "0" + t;
};
module.exports = {
formatTime: function(t) {
var i = t.getFullYear(), a = t.getMonth() + 1, n = t.getDate(), o = t.getHours(), s = t.getMinutes(), u = t.getSeconds();
return [ i, a, n ].map(e).join("/") + " " + [ o, s, u ].map(e).join(":");
},
imageUtil: function(t) {
var e = {}, i = t.detail.width, a = t.detail.height, n = a / i;
return wx.getSystemInfo({
success: function(t) {
var o = t.windowWidth, s = t.windowHeight;
n < s / o ? (e.imageWidth = o, e.imageHeight = o * a / i) : (e.imageHeight = s,
e.imageWidth = s * i / a);
}
}), e;
},
getSearchMusic: function(t, e, i) {
wx.request({
url: "https://ailingcheng.cn/index.php/Api/Index/ajax_goods_search",
data: {
p: e,
keyword: t
},
method: "POST",
header: {
"content-type": "application/x-www-form-urlencoded"
},
success: function(t) {
"success" == t.data.state && i(t.data);
}
});
},
uploadimg: function(e) {
var i = this, a = e.i ? e.i : 0, n = e.success ? e.success : 0, o = e.fail ? e.fail : 0;
wx.uploadFile({
url: e.url,
filePath: e.path[a],
name: "fileinfo",
formData: null,
success: function(e) {
n++;
var i = JSON.parse(e.data);
t.push(i.fileinfo);
},
fail: function(t) {
o++;
},
complete: function() {
++a == e.path.length || (e.i = a, e.success = n, e.fail = o, i.uploadimg(e));
}
});
},
imgs: t,
isEmptyObject: function(t) {
var e;
for (e in t) return !1;
return !0;
}
};