/**
 * [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/02 by CL $
*/
var _inst_oesearch = null;
$(function(){
    
    //搜索类
    function OESearch() {
        this._search_dialog = null; //弹出对象
        this._search_box = "search_wrap"; //搜索框名称
        this.slide_time = 200;
        this.params = ""; //搜索项组合 item=value&item=value
        
        this.this_dom = null;
        this.slide_box = null;
        
        this.wake();
    }
    
    OESearch.prototype = {
        
        wake:function() {
            _this = this;
            
            //选择分类
            $(document).on("click", "[f='but_sel_giftcat']", function(){
                var $val = $(this).attr("data-val");
                var $input = $(this).attr("data-input");
                $("#"+$input).val($val);
                $(this).addClass('current').siblings().removeClass('current');
                
                _this.submitSearch();
            });
        }, 
        
        
        //执行搜索
        submitSearch:function() {
            _this = this;
            
            _this.params = _this.buildParams(); //获取参数
            $reqs_url = WAP_APPFILE+"&c=gift&a=list&datatype=json";
            $reqs_url += "&"+_this.params;
            $("#reqs_url").val($reqs_url);
            $("#page").val("1");
            
            //重新搜索...
            setTimeout(function(){
                if (_inst_oepage) {
                    $("#"+_inst_oepage.pull_data_id).html("");
                    _inst_oepage.scroll.refresh();
                }
            }, 50);
        }, 
        
        //组合参数
        buildParams:function() {
            var $build_params = "";
            var arr_data = new Array();
            arr_data = [
                    's_catid'
                ];
            $.each(arr_data, function(i, item) {
                $val = $("#"+item).val();
                if (typeof($val) == "undefined") {
                    $val = "";
                }
                if ($build_params.length == 0 || $build_params == "") {
                    $build_params += item+"="+encodeURIComponent($val);
                }
                else {
                    $build_params += "&"+item+"="+encodeURIComponent($val);
                }
            });
            return $build_params;
        }
        
    }
    _inst_oesearch = new OESearch();
    
});

