/**
 * [OElove] (C)2010-2099 oelove.com Inc.biz
 * Email: service@phpcoo.com ,phpcoo@qq.com
 * $ Last update 2020/11/30 by OE $
*/
//打开页面
var Var_iframe_name = 'oelove_admin_main';
var _openNewPage = function(url, name, param) {
    if (param) {
        url = url + '?' + JSON.stringify(param);
    }
    window.open(url, name);
} 

//
$(function() {
    //左边菜单,url链接...
    $('.oe_side_menu').on('click', 'a', function() {
        $_menu_url = $(this).attr('lay-href');
        if(typeof($_menu_url) != 'undefined') {
          _openNewPage($_menu_url, Var_iframe_name);
        }
    });

    //最新消息...底部弹出...
    $('.oe_website_msg').on('click', '.header i', function() {
        $isShow = $(this).attr('data-toggle');
        if ($isShow == 'down') {
            $(this).hide().siblings().show();
            $('.oe_website_msg .body').slideToggle();
        }
        else if ($isShow == 'up') {
            $(this).hide().siblings().show();
            $('.oe_website_msg .body').slideToggle();
        }
        else{
            $('.oe_website_msg .body').slideToggle();
        }
    });
    
    //展开更多搜索条件
    $('.oe_searchbar').on('click', '.more_search_open', function() {
        $('.more_search').show();
    });
    $('.oe_searchbar').on('click', '.more_search_close', function() {
        $('.more_search').hide();
    });
    
    //预览图片
	$(document).on("click", "[f='viewimg']", function(){
		$img_url = $(this).attr("data-img"); //预览大图
		if (typeof($img_url) == "undefined") {
			$img_url = $(this).attr("src");
		}
		if ($img_url.length > 0) {
			if ($img_url.substr(0, 1) == "/" || $img_url.substr(0, 4) == "http") {
			
			}
			else {
				$img_url = _ROOT_PATH+$img_url;
			}
			window.open($img_url);
		}
	});

	//清除图片
	$(document).on("click", "[f='removeimg']", function(){
		$_img_data_preview = $(this).attr("data-preview"); //预览
        if (typeof($_img_data_preview) == "undefined") {
            $_img_data_preview = "";
        }
		$_img_data_input = $(this).attr("data-input"); //默认input
        
        //缩略图
        if ($("#"+$_img_data_input+"_thumb").length > 0) {
            $("#"+$_img_data_input+"_thumb").val("");
        }
        //原图
        if ($("#"+$_img_data_input+"_url").length > 0) {
            $("#"+$_img_data_input+"_url").val("");
        }
        if ($_img_data_preview.length > 0) {
            $("#"+$_img_data_preview+"_preview").attr("src", _ROOT_PATH+"tpl/static/images/waitimg.jpg");
        }
	});
    
    //a选择搜索分类
    $(document).on("click", "[f='but_search_cat']", function(){
        $form = $(this).attr("data-form");
        if (typeof($form) == "undefined") {
            $form = "mysearch";
        }
        $input = $(this).attr("data-input");
        $value = $(this).attr("data-val");
        $("#"+$input).val($value);
        $("#"+$form).submit();
        
    });
    
    //全选、取消
    layui.use('form', function(){
        $_form = layui.form;
        
        //全选、取消全选
        $_form.on('checkbox(selectAll)', function(data){
            if (data.elem.checked) {
                $('.oe_table_wrap').find('.check input').prop('checked', true);
                $_form.render(); //渲染
            }
            else{
                $('.oe_table_wrap').find('.check input').prop('checked', false);
                $_form.render(); //渲染
            }
        });
        
        //更改状态...
        $_form.on('checkbox(updatestatus)', function(data){
            $current_uri = document.URL;
            $_control_url = $current_uri.split("&")[0]+"&"+$current_uri.split("&")[1];
            $_type = data.elem.getAttribute("data-type");
            if ($_type == null) {
                $_type = "";
            }
            $_id = data.elem.getAttribute("data-id");
            if ($_id == null) {
                $_id = "";
            }
            if (data.elem.checked) {
                //已选...
                $_type = $_type+"open";
            }
            else{
                //取消选中
                $_type = $_type+"close";
            }
            $.ajax({
                type: "GET",
                url: $_control_url,
                data: "a=update&type="+$_type+"&id="+$_id+"&r="+new Date().toString(),
                dataType : "text",
                success: function(data) {
                    
                }
            });
        });
        
    });
    
    //批量操作...修改和删除等...支持a赋值  form/url/ajax
    $(document).on("click", "[f='handle-array']", function(){
        $a = $(this).attr("data-a");
        if (typeof($a) == "undefined") {
            $a = "";
        }
        $go_form = $(this).attr("data-form");
        if (typeof($go_form) == "undefined") {
            $go_form = "";
        }
        $go_url = $(this).attr("data-url");
        if (typeof($go_url) == "undefined") {
            $go_url = "";
        }
        $type = $(this).attr("data-type"); //form/url/ajax
        if (typeof($type) == "undefined") {
            $type = "form";
        }
        if ($a.length > 0) {
            $("#a").val($a);
        }
        //判断是否选择...
        $_ids = "";
        $("input[name='id[]']:checked").each(function() {
            $_ids += $(this).val()+",";
        });
        if ($_ids.length == 0) {
            layer.msg("请选择要处理的数据");
            return false;
        }
        
        $_text = $(this).attr("data-text");
        if (typeof($_text) == "undefined") {
            $_text = "确定要执行该操作吗？";
        }
        
        layer.confirm($_text, {
                btn: ["确定","取消"] //按钮
            }, 
            function(){
                layer.closeAll();
                if ($type == "form") {
                    $("#"+$go_form).submit();
                }
                else if ($type == "url") {
                    window.location.href = $go_url;
                }
                else if ($type == "ajax") {
                    oelove_do_ajax($go_url, function(){
                        layer.msg("操作成功", {icon:1});
                    });
                }
                
            }, 
            function(){
                layer.closeAll();
                //layer.msg("取消操作", {icon:2});
            }
        ); 
    });
    //单个操作...删除、等 确认操作... url和ajax操作
    $(document).on("click", "[f='handle-one']", function(){
        $go_url = $(this).attr("data-url");
        if (typeof($go_url) == "undefined") {
            $go_url = "";
        }
        $type = $(this).attr("data-type"); //url/ajax
        if (typeof($type) == "undefined") {
            $type = "url";
        }
        if ($go_url.length == 0) {
            layer.msg("请求链接出错啦！");
            return false;
        }
        
        $_text = $(this).attr("data-text");
        if (typeof($_text) == "undefined") {
            $_text = "确定要执行该操作吗？";
        }
        
        
        $_reload = $(this).attr("data-reload");
        if (typeof($_reload) == "undefined") {
            $_reload = "0";
        }
        
        layer.confirm($_text, {
                btn: ["确定","取消"] //按钮
            }, 
            function(){
                layer.closeAll();
                if ($type == "url") {
                    window.location.href = $go_url;
                }
                else if ($type == "ajax") {
                    oelove_do_ajax($go_url, function(){
                        layer.msg("操作成功", {icon:1});
                        if ($_reload == "1") {
                            //本页刷新...
                            setTimeout(function(){
                                window.location.reload();
                            }, 500);
                        }
                        else if ($_reload == "2") {
                            //父页刷新...
                            setTimeout(function(){
                                window.parent.location.reload();
                            }, 500);
                        }
                    });
                }  
            }, 
            function(){
                layer.closeAll();
                //layer.msg("取消操作", {icon:2});
            }
        ); 
    });
    
    
    //检测会员资料项是否可用
	$(document).on("blur", "[f='user_checkcan']", function(){
		$_value = $(this).val();
		$_type = $(this).attr("data-type");
		if (typeof($_type) == "undefined") {
			$_type = "username";
		}
		$_uid = $(this).attr("data-uid");
		if (typeof($_uid) == "undefined") {
			$_uid = 0;
		}
        $tips_obj = $("#"+$_type+"_tips");
		if ($_value.length > 0) {
            $tips_obj.html("");
			$.ajax({
				type: "POST",
				url: _OECPFILE+"&c=user",
				cache: false,
				data: {
                    a:"checkcan", type:$_type, value:$_value, uid:$_uid, r:get_rndnum(8)
                },
				dataType: "json",
				success: function(data) {
					$json = eval(data);
					$response = $json.response;
					$result = $json.result;
					if ($response == '1') {
                        $tips_obj.html("<font color='green'>可用</font>");
					}
					else {
						if ($result.length == 0) {
							$result = "已存在";
						}
						$tips_obj.html("<font color='red'>"+$result+"</font>");
					}
				},
				error: function() {
					layer.msg("系统繁忙，请稍后再试！");
				}
			});
		}

	});
    
    //管理页//右边更多操作 收起和展开...通用
    $(document).on("click", "[f='narrow']", function(){
        $(this).closest('.oe_menu_inner').find('.menu_body').hide();
        $(this).closest('.oe_menu_inner').css({'top': '70px'});
        $(this).hide().siblings('.enlarge').show();
    });
    $(document).on("click", "[f='enlarge']", function(){
        $(this).closest('.oe_menu_inner').find('.menu_body').show();
        $(this).closest('.oe_menu_inner').css({'top': '120px'});
        $(this).hide().siblings('.narrow').show();
    });
    
    
    //批量审核证件...Form提交 rz
    $(document).on("click", "[f='handle-auditrz']", function(){
        $go_form = $(this).attr("data-form");
        if (typeof($go_form) == "undefined") {
            $go_form = "myform";
        }
        $type = $(this).attr("data-type");
        if (typeof($type) == "undefined") {
            $type = "pass";
        }
        $("#lotact").val($type);
        
        //判断是否选择...
        $_ids = "";
        $("input[name='id[]']:checked").each(function() {
            $_ids += $(this).val()+",";
        });
        if ($_ids.length == 0) {
            layer.msg("请选择要处理的数据");
            return false;
        }
        
        $_text = $(this).attr("data-text");
        if (typeof($_text) == "undefined") {
            $_text = "确定要执行该操作吗？";
        }
        
        layer.confirm($_text, {
                btn: ["确定","取消"] //按钮
            }, 
            function(){
                layer.closeAll();
                $("#"+$go_form).submit();
                
            }, 
            function(){
                layer.closeAll();
            }
        ); 
    });
    
    //批量审核操作...Form提交 通用 8.12.28
    $(document).on("click", "[f='handle-audit']", function(){
        $go_form = $(this).attr("data-form");
        if (typeof($go_form) == "undefined") {
            $go_form = "myform";
        }
        $type = $(this).attr("data-type");
        if (typeof($type) == "undefined") {
            $type = "pass";
        }
        $("#lotact").val($type);
        
        //8.12.28
        $a = $(this).attr("data-a");
        if (typeof($a) == "undefined") {
            $a = "";
        }
        if ($a.length > 0) {
            $("#a").val($a);
        }
        
        //判断是否选择...
        $_ids = "";
        $("input[name='id[]']:checked").each(function() {
            $_ids += $(this).val()+",";
        });
        if ($_ids.length == 0) {
            layer.msg("请选择要处理的数据");
            return false;
        }
        
        $_text = $(this).attr("data-text");
        if (typeof($_text) == "undefined") {
            $_text = "确定要执行该操作吗？";
        }
        
        layer.confirm($_text, {
                btn: ["确定","取消"] //按钮
            }, 
            function(){
                layer.closeAll();
                $("#"+$go_form).submit();
                
            }, 
            function(){
                layer.closeAll();
            }
        ); 
    });
    
    //套餐 选择天数
    $(document).on("click", "[f='but_sel_tcdays']", function(){
        $_days = $(this).attr("data-days");
        $("#days").val($_days);
        $(this).addClass('current').siblings().removeClass('current');
    });
    
    //单项诚信查询 8.12.27
	$(document).on("click", "[f='creditget']", function(){
		$type = $(this).attr("data-type");
		$value = $(this).attr("data-value");
		$tips = $(this).attr("data-tips");
		
		$obj_tips = $("#"+$tips);
		$obj_tips.html("<img src='"+_ROOT_PATH+"tpl/admin/images/loading.gif' />");
		$.ajax({
			type: "GET",
			url: _ROOT_PATH+"index.php",
			cache: false,
			data: {
				c:"rpzy", a:"query", type:$type, value:$value, r:get_rndnum(8)
			},
			dataType: "json",
			success: function($data) {
				$json = eval($data);
				$response = $json.response;
				$result = $json.result;
				if ($response == "1") { //没有举报记录
					$obj_tips.html("<img src='"+_ROOT_PATH+"tpl/admin/images/allow.gif' />");
				}
				else if ($response == "2"){ //有举报记录
					$obj_tips.html("<img src='"+_ROOT_PATH+"tpl/admin/images/forbid.gif' />");
				}
				else {
					$obj_tips.html("<font color='red'>查询失败</font>");
				}
			},
			error: function() {
				$obj_tips.html("");
			}
		});

	});
    
    //一键点击同步到七牛云 8.12.28
	$(document).on("click", "[f='but_send_syncound']", function(){
		$("#syn_loading").show();
		$_url = _ROOT_PATH+"index.php?c=ajax&a=batchsynyun";
		$.ajax({
			type: "POST",
			url: $_url,
			cache: false,
			data: {r:get_rndnum(8)},
			dataType: "json",
			success: function(data) {
				$json = eval(data);
				$response = $json.response;
				$result = $json.result;
				if ($response == '1') {
					layer.msg("操作成功，同步了"+$result+"个附件");
					$("#syn_result").html("（操作成功，同步了 "+$result+" 个附件/图片）");
				}
				else {
					if ($result.length > 0) {
						layer.msg($result);
					}
					else {
						layer.msg("操作失败");
					}
				}
				$("#syn_loading").hide();
			},
			error: function() {

			}
		});

	});
    
    
    //通用弹窗 21.04.21
    $(document).on("click", "[f='but_normal_dialog']", function(){
        var width = $(this).attr('data-width');
        if (typeof(width) == 'undefined') {
            width = 750;
        }
        var height = $(this).attr('data-height');
        if (typeof(height) == 'undefined') {
            height = 500;
        }
        var url = $(this).attr('data-url');
        var title = $(this).attr('data-title');
        if (typeof(title) == 'undefined') {
            title = '通用弹窗';
        }
        
        layer.open({
            title:title,
            type: 2,
            area: [width+'px', height+'px'],
            shadeClose: false,
            resize: false,
            scrollbar: false,
            content: url
        });
    });
    
    
});



