<#assign title="我的家"/>
<#include "/home/frag.head.ftl" />

<div class="weui-tab">
    <input id="userId" type="text" hidden="hidden" value=${user_id!}/>
    <div class="weui-tab__bd">
        <div id="tab1" class="weui-tab__bd-item weui-tab__bd-item--active">
            <#include "/home/ribao.ftl" /></div>
        <div id="tab2" class="weui-tab__bd-item">
            <#include "/home/qiuzhu.ftl" /></div>
    <#--<div id="tab3" class="weui-tab__bd-item">-->
    <#--<h1>页面三</h1> </div>-->
    <#--<div id="tab4" class="weui-tab__bd-item">-->
    <#--<h1>页面四</h1> </div>-->
    </div>
    <div class="weui-tabbar">
        <a href="#tab1" class="weui-tabbar__item weui-bar__item--on">
            <div class="weui-tabbar__icon"><img src="/static/images/wx/order.png" alt=""></div>
            <p class="weui-tabbar__label">健康日报</p>
        </a>
        <a href="#tab2" class="weui-tabbar__item">
            <div class="weui-tabbar__icon"><img src="/static/images/wx/customer_service.png" alt=""></div>
            <p class="weui-tabbar__label" onclick="familyClick()">家庭求助</p>
        </a>
    <#--<a href="#tab3" class="weui-tabbar__item">-->
    <#--<div class="weui-tabbar__icon"> <img src="./images/icon_nav_article.png" alt=""> </div>-->
    <#--<p class="weui-tabbar__label">发现</p>-->
    <#--</a>-->
    <#--<a href="#tab4" class="weui-tabbar__item">-->
    <#--<div class="weui-tabbar__icon"> <img src="./images/icon_nav_cell.png" alt=""> </div>-->
    <#--<p class="weui-tabbar__label">我</p>-->
    <#--</a>-->
    </div>
</div>


</body>

<#include "/home/frag.foot.ftl" />
<script>
    <#include "/home/ribao.js" />
    <#include "/home/qiuzhu.js" />
    (function ($) {

        $(function () {
            $('.weui-navbar__item').on('click', function () {
                $(this).addClass('weui-bar__item_on').siblings('.weui-bar__item_on').removeClass('weui-bar__item_on');
                //内容切换
                var moduleClass = jQuery(this).attr("module");
                var ss = ".weui-tab__panel ." + moduleClass + "_weui_tab_bd_item_active";
                $(ss).removeClass(moduleClass + '_weui_tab_bd_item_active');
                var data_toggle = jQuery(this).attr("target");
                $(data_toggle).addClass(moduleClass + "_weui_tab_bd_item_active");
            });
        });


        ribao_init();
        qiuzhu_init();
        family_init();
        ribao_add();
        ribao_cancel();

        <#if msReport ??>var msReport = ${msReport}</#if>;
        $('#ribao_safety_num').val(msReport.safetyNum);
        ribaoInitialization(msReport.reportId);
        /*submit_back();*/
        familyClick();

        $(function () {
            $("#ground").bind("click", function () {
                if ($("#Gj").val() == "off") {
                    $("#Gj").val("on");
                    console.log("关闭查看所有");

                    qzMy_help('', $("#quetyFamily").val());
                } else {
                    $("#Gj").val("off");
                    console.log("查看已解决的");
                    qzMy_help(3, $("#quetyFamily").val());
                }
            });
        });
    })(jQuery);


    //小区求助信息的展示
    function familyClick() {
        $('#notitle').empty();//清除节点
        $.ajax({
            url: '/home/home/queryQzTask',
            data: {userId: $('#userId').val()},
            type: 'GET',
            async: false,
            success: function (data) {
                console.log(data);
                if (data.data.length > 0) {
                    hasData = true;
                    data.data.forEach(function (v) {
                        familyValue(v);
                    });
                } else {

                }
            },
            error: function () {
            }
        });
    }

    function familyValue(v) {
        $('#notitle').append($('<a class="weui-cell weui-cell_active weui-cell_access js_item" data-id="form" ' +
                '                               onclick=\'xiaoQuItemClick(' + JSON.stringify(v) + ')\'>\n' +
                '                        <div class="weui-cell__bd" taskId="1212>\n' +
                '                            <div class="weui-media-box weui-media-box_text" id="title">\n' +
                '                                <p class="weui-media-box__desc" >' + v.taskTitle + '</p>\n' +
                '                            </div>\n' +
                '                        </div>\n' +
                '                        <div class="weui-cell__ft">' + conversion(v.taskStatus) + '</div>\n' +
                '                    </a>\n<br/>'));

    }

    function xiaoQuItemClick(v) {
        /*alert(v.taskId)*/
        if ($('#titlteZs')[0].style.display == 'none') {
            $('#notitle').toggle();
            $('#titlteZs')[0].style.display = '';
            $('#qzHS').empty();//清除节点
            //详情页面的展示
            $.ajax({
                url: '/home/home/taskQuery',
                data: {taskId: v.taskId},
                type: 'GET',
                success: function (data) {
                    console.log(data);
                    if (data.data.length > 0) {
                        hasData = true;
                        $('#qzHS').append($('<div>' + data.data[0].taskTitle + '</div>'))
                        data.data.forEach(function (v) {
                            shValue(v);
                        });
                    } else {

                    }
                },
                error: function () {
                }
            });
            /*$('#qzHS').*/

        } else {
            $('#notitle')[0].style.display = '';
            $('#titlteZs')[0].style.display = 'none';
        }
    }


    //完成 已解决  为完成的方法
    function conversion(a) {
        if (a == 1) {
            return "<span style='color:red;'>未解决</span>";
        } else if (a == 2) {
            return "<span style='color:Black;'>处理中</span>";
        } else {
            return "<span style='color:green;'>已完成</span>";
        }
    }

</script>