<#assign title="求助详情"/>
<#include "/home/frag.head.ftl" />

<div class="weui-tab">

    <div class="weui-btn-area">

        <h4 class="weui-media-box__title">求助标题</h4>
        <p class="weui-media-box__desc">${ task.taskTitle }</p>
        <br>
        <h4 class="weui-media-box__title">求助对象</h4>
        <p class="weui-media-box__desc">${ task.taskTarget }</p>
        <br>
        <h4 class="weui-media-box__title">求助内容</h4>
        <p class="weui-media-box__desc">${ task.remark }</p>
        <br>
        <#if task.taskStatus == 1>
            <div class="weui-btn-area">
                <a class="weui-btn weui-btn_primary" href="javascript:doTask();">响应</a>
            </div>
        </#if>
        <#if task.taskStatus == 2>
            <div style="display: flex; justify-content: center;">
                <h4 class="weui-media-box__title">处理中</h4>
            </div>
        </#if>
        <#if task.taskStatus == 3>
            <div style="display: flex; justify-content: center;">
                <h4 class="weui-media-box__title">已处理完成</h4>
            </div>
        </#if>
    </div>

    <div id="qz_showPop" class="weui-popup__container popup-bottom">
        <div class="weui-popup__overlay"></div>
        <div class="weui-popup__modal">
            <div class="weui-btn-area">
                <div style="display:flex; flex-direction: row; justify-content: space-between;">
                    <div style="width: 80%;"></div>
                    <a class="weui-btn weui-btn_primary" style="margin-bottom: 3vh;" href="javascript:close();">关闭</a>
            </div>
                <textarea id="qz_content" class="weui-textarea" placeholder="请输入文本" rows="5"></textarea>
                <a class="weui-btn weui-btn_primary" style="margin-top: 3vh;margin-bottom: 5vh;" href="javascript:send();">提交</a>
            </div>
        </div>
    </div>
</div>

<#include "/home/frag.foot.ftl" />

<script>
    var task = ${taskJson};

    (function ($) {

        console.log('详情页' + task);

    })(jQuery);

    function doTask() {
        $("#qz_showPop").popup();
    }

    function close() {
        $.closePopup();
    }

    function send() {

        let qzcontent = $('#qz_content').val();
        if (qzcontent.length <= 0){
            alert("请输入内容");
            return;
        }

        $.ajax({
            url: '/yeweihui/qiuzhu/reply.json',
            type: 'post',
            data: {
                userId: task.userId,
                taskId: task.taskId,
                replyContent: qzcontent
            },
            success: function (data) {
                $.closePopup();
            },
            error: function () {
                $.alert("网络异常");
            }
        });
    }
</script>