$(function(){
    
    //审核认证
    $(document).on("click", "[f='pop_audit_shoprz']", function(){
        $id = $(this).attr("data-id");
        oemarry_pop_audit_shoprz($id);
    });
    
    //查看认证
    $(document).on("click", "[f='pop_view_shoprz']", function(){
        $id = $(this).attr("data-id");
        oemarry_pop_view_shoprz($id);
    });
    
    //商家绑定会员UID
    $(document).on("click", "[f='pop_bind_uid']", function(){
        $id = $(this).attr("data-id");
        oemarry_pop_bind_uid($id);
    });
    
    //发送邮件通知
    $(document).on("click", "[f='pop_send_email']", function(){
        $uid = $(this).attr("data-uid");
        if (typeof($uid) == "undefined") {
            $uid = "";
        }
        $email = $(this).attr("data-email");
        if (typeof($email) == "undefined") {
            $email = "";
        }
        oelove_pop_send_email($uid, $email);
    });
    //发送短信通知
    $(document).on("click", "[f='pop_send_sms']", function(){
        $uid = $(this).attr("data-uid");
        if (typeof($uid) == "undefined") {
            $uid = "";
        }
        $mobile = $(this).attr("data-mobile");
        if (typeof($mobile) == "undefined") {
            $mobile = "";
        }
        oelove_pop_send_sms($uid, $mobile);
    });
    //发送站内通知
    $(document).on("click", "[f='pop_send_msg']", function(){
        $uid = $(this).attr("data-uid");
        if (typeof($uid) == "undefined") {
            $uid = "";
        }
        oelove_pop_send_msg($uid);
    });
    
    //取消活动报名
    $(document).on("click", "[f='pop_partybm_cancel']", function(){
        $id = $(this).attr("data-id");
        oelove_pop_partybm_cancel($id); 
    });
    //报名成功 9.05.05
    $(document).on("click", "[f='pop_partybm_pass']", function(){
        $id = $(this).attr("data-id");
        oelove_pop_partybm_pass($id); 
    });
    
    //选择会员
    $(document).on("click", "[f='select_user']", function(){
        $_inputid = $(this).attr("data-inputid");
        
        //8.12.06
        $_sunion = $(this).attr("data-sunion");
        if (typeof($_sunion) == "undefined") {
            $_sunion = 0;
        }
        
        //9.09.06 选择类型 多选/单选
        $_type = $(this).attr("data-type");
        if (typeof($_type) == "undefined") {
            $_type = "";
        }
        oelove_varpop_selectuser($_inputid, $_sunion, $_type);
    });

    //选择活动 8.12.09
    $(document).on("click", "[f='select_party']", function(){
        $_inputid = $(this).attr("data-inputid");
        oelove_varpop_selectparty($_inputid);
    });

    //选择推广员 2018.12.07
    $(document).on("click", "[f='select_union']", function(){
        $_inputid = $(this).attr("data-inputid");
        oelove_varpop_selectunion($_inputid);
    });

    //导出会员数据 8.12.21
    $(document).on("click", "[f='pop_export_user']", function(){
        oelove_pop_exportuser();
	});
    
    //诚信查询 改进版 8.12.29 弹窗 查所有项目
	$(document).on("click", "[f='pop_view_rp']", function(){
		$_id = $(this).attr("data-uid");
		oelove_pop_viewrp($_id);
	});
    
    //弹出委托审核页 9.01.03
    $(document).on("click", "[f='pop_lineserv_audit']", function(){
        $_id = $(this).attr("data-id");
		oelove_pop_audit_lineserv($_id);
    });
    
    //批量生成线下报名 9.01.19
    $(document).on("click", "[f='but_party_underbm']", function(){
        $_id = $(this).attr("data-id");
		oelove_pop_party_underbm($_id);
    });

    //检测是否存在群名称 9.09.06
	$(document).on("blur", "[f='qzform_checkname']", function(){
		$_value = $(this).val();
		$_qzid = $(this).attr("data-qzid");
		if (typeof($_qzid) == "undefined") {
			$_qzid = 0;
		}
        $tips_obj = $("#qzname_tips");
		if ($_value.length > 0) {
            $tips_obj.html("");
			$.ajax({
				type: "POST",
				url: _OECPFILE+"&c=qzform",
				cache: false,
				data: {
                    a:"checkname", name:$_value, id:$_qzid, r:get_rndnum(8)
                },
				dataType: "json",
				success: function(data) {
					$json = eval(data);
					$response = $json.response;
					$result = $json.result;
					if ($response == '1') {
                        $tips_obj.html("<font color='green'>可用</font>");
					}
					else {
						if ($result.length == 0) {
							$result = "已存在";
						}
						$tips_obj.html("<font color='red'>"+$result+"</font>");
					}
				},
				error: function() {
					layer.msg("系统繁忙，请稍后再试！");
				}
			});
		}

	});
    
    
    //人工实名认证 9.10.22
    $(document).on("click", "[f='pop_makerz']", function(){
        $uid = $(this).attr("data-uid");
        if (typeof($uid) == "undefined") {
            $uid = "";
        }
        oelove_pop_makerz($uid);
    });
    
    
    //弹窗修改头像 9.11.19
    $(document).on("click", "[f='pop_edit_avatar']", function(){
        $id = $(this).attr("data-id");
        if (typeof($id) == "undefined") {
            $id = "";
        }
        oelove_pop_edit_avatar($id);
    });
    
    //弹窗修改状态 9.11.25
    $(document).on("click", "[f='pop_edit_status']", function(){
        $id = $(this).attr("data-id");
        if (typeof($id) == "undefined") {
            $id = "";
        }
        oelove_pop_edit_status($id);
    });
    
    //弹出添加金豆 9.11.19
    $(document).on("click", "[f='pop_add_money']", function(){
        $id = $(this).attr("data-id");
        if (typeof($id) == "undefined") {
            $id = "";
        }
        oelove_pop_add_money($id);
    });
    
    //弹窗修改VIP等级 9.11.19
    $(document).on("click", "[f='pop_add_vip']", function(){
        $id = $(this).attr("data-id");
        if (typeof($id) == "undefined") {
            $id = "";
        }
        oelove_pop_add_vip($id);
    });
    
    //鼠标放大头像 9.11.20
    $(document).on("mouseover", "[f='zoom_avatar']", function(e){
        var imgNode = $(this).parent().siblings().find('img');
        var src = imgNode.attr('src');
        var datasrc =  imgNode.attr('data-src');
        if(src != datasrc) {
            imgNode.attr('src', datasrc);
        }
        $(this).parent().siblings().show();
    }).on('click', "[f='zoom_avatar']", function () {
        var $img_url = $(this).parent().siblings().find('img').attr('data-src');
        if($img_url.length > 0) {
            if ($img_url.substr(0, 1) == "/" || $img_url.substr(0, 4) == "http") {
          
            }
            else {
              $img_url = _ROOT_PATH+$img_url;
            }
            window.open($img_url);
        }
    });
    $(document).on("mouseout", "[f='zoom_avatar']", function(){
        $(this).parent().siblings().hide();
    });
    
});


