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;
    }
};