/**
 * [OElove] (C)2010-2099 oelove.com Webapp
 * Email: service@phpcoo.com ,phpcoo@qq.com
 * This is NOT a freeware, use is subject to license terms
 * $ Last update 2020/05/20 by CL $
*/
var _inst_oecptips = null;
$(function () {
   
    function OECPTips() {
        this.api_url = WAP_APPFILE +'&c=cp';
        this._tips_dialog = null;
        this.slide_time = 200;
        
        
        this.initTips();
        this.closeTips();
        
    }
    OECPTips.prototype = {
        
        //初始化
        initTips:function() {
            var _this = this;
            
            var $has_tips = _getCookie('OE_CP_TIPS');
            if (typeof($has_tips) == 'undefined') {
                $has_tips = '';
            }
            _setCookie('OE_CP_TIPS', '1', 1); //1天后再提示
            
            if ($has_tips != '1') {
                setTimeout(function(){
                    _this.openTips();
                }, 800);
            }
        },
        
        //弹出提示
        openTips:function() {
            var _this = this;
            
            var mydialog = [];
            if ($("#cptips_rz_dialog").length > 0) {
                mydialog.push('rz');
            }
            if ($("#cptips_profile_dialog").length > 0) {
                mydialog.push('profile');
            }
            if ($("#cptips_vip_dialog").length > 0) {
                mydialog.push('vip');
            }
            if (mydialog.length > 0) {
                var $rand_dialog = mydialog[Math.floor(Math.random()*mydialog.length)];
                
                _this._tips_dialog = OEUI.Dialog({
                    el: '#cptips_'+$rand_dialog+'_dialog',
                    animated: 'zoomIn',
                    time: _this.slide_time,
                    type: 2
                }); 
            }
        },
        
        //关闭提示
        closeTips:function() {
            var _this = this;
            
            //关闭提示
            $(document).on("click", "[f='close_cptips']", function(){
                var $url = $(this).attr("data-url");
                if (typeof($url) == 'undefined') {
                    $url = '';
                }
                if ($url != '') {
                    _this._tips_dialog.hide(function(){
                        setTimeout(function(){
                            window.location.href = $url;
                        }, 50);
                    });
                }
                else {
                    _this._tips_dialog.hide();
                }
            });
        }
        
        
    }
    _inst_oecptips = new OECPTips();
});
