/**
 * [OElove] (C)2010-2099 oelove.com Inc.
 * Email: service@phpcoo.com，phpcoo@qq.com
 * This is not a freeware, use is subject to license terms
 * $ LastTime 2017.02.13 Update by CL $
*/
$(function () {
    function Party () {
        this.pay();
    }
    Party.prototype = {
        pay: function () {
            var is_http = false;
            $('[f="but_party_pay_submit"]').on('click', function () {
                var id = $(this).attr("data-id");

                if (is_http) return;
                is_http = true;

                var loading,
                    timer = setTimeout(function () {
                        loading = OEUI.loading({
                            el: this
                        });
                        loading.show();
                    }, 200);

                $.ajax({
                    type: "POST",
                    url: _OE_FILE+"&c=party",
                    data: {
                        a:"confirmpay", id: id
                    },
                    success: function(json) {
                        is_http = false;
                        loading && loading.remove();
                        clearTimeout(timer);
                        timer = null;
                        var res = JSON.parse(json);

                        if (res.response == "1") {
                            window.location.href = _ROOT_PATH+"index.php?c=pay&paynum="+ res.result
                        } else {
                            var error = res.result;
                            if (error.length == 0) {
                                error = "提交失败，请检查";
                            }
                            OEUI.message.msg({text: error});
                        }
                    },
                    error: function() {
                        is_http = false;
                        loading && loading.remove();
                        clearTimeout(timer);
                        timer = null;
                        OEUI.message.msg({text: '系统繁忙，请稍后再试'});
                    }
                });
            }); 
        }
    }
    new Party();
});