<!--{include file="<!--{$mpath}-->block_header.tpl"}-->
<style>
    .layui-upload-file{
        display: none;
    }
</style>
<!--loading页开始-->
<div class="loading">
    <div class="loader">
        <div class="loader-inner pacman">
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
</div>
<!--loading页结束-->
<body>
<header class="mui-bar mui-bar-nav report-header box-s" id="header">
    <a href="javascript:history.go(-1)"><i class="iconfont icon-fanhui fl"></i></a>
    <p>修改资料</p>
</header>
<div id="main" class="mui-clearfix">
    <div class="plist clearfloat data">
        <ul>
            <li class="clearfloat touxiang">
                <a href="#">
                    <p class="fl">头像</p>
                    <i class="fr">
                        <!--{if empty(<!--{$data.pic}-->)}-->
                                 <img id="testList" src="<!--{$mpath}-->images/timg.png"/>
                        <!--{else}-->
                        <img id="testList" src="<!--{$data.pic}-->"/>
                        <!--{/if}-->
                        <input type="hidden" class="fr shuru" name="headerimg" id="headerimg" value="<!--{$data.pic}-->"/>
                    </i>
                </a>
            </li>
            <li class="clearfloat">
                <a href="#">
                    <p class="fl">昵称</p>
                    <input type="text" class="fr shuru" name="nickname" id="nickname" value="<!--{$data.nickname}-->"/>
                </a>
            </li>
            <li class="clearfloat">
                <a href="#">
                    <p class="fl">邮箱</p>
                    <input type="text" class="fr shuru" name="email" id="email" value="<!--{$data.email}-->"/>
                </a>
            </li>
        </ul>
    </div>
    <a href="javascript:void(0)" class="tui-btn" id="edit_btn">
        确定修改
    </a>
</div>
</body>
<script type="text/javascript" src="<!--{$mpath}-->js/jquery-1.8.3.min.js" ></script>
<script src="<!--{$mpath}-->layer_mobile/layer.js"></script>
<script src="<!--{$mpath}-->js/fastclick.js"></script>
<script src="<!--{$mpath}-->js/mui.min.js"></script>
<script type="text/javascript" src="<!--{$mpath}-->js/hmt.js" ></script>
<script>
    $(function(){
        $("#edit_btn").bind("click", function(){ //提交
            $nickname=$("[name=nickname]").val();
            $email=$("[name=email]").val();
            $pic=$("[name=headerimg]").val();
         //   $sex='';
          //  if($('#sex_0').is(':checked')) {
           //     $sex="male";
         //   }
          //if($('#sex_1').is(':checked')) {
            //    $sex="female";
           // }
            $.ajax({
                type: "POST",
                url: "index.php?c=user&a=ajaxeditinfo",
                cache: false,
                data: {nickname:$nickname,email:$email,pic:$pic},
                dataType: "json",
                success: function(data) {
                    var json = eval(data);
                    var response = json.response;
                    var result = json.result;
                    if (response == '1') {
                        layer.msg(result)

                        setTimeout( function(){
                            location.reload();
                            layer.close(index);
                        }, 1 * 1000 );//延迟5000毫米
                    } else {
                        layer.msg(result)
                    }
                },

            });
        });

    });
</script>
<script src="<!--{$mpath}-->layui/layui.js" charset="utf-8"></script>
<script>
    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#testList'
            ,url: 'index.php?c=user&a=upload'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }else{
                    $("#testList").attr("src",res.name);
                    $("[name=headerimg]").val(res.name1);
                }
                //上传成功
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });



        //绑定原始文件域
        upload.render({
            elem: '#test20'
            ,url: '/upload/'
            ,done: function(res){
                console.log(res)
            }
        });

    });
</script>
</html>
