<div class="page__bd">
    <div class="weui-tab">
        <div class="weui-navbar">
            <a class="weui-navbar__item weui-bar__item_on" target="#qz_nav1" module="qiu_zhu" onclick="familyClick()">
                小区求助
            </a>
            <a class="weui-navbar__item" target="#qz_nav2" module="qiu_zhu" id="qzMy_help" onclick="qzMy_help('')">
                我的求助
            </a>
        </div>
        <div class="weui-tab__panel">
            <div id="qz_nav1" class="weui-tab__bd-item qiu_zhu_weui_tab_bd_item_active">
                <div id="notitle">
                    <div>

                    </div>
                <#--<a class="weui-cell weui-cell_active weui-cell_access js_item" data-id="form" href="javascript:;">
                        <div class="weui-cell__bd">
                            <div class="weui-media-box weui-media-box_text" id="title">
                                <p class="weui-media-box__desc">由各种物质组成的巨型球状天体，叫做星球。星球有一定的形状，有自己的运行轨道。</p>
                            </div>
                        </div>
                        <div class="weui-cell__ft"></div>
                    </a>
                    <a class="weui-cell weui-cell_active weui-cell_access js_item" data-id="list" href="javascript:;">
                        <div class="weui-cell__bd">
                            <div class="weui-media-box weui-media-box_text" id="title">
                                <p class="weui-media-box__desc">由各种物质组成的巨型球状天体，叫做星球。星球有一定的形状，有自己的运行轨道。</p>
                            </div>
                        </div>
                        <div class="weui-cell__ft"></div>
                    </a>
                    <a class="weui-cell weui-cell_active weui-cell_access js_item" data-id="name" href="javascript:;">
                        <div class="weui-cell__bd">
                            <div class="weui-media-box weui-media-box_text" id="title2">
                                <p class="weui-media-box__desc">由各种物质组成的巨型球状天体，叫做星球。星球有一定的形状，有自己的运行轨道。</p>
                            </div>
                        </div>
                        <div class="weui-cell__ft"></div>
                    </a>
                    <a class="weui-cell weui-cell_active weui-cell_access js_item" data-id="age" href="javascript:;">
                        <div class="weui-cell__bd">
                            <div class="weui-media-box weui-media-box_text" id="title3">
                                <p class="weui-media-box__desc">由各种物质组成的巨型球状天体，叫做星球。星球有一定的形状，有自己的运行轨道。</p>
                            </div>
                        </div>
                        <div class="weui-cell__ft"></div>
                    </a>-->
                </div>
                <br/>
                <br/>
                <div id="titlteZs" style="display: none">
                    <div class="page__bd">
                        <div class="weui-panel weui-panel_access" id="qzHS">
                        </div>
                        <div class="button-sp-area">
                            <div class="weui-btn-area">
                                <a class="weui-btn weui-btn_primary" onclick="qzBackXiaoQu();">返回</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>



        <#--我的求助2-->
            <div id="qz_nav2" class="weui-tab__bd-item">
                <div id="notPlay">
                    <div class="weui-btn-area">
                        <a id="btnQZ" class="weui-btn weui-btn_primary" onclick="qzDetail();">发起求助</a>
                    </div>
                    <div class="weui-cell weui-cell_active weui-cell_switch">
                        <div class="weui-cell">
                            <div class="weui-cell__bd">
                                <input id="quetyFamily" type="text" class="weui-input" placeholder="搜素关键字"
                                       maxlength="10" style="width: 150px"/>
                            </div>
                            <a href="javascript:"
                               class="weui-btn weui-btn_mini weui-btn_primary" onclick="queryQz()">查询</a>
                        </div>
                        <input hidden="hidden" name="Gj11" id="Gj" value="on" type="radio" checked="checked"/>
                        <div class="weui-cell__ft">
                            <input class="weui-switch" type="checkbox" id="ground" name="ground">
                        </div>
                        <div class="weui-cell__bd">已解决</div>
                    </div>
                    <div id="family">
                        <div class="weui-panel__bd" id="valueQz">
                        </div>
                        <br>
                        <br>
                    </div>
                </div>
                <div id="play" style="display: none" class="weui-panel__bd"><#--发起求助的展示界面-->
                    <div class="weui-cells__group weui-cells__group_form">
                        <div class="weui-cells weui-cells_form">
                            <div class="weui-cell weui-cell_active" id="js_cell">
                                <div class="weui-cell__hd"><label class="weui-label">标题</label></div>
                                <div class="weui-cell__bd weui-flex">
                                    <input id="Qzinput" class="weui-input" type="text"
                                           placeholder="输入求助标题" maxlength="20" bindinput='formName' name="name"
                                    >
                                <#--<button id="js_input_clear" onclick="inputClick()"
                                        class="weui-btn_reset weui-btn_icon weui-btn_input-clear">
                                    <i class="weui-icon-clear"></i>
                                </button>-->
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="weui-form__control-area">
                        <div class="weui-cells__group weui-cells__group_form">
                            <div class="weui-cells weui-cells_checkbox">
                            <#-- <label class="weui-cell weui-cell_active weui-check__label" for="qzf1">
                                 <div class="weui-cell__hd">
                                     <input type="checkbox" class="weui-check" name="checkbox1" id="qzf1"
                                            value="居委会">
                                     <i class="weui-icon-checked"></i>
                                 </div>
                                 <div class="weui-cell__bd">
                                     <p>居委会</p>
                                 </div>
                             </label>-->
                                <label class="weui-cell weui-cell_active weui-check__label" for="qzf2">
                                    <div class="weui-cell__hd">
                                        <input type="checkbox" name="checkbox2" class="weui-check" id="qzf2"
                                               value="A" checked="checked">
                                        <i class="weui-icon-checked"></i>
                                    </div>
                                    <div class="weui-cell__bd">
                                        <p>业委会</p>
                                    </div>
                                </label>
                            <#--<label class="weui-cell weui-cell_active weui-check__label" for="qzf3">
                                <div class="weui-cell__hd">
                                    <input type="checkbox" name="checkbox3" class="weui-check" id="qzf3" value="物业">
                                    <i class="weui-icon-checked"></i>
                                </div>
                                <div class="weui-cell__bd">
                                    <p>物业</p>
                                </div>
                            </label>
                            <label class="weui-cell weui-cell_active weui-check__label" for="qzf4">
                                <div class="weui-cell__hd">
                                    <input type="checkbox" name="checkbox4" class="weui-check" id="qzf4"
                                           value="志愿者">
                                    <i class="weui-icon-checked"></i>
                                </div>
                                <div class="weui-cell__bd">
                                    <p>志愿者</p>
                                </div>
                            </label>-->
                            <#--<a href="javascript:void(0);" class="weui-cell weui-cell_active weui-cell_link">
                                <div class="weui-cell__bd">添加更多</div>
                            </a>-->
                            </div>
                        </div>
                        <div class="weui-cells weui-cells_form">
                            <div class="weui-cell ">
                                <div class="weui-cell__bd">
                                    <textarea class="weui-textarea" placeholder="请输入求助内容" rows="3"
                                              id="remarks"></textarea>
                                    <div class="weui-textarea-counter"><span>0</span>/200</div>
                                </div>
                            </div>
                            <br>
                            <div class="button-sp-area">
                                <a id="zqback2" href="javascript:;" onclick="qzBackFa()"
                                   class="weui-btn weui-btn_default">取消</a>
                                <a id="back" href="javascript:;" onclick="qzCommit()" class="weui-btn weui-btn_primary">求助</a>
                            </div>
                        <#--  <div class="weui-cell">
                              <a class="weui-btn weui-btn_primary" href="javascript:" id="zqback2"
                                 onclick="qzCommit()" >取消</a>
                              <a class="weui-btn weui-btn_primary" href="javascript:" id="back"
                                 onclick="qzCommit()" >求助</a>
                          </div>-->
                            <div class="weui-cell ">
                                <br>
                                <br>
                            </div>
                        </div>
                    </div>
                </div>

                <div id="familyDisplay" style="display: none">
                    <div class="page__bd">
                        <div class="weui-panel weui-panel_access" id="qzHS2">
                        </div>
                        <div class="button-sp-area">
                            <div class="weui-btn-area">
                                <a class="weui-btn weui-btn_default" onclick="qzBackHome();">返回</a>
                            </div>
                            <div class="weui-btn-area">
                                <a class="weui-btn weui-btn_primary" onclick="HomeStatus();" id="isHiddenStyle12"
                                   style="display: none">完成</a>
                                <br>
                                <br>
                                <br>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>

    function qzCommit() {
        /*     $("#qzf1").val()
             $("#qzf2").val()
             $("#qzf3").val()
             $("#qzf4").val()*/
        var taskTitle = $("#Qzinput").val();
        if (!taskTitle) {
            alert("请输入求助标题！")
            $('#notPlay').hidden = 'hidden';
            $('#play')[0].style.display = '';
            // $('#notPlay').style=='hidden'
            return false;
        }
        var taskTarget = $("#qzf2").val();
        if (!taskTarget) {
            alert("请输入求助目标！")
            return false;
        }
        var remark = $("#remarks").val();
        if (!remark) {
            alert("请输入求助内容！")
            return false;
        }

        var data = {}
        var tep = JSON.stringify(data);
        console.log(tep)
        $.ajax({
            url: '/home/home/addFimaly',
            data: {
                taskTitle: $("#Qzinput").val(),
                taskTarget: $("#qzf2").val(),
                remark: $("#remarks").val(),
                userId: $('#userId').val(),
            },
            type: 'GET',
            success: function (data) {
                if ($('#notPlay')[0].style.display == 'none') {
                    $('#play').toggle();
                    $('#notPlay')[0].style.display = '';
                } else {
                    $('#play')[0].style.display = '';
                    $('#notPlay')[0].style.display = 'none';
                }
                qzMy_help('', '');
                $('#quetyFamily').val("")

            },
            error: function () {

            }
        });
    }

    function qzBackFa() {
        if ($('#notPlay')[0].style.display == 'none') {
            $('#play').toggle();
            $('#notPlay')[0].style.display = '';
        } else {
            $('#play')[0].style.display = '';
            $('#notPlay')[0].style.display = 'none';
        }
        $('#Qzinput').val("")
        $("#qzf2").removeAttr('checked', false)
        $('#remarks').val("")
    }

    //我的求助的页面展示
    function qzMy_help(status, query) {
        $('#valueQz').empty();//清除节点
        $.ajax({
            url: '/home/home/queryQzTask',
            data: {
                taskStatus: status,
                taskTitle: query,
                userId: $('#userId').val()
            },
            type: 'GET',
            success: function (data) {
                console.log(data);
                if (data.data.length > 0) {
                    hasData = true;
                    data.data.forEach(function (v) {
                        helpValueGj(v);
                    });
                } else {

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

    function helpValueGj(v) {
        $('#valueQz').append($(' <a class="weui-cell weui-cell_active weui-cell_access js_item" data-id="form"\n' +
                '                               onclick=\'myItemClick(' + JSON.stringify(v) + ')\'>\n' +
                '                                <div class="weui-cell__bd">\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><br/>'));
    }

    var aid;

    function myItemClick(v) {
        if ($('#familyDisplay')[0].style.display == 'none') {
            $('#familyDisplay')[0].style.display = '';
            $("#notPlay").toggle();
            $('#qzHS2').empty();

            $.ajax({
                url: '/home/home/taskQuery',
                data: {taskId: v.taskId},
                type: 'GET',
                success: function (data) {
                    console.log(data);
                    //判断该求助是否完成  来判断按钮是否展示
                    if (data.data.length > 0 && data.data[0].taskStatus == 2) {
                        $('#isHiddenStyle12')[0].style.display = '';
                    } else {
                        $('#isHiddenStyle12')[0].style.display = 'none';
                    }

                    if (data.data.length > 0) {
                        $('#qzHS2').append($('<div>' + data.data[0].taskTitle + '</div>'))
                        data.data.forEach(function (v) {
                            shValuenat2(v);
                        });
                    } else {

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

    function shValuenat2(v) {
        aid = v.taskId;
        $('#qzHS2').append($('<a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">\n' +
                '                <div class="weui-media-box__bd">\n' +
                '                    <div style="display: flex; flex-direction: row; justify-content: space-between;">\n' +
                '                        <p class="weui-media-box__desc">' + v.nickName + '</p>\n' +
                '                        <p class="weui-media-box__desc">' + timestampToTime(v.timeUpdate) + '</p>\n' +
                '                    </div>\n' +
                '                    <div class="weui-cell ">\n' +
                '                        <div class="weui-cell__bd">\n' +
                '                            <textarea class="weui-textarea" rows="1" readonly >' + v.replyContent + '</textarea>\n' +
                '                            <div class="weui-textarea-counter"></div>\n' +
                '                        </div>\n' +
                '                    </div>\n' +
                '                </div>\n' +
                '            </a>\n<br />'));
    }

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

    }

    //求助反馈完成
    function HomeStatus() {
        $.ajax({
            url: '/home/qiuzhu/reply.json',
            type: 'GET',
            data: {
                taskId: aid,
            },
            success: function (data) {
                qzBackHome();
                qzMy_help('', '');
            },
            error: function () {
            }
        });
    }

    //只是单独的返回
    function qzBackHome() {
        if ($('#notPlay')[0].style.display == 'none') {
            $('#familyDisplay').toggle();
            $('#notPlay')[0].style.display = '';
        } else {
            $('#familyDisplay')[0].style.display = '';
            $('#notPlay')[0].style.display = 'none';
        }

    }

    function qzDetail() {
        $("#notPlay").toggle();
        /*点击隐藏*/
        /*展示*/
        $('#play')[0].style.display = '';
        $('#Qzinput').val("")
       // $("#qzf2").removeAttr('checked', false)
        $('#remarks').val("")
    }


    //查询按钮
    function queryQz() {
        if ($("#Gj").val() != "off") {
            qzMy_help('', $("#quetyFamily").val());
        } else {
            qzMy_help(3, $("#quetyFamily").val());
        }
    }
</script>