//发送邮件通知 窗 ...
function oelove_pop_send_email($id, $email, $width, $height) {
    if (typeof($email) == "undefined") {
        $email = "";
    }
    if (typeof($width) == "undefined") {$width = 900;}
	if (typeof($height) == "undefined") {$height = 550;}
    $_url = _OECPFILE + "&c=maillog&a=send&uid="+$id+"&email="+$email+"&r="+get_rndnum(8);
    layer.open({
        title:"发送邮件通知",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}
//发送短信通知 窗 ...
function oelove_pop_send_sms($id, $mobile, $width, $height) {
    if (typeof($mobile) == "undefined") {
        $mobile = "";
    }
    if (typeof($width) == "undefined") {$width = 700;}
	if (typeof($height) == "undefined") {$height = 400;}
    $_url = _OECPFILE + "&c=smslog&a=send&uid="+$id+"&mobile="+$mobile+"&r="+get_rndnum(8);
    layer.open({
        title:"发送短信通知",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}
//发送站内通知 窗 ...
function oelove_pop_send_msg($id, $width, $height) {
    if (typeof($width) == "undefined") {$width = 750;}
	if (typeof($height) == "undefined") {$height = 430;}
    $_url = _OECPFILE + "&c=msg&a=send&uid="+$id+"&r="+get_rndnum(8);
    layer.open({
        title:"发送站内通知",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}

//取消报名
function oelove_pop_partybm_cancel($id, $width, $height) {
    if (typeof($width) == "undefined") {$width = 850;}
	if (typeof($height) == "undefined") {$height = 530;}
    $_url = _OECPFILE + "&c=partybm&a=cancel&id="+$id+"&r="+get_rndnum(8);
    layer.open({
        title:"取消活动报名",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}

/**
 选择会员 9.09.06
 @param:: int $inputid input名称
 @param:: int $sunion 是否有推荐人 1-Y,0-N
 @param:: string $type 返回类型 checkbox多选，空则为单选 9.09.06
*/
function oelove_varpop_selectuser($inputid, $sunion, $type, $width, $height) {
    if (typeof($sunion) == "undefined") {$sunion = 0;} //8.12.06
    if (typeof($type) == "undefined") {$type = "";} //9.09.06
    if (typeof($width) == "undefined") {$width = 950;}
	if (typeof($height) == "undefined") {$height = 480;}
    $_url = _OECPFILE + "&c=user&a=select&sunion="+$sunion+"&stype="+$type+"&inputid="+$inputid+"&r="+get_rndnum(8);
    layer.open({
        title:"选择会员",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}



//选择活动 8.12.09
function oelove_varpop_selectparty($inputid, $width, $height) {
    if (typeof($width) == "undefined") {$width = 900;}
	if (typeof($height) == "undefined") {$height = 480;}
    $_url = _OECPFILE + "&c=party&a=select&inputid="+$inputid+"&r="+get_rndnum(8);
    layer.open({
        title:"选择活动",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}

//诚信查询 弹窗 ...8.12.29
function oelove_pop_viewrp($id, $width, $height) {
    if (typeof($width) == "undefined") {$width = 800;}
	if (typeof($height) == "undefined") {$height = 500;}
    $_url = _OECPFILE + "&c=viewrp&uid="+$id+"&r="+get_rndnum(8);
    layer.open({
        title:"诚信查询",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}


//审核委托 弹窗 ...9.01.03
function oelove_pop_audit_lineserv($id, $width, $height) {
    if (typeof($width) == "undefined") {$width = 800;}
	if (typeof($height) == "undefined") {$height = 408;}
    $_url = _OECPFILE + "&c=lineserv&a=audit&id="+$id+"&r="+get_rndnum(8);
    layer.open({
        title:"审核委托服务",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}

//批量生成线下报名 9.01.19
function oelove_pop_party_underbm($id, $width, $height) {
    if (typeof($width) == "undefined") {$width = 700;}
	if (typeof($height) == "undefined") {$height = 380;}
    $_url = _OECPFILE + "&c=partybm&a=underbm&partyid="+$id+"&r="+get_rndnum(8);
    layer.open({
        title:"生成线下报名",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}

//报名成功 9.05.05
function oelove_pop_partybm_pass($id, $width, $height) {
    if (typeof($width) == "undefined") {$width = 850;}
	if (typeof($height) == "undefined") {$height = 450;}
    $_url = _OECPFILE + "&c=partybm&a=pass&id="+$id+"&r="+get_rndnum(8);
    layer.open({
        title:"报名成功",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}

//执行ajax...
function oelove_do_ajax($url, callback) {
    callback = callback || function(){};
    $.ajax({
        type: "POST",
        url: $url,
        cache: false,
        data: {
            r:get_rndnum(8)
        },
        dataType: "json",
        success: function($data) {
            $json = eval($data);
            $response = $json.response;
            $result = $json.result;
            if ($response == "1") {
                if (typeof(callback) == "function") {
                    callback();
                }
            }
            else {
                if ($result.length > 0) {
                    layer.msg($result);
                }
                else {
                    layer.msg("操作失败");
                }
            }
        },
        error: function() {
            layer.msg("系统繁忙，请稍后再试");
        }
    });          
}

//预加载图片 9.10.12
function preload_img() {
    var img = $("[preload='0']");
    if (typeof(img) == "undefined"){
        return;
    }
    var imgEl = [];
    $.each(img, function(i, v) {
        $_src_img = $(v).attr('data-src');
        if (typeof($_src_img) == "undefined") {
            $_src_img = "";
        }
        if ($_src_img.length > 0) {
            imgEl[i] = new Image();
            imgEl[i].onload = function(){
                $(v).attr('src', $(v).attr('data-src'));
                $(v).attr("preload", "1");
            };  
            imgEl[i].src = $(v).attr('data-src');
        }
    });
}

//弹出人工实名认证 窗 ... 9.10.22
function oelove_pop_makerz($id, $width, $height) {
    if (typeof($width) == "undefined") {$width = 950;}
	if (typeof($height) == "undefined") {$height = 450;}
    $_url = _OECPFILE + "&c=userrz&a=makerz&uid="+$id+"&r="+get_rndnum(8);
    layer.open({
        title:"实名认证",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}

//弹窗修改头像 窗 ... 9.11.19
function oelove_pop_edit_avatar($id, $width, $height) {
    if (typeof($width) == "undefined") {$width = 700;}
	if (typeof($height) == "undefined") {$height = 450;}
    $_url = _OECPFILE + "&c=user&a=editavatar&id="+$id+"&r="+get_rndnum(8);
    layer.open({
        title:"修改头像",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}

//弹窗修改状态 窗 ... 9.11.25
function oelove_pop_edit_status($id, $width, $height) {
    if (typeof($width) == "undefined") {$width = 650;}
	if (typeof($height) == "undefined") {$height = 400;}
    $_url = _OECPFILE + "&c=user&a=editstatus&id="+$id+"&r="+get_rndnum(8);
    layer.open({
        title:"修改状态",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}

//弹窗添加金豆 窗 ... 9.11.19
function oelove_pop_add_money($id, $width, $height) {
    if (typeof($width) == "undefined") {$width = 700;}
	if (typeof($height) == "undefined") {$height = 450;}
    $_url = _OECPFILE + "&c=finance&a=money2&id="+$id+"&r="+get_rndnum(8);
    layer.open({
        title:"操作余额",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}

//弹窗编辑VIP等级 窗 ... 9.11.19
function oelove_pop_add_vip($id, $width, $height) {
    if (typeof($width) == "undefined") {$width = 700;}
	if (typeof($height) == "undefined") {$height = 550;}
    $_url = _OECPFILE + "&c=vipuser&a=add2&id="+$id+"&r="+get_rndnum(8);
    layer.open({
        title:"修改等级",
        type: 2,
        area: [''+$width+'px', ''+$height+'px'],
        shadeClose: false,
        resize: false,
        scrollbar: false,
        content: $_url
    });
}

//添加题目选项 21.04.21
function _emSubjectAddTr(objid, numid) {	
	var obj = $("#"+objid);
	var obj_num = parseInt($("#"+numid).val());
	var current_id = parseInt(obj_num+1);
	var html_tr = "<tr>"+
				"<td class='text_center'><input type='text' name='itemno_"+current_id+"' id='itemno_"+current_id+"' class='layui-input input-120' /></td>"+
				"<td class='text_center'><input type='text' name='text_"+current_id+"' id='text_"+current_id+"' class='layui-input input-200' /></td>"+
				"<td class='text_center'><input type='text' name='value_"+current_id+"' id='value_"+current_id+"' class='layui-input input-80' /> 分</td>"+
				"<td class='text_center'><a href='javascript:;' onclick=\"_emSubjectDelTr(this);\">移除</a></td></tr>";
                
    obj.find("tr").last().after(html_tr);
	$("#"+numid).val(current_id); //重新赋值
}
//删除题目选项 21.04.21
function _emSubjectDelTr(obj) {
	$(obj).parent('td').parent('tr').remove();
}
