/**
 * [OElove] (C)2010-2099 oelove.com biz
 * Email: service@phpcoo.com ,phpcoo@qq.com
 * This is NOT a freeware, use is subject to license terms
 * $ Last update 2020/04/20 by CL $
*/
var inst_oeindex = null;
$(function(){
    
    function OEIndex() {
        this.api_url = WAP_APPFILE;
        
        this.init();
        this.clickUser();
    }
    
    OEIndex.prototype = {
        
        //初始化
        init:function() {
            var _this = this;
            _this.getUserData();
            
            
            if ($("#joinqz_wall").length > 0) {
                setTimeout(function(){
                   _this.getJoinQz(); 
                }, 50);
            }
            
        },
        
        
        clickUser:function() {
            var _this = this;
            //换一组
            $(document).on("click", "[f='but_change_user']", function(){
                _this.getUserData();
            });
        },
        
        //获取一组会员资料
        getUserData:function($type) {
            var _this = this;
            
            $.ajax({
                type: "POST",
                url: _this.api_url,
                cache: false,
                data: {
                    c:'ajax', a:'user'
                },
                dataType: "json",
                success: function($data) {
                    var $json = eval($data);
                    var $response = $json.response;
                    var $result = $json.result;
                    
                    if ($response == "1") { 
                        $("#user_data").html($result);
                        preload_img();
                    }
                },
                error: function() {
                    OEUI.toast({
                        type: 'bottom',
                        text: '网络繁忙，请稍后再试！'
                    });
                }
            });
            
        }, 
        
        //获取访问记录
        getVisitme:function() {
            var _this = this;
            $.ajax({
                type: "POST",
                url: _this.api_url,
                cache: false,
                data: {
                    c:'ajax', a:'visitme'
                },
                dataType: "json",
                success: function($data) {
                    var $json = eval($data);
                    var $response = $json.response;
                    var $result = $json.result;
                    if ($response == "1") { 
                        $("#visitme_data").html($result);
                        $("#visitme_box").show();
                        preload_img();
                    }
                },
                error: function() {
                }
            });
        },
        
        //加群动态
        getJoinQz:function() {
            var _this = this;
            $.ajax({
                type: "POST",
                url: _this.api_url,
                cache: false,
                data: {
                    c:'ajax', a:'joinqz'
                },
                dataType: "json",
                success: function($data) {
                    var $json = eval($data);
                    var $response = $json.response;
                    var $result = $json.result;
                    if ($response == "1") { 
                        var $html = "";
                        
                        $.each($result, function($iv, $elm){
                            $html += "<li class='ws fz14'>"+$elm.title+" <span class='color_c'>"+$elm.trantime+"</span></li>";
                        });
                        $("#joinqz_wall_data").html($html);
                        $("#joinqz_wall").show();
                        //载入marquee js
                        var $js = "<script src='"+_ROOT_PATH +"tpl/wbapp/js/oe/marquee.js?v="+VERSION+"'></script>"; 
                        $("body").append($js);
                        setTimeout(function(){
                            new OEMarquee({el:document.querySelector('#joinqz_wall_list')});
                        }, 100);
                    }
                },
                error: function() {
                }
            });
            
        }
        
    }
    inst_oeindex = new OEIndex();
});
