/**
 * [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 2019/07/26 by CL $
*/
$(function(){
    //查看商家信息
    $(document).on("click", '[f="but_view_store"]', function(){
        $uid = $(this).attr("data-uid");
        $sid = $(this).attr("data-sid");
        if (typeof ($uid) == 'undefined') {
            $uid = 0
        }
        if (typeof ($sid) == 'undefined') {
            $sid = 0
        }
        if ($uid == 0 && $sid == 0) {
            layer.msg("参数错误");
            return false;
        }
        $url = _OE_FILE  +"?c=home&a=getstore";
        $.ajax($url , {
            dataType: "json",
            type: "post",
            data: {
                uid:$uid, sid:$sid, datatype:"json", r:get_rndnum(8)
            },
            success: function($data){
                $json = eval($data);
                $response = $json.response;
                $result = $json.result;
                if ($response == '1') {
                    $("#store_data").html($result);
                    $("#store_data").show(); //9.06.27
                    //$("#store_detail_box").hide();
                }
                else {
                    if ($result.length > 0) {
                        layer.msg($result);
                    }
                    else {
                        layer.msg("操作失败，请检查");
                    }
                }
            },
            error: function(a,b,c){
                layer.msg("系统繁忙，请稍后再试");
            }
        });
       // $("#store_detail_box").show();
    });
    $(document).on("click", '[f="but_store_close"]', function(){
        $("#store_detail_box").remove();
    });

    //关注收藏... 2018.12.07
    $(document).on("click", "[f='but_submit_follow']", function(){
        $obj = $(this);
        $_id = $(this).attr("data-id");
        $url = _OE_FILE +"?c=home&a=follow";
        $obj_id = $(this).attr("id");
        $("#"+$obj_id).attr("f", "");

        $.ajax($url , {
            dataType: "json",
            type: "post",
            data: {
                id:$_id, datatype:"json", r:get_rndnum(8)
            },
            success: function($data){
                $json = eval($data);
                $response = $json.response;
                $result = $json.result;
                if ($response == '1') {
                    if ($("#"+$obj_id).hasClass("current")) {
                        $("#"+$obj_id).removeClass('current');
                        $("#"+$obj_id).html('单身请关注');
                        layer.msg('已取消关注');
                    }else{
                        $("#"+$obj_id).addClass('current');
                        $("#"+$obj_id).html('取消关注');
                        layer.msg('已关注');
                    }
                    //$("#store_detail_box").remove();
                }
                else {
                    if ($result.length > 0) {
                        layer.msg($result);
                    }
                    else {
                        layer.msg("操作失败，请检查");
                    }
                }
                $("#"+$obj_id).attr("f", "but_submit_follow");
            },
            error: function(a,b,c){
                layer.msg("系统繁忙，请稍后再试");
                $("#"+$obj_id).attr("f", "but_submit_follow");
                $("#store_detail_box").remove();
            }
        });

    });
});


