<?xml version="1.0" encoding="UTF-8"?>
<h:screen xmlns:h="http://www.hand-china.com/hap">
    <style>
        html, body {
            background: #e9ecf3;
            /*height: 627px;*/
        }

        #msgType-prompt {
            margin-top: 5px;
        }
        textarea{outline:none;resize:none;}
    </style>
    <!--<script src="${base.contextPath}/common/code?sdDataSource=WECHAT.MSG_TYPE" type="text/javascript"></script>-->
    <script><![CDATA[
    var wechatAppId = ${RequestParameters.wechatAppId!};
    var viewModel = kendo.observable({
        enabled: false,
        isEnabled: true,
        data: {
            msgType: "text",
            wechatAppId: wechatAppId
        },
        sdDataSource: [{code:"text",meaning:"文字消息"}],
    });

    //获取viewModel数据
    !function () {
        $.ajax({
            type: "get",
            url: "${base.contextPath}/response/message/query?wechatAppId=" + wechatAppId,
            dataType: "json",
            contentType: 'application/json',
            success: function (datas) {
                if (datas.total !== 0) {
                    viewModel.set("data", datas.rows[0]);
                }

            }
        })
    }();

    ]]></script>
    <div style="height: 100px;background: white;width: 475px;border-radius: 5px;box-shadow: 3px 3px 3px rgb(204, 204, 204);padding-top: 10px;margin-left: 40px;margin-top: 40px;padding-left: 10px;float:inherit;">
        <h2 style="text-align: center">关注欢迎语</h2>
    </div>
    <div style="height: 350px;background: white;width: 475px;border-radius: 5px;box-shadow: 3px 3px 3px rgb(204, 204, 204);padding-top: 10px;margin-left: 40px;margin-top: 40px;padding-left: 10px;float: inherit;">

        <h:hlsCombobox name="msgType" id="msgType"
                       bind="enabled: isEnabled,source: sdDataSource, value:data.msgType"
                       colspan="3"
                       dataTextField="meaning"
                       dataValueField="code"
                       placeholder="消息类型"
                       prompt="消息类型"
                       promptColspan="3"
                       valuePrimitive="true"
                       style="width:100%"
        />
        <div style="clear: both"></div>
        <label class="col-sm-3 control-label hlsComboboxLabel" style="float: left">内容：</label>
        <h:hlsTextArea id="content" bind="enabled: isEnabled, value:data.content"
                       style="width:435px;height:250px;margin-left:15px"></h:hlsTextArea>

    </div>
    <h:hlsToolBar>
        <h:hlsButton id="save" text="提交修改"></h:hlsButton>
    </h:hlsToolBar>
    <script><![CDATA[
    $("#save").click(function () {
        $.ajax({
            type: "post",
            url: "${base.contextPath}/response/message/updateContent",
            data: kendo.stringify(viewModel.data),
            dataType: "json",
            contentType: 'application/json',
            success: function (datas) {
                if (datas.success) {
                    kendo.ui.showConfirmDialog({
                        title: "提示",
                        message: "保存成功"
                    }).done(function (e) {
                        if(e.button=='OK'){
                            window.parent.$('#'+'${RequestParameters.hlsWindowId}').data('kendoWindow').close();
                        }
                    });
                    //todo
                } else {
                    kendo.ui.showErrorDialog({
                        title: "提示",
                        message: datas.message
                    })
                }
            }
        })
    })
    ]]></script>
</h:screen>