<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml" lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>精准导购系统企业号应用</title>
    <link rel="stylesheet" href="/static/css/wechat/weui.min.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/wechat/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="/static/css/wechat/style.css">
</head>

<body ontouchstart>
<header>
    <div class="header">
        <a href="" th:href="@{/customer/usercenter}" class="btn-a-back"><i class="iconfont">&#xe61f;</i></a>
        <h2 th:text="${propName}"></h2>
    </div>
</header>
<div class="weui-cells weui-cells_form mt0">
    <div class="weui-cell">
        <div class="weui-cell__bd">
            <input class="weui-input" id="newValue" type="text" value="" th:value="${text}"/>
        </div>
        <div class="weui-cell__ft">
            <i class="weui-icon-cancel"></i>
        </div>
    </div>
</div>
<div class="btn-modify">
    <a class="weui-btn weui-btn_blue" id="showToast" href="javascript:">保存</a>
</div>

<input type="hidden" id="prop" th:value="${prop}">
<input type="hidden" id="id" th:value="${id}">

<!--提交成功提示-->
<div id="toast" style="display: none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast">
        <i class="weui-icon_toast"></i>
        <p class="weui-toast__content" id="toast_content"></p>
    </div>
</div>


<div class="js_dialog" id="successDialog" style="opacity: 0; display: none;">
    <div class="weui-mask"></div>
    <div class="weui-dialog">
        <div class="weui-dialog__bd">请填写内容后保存</div>
        <div class="weui-dialog__ft">
            <a href="javascript:;" id="succBtn" class="weui-dialog__btn weui-dialog__btn_primary">知道了</a>
        </div>
    </div>
</div>

<script type="text/javascript" src="/static/js/wechat/zepto.min.js"></script>
<script type="text/javascript" src="/static/js/statistics.js"></script>
<script type="text/javascript" src="/static/js/history.js"></script>
<script type="text/javascript">
    $(function () {
        $('.weui-icon-cancel').on('click', function () {
            $('.weui-input').val('').focus()
        });

        $('#succBtn').on('click', function(){
            $("#successDialog").fadeOut(200);
            $("#bindDialog").fadeOut(200);
        });

        // 提交成功提示
        var $toast = $('#toast');
        $('#showToast').on('click', function () {

            var id = $("#id").val();
            var prop = $("#prop").val();
            var newValue = $("#newValue").val();

            if(newValue == '' || newValue == undefined){
                $('#successDialog').fadeIn(200);
                return false;
            }

            $.ajax({
                url: "/customer/saveUserInfo",
                type: "post",
                data: {'id': id, 'prop': prop, 'newValue': newValue},
                success: function (data) {
                    if ($('#toast').css('display') != 'none') return;
                    $("#toast_content").text("提交成功");
                    $('#toast').fadeIn(100);
                    setTimeout(function () {
                        $('#toast').fadeOut(100);
                        backToUrl();
                    }, 1000);
                },
                error: function(data){
                    if ($('#toast').css('display') != 'none') return;
                    $("#toast_content").text(data.response);
                    $('#toast').fadeIn(100);
                    setTimeout(function () {
                        $('#toast').fadeOut(100);
                    }, 1000);
                }
            });

        });
    });
</script>
</body>

</html>
