<!--{include file="<!--{$oetplpath}-->block_head.tpl"}-->

<!--{if $a == "editavatar"}-->
<div class="layui-fluid oe_fluid" style="padding-top:10px;">

  <div class="layui-card">
    <div class="layui-card-header">修改[<!--{$user.username}-->]头像</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr>
          <th width="20%"><font color="red"></font>会员UID：</th>
          <td width="80%">
            <input type="hidden" name="id" id="id" class="layui-input input-200" value="<!--{$user.userid}-->" />
            <!--{$user.userid}-->
          </td>
        </tr>
        <tr>
          <th>头像：</th>
          <td>
            <table class="oe_tbl_form layui-form">
              <tr>
                <td width="320px">
                  
                  <div class="layui-btn">
                    <i class="layui-icon layui-icon-upload"></i>
                    点击上传
                    <input type="file" name="head" id="head" value="" f="but_upload_image" data-mod="avatar" data-forbidwater="1" />
                  </div>
                  <div class="upload_loading" id="head_loading" style="display:none;"></div>
                  <input type="hidden" id="head_thumb" name="head_thumb" value="" />
                  <input type="hidden" id="head_url" name="headimg" value="<!--{$user.headimg}-->" />
                  
                  <div class="tblform_tips normal">&nbsp;&nbsp;&nbsp;预览：</div>
                  <div class="upload_pic upload_pic_md" style="width:30px;height:30px;">
                    <img src="<!--{$urlpath}--><!--{if !empty($user.headimg)}--><!--{$user.headimg}--><!--{else}-->tpl/static/images/waitimg.jpg<!--{/if}-->" width="30px" height="30px" id="head_preview" f="viewimg" />
                  </div>
                  
                  <a href="javascript:;" class="oe_deluploadimg" f="removeimg" data-preview="head" data-input="head">移除</a>
                
                </td>
                <td></td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>状态：</th>
          <td>
            <div class="tbl_input input-200">
              <select name="headflag" id="headflag">
                <option value="0"<!--{if $user.headflag == '0'}--> selected<!--{/if}-->>未上传</option>
                <option value="2"<!--{if $user.headflag == '2'}--> selected<!--{/if}-->>已上传待审核</option>
                <option value="3"<!--{if $user.headflag == '3'}--> selected<!--{/if}-->>审核不通过</option>
                <option value="1"<!--{if $user.headflag == '1'}--> selected<!--{/if}-->>审核通过</option>
              </select>
            </div>
            <br />
            <span class="text_tip_inline">（只有审核通过页面才会显示头像）</span>
          </td>
        </tr>
      </table>
    </div>
  </div>

  
  <div class="oe_tbl_form_btn">
    <button class="layui-btn" id="but_submit_post" lay-submit lay-filter="submitform">
      完成
      <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
    </button>
  </div>
  
</div>

<script type="text/javascript">
$(function(){
    layui.use('form', function(){
        $form = layui.form;
        

        //完成...
        $form.on('submit(submitform)', function(data){
            $obj_id = data.elem.getAttribute("id");
            if (!$("#"+$obj_id).hasClass("forbid_submit")) {
            
            
                $id = $("#id").val();
                if ($id.length == 0) {
                    layer.msg("请输入用户UID");
                    return false;
                }
                $headimg = $("#head_url").val();
                $headflag = $("#headflag").val();
                
                
                $("#"+$obj_id).addClass("forbid_submit");
                if ($("#"+$obj_id).find("span").length > 0) {
                    $("#"+$obj_id).find("span").show();
                }
                $.ajax({
                    type: "POST",
                    url: "<!--{$oefile}-->&c=<!--{$c}-->",
                    cache: false,
                    data: {
                        a:"saveavatar", id:$id, headimg:$headimg, headflag:$headflag, 
                        datatype:"ajax", r:get_rndnum(8)
                    },
                    dataType: "json",
                    success: function(data) {
                        $json = eval(data);
                        $response = $json.response;
                        $result = $json.result;
                        if ($response == '1') {
                            layer.msg("操作成功");
                            setTimeout(function(){
                                window.parent.location.reload();
                            }, 800);
                        }
                        else {
                            if ($result.length > 0) {
                                layer.msg($result);
                            }
                            else {
                                layer.msg("操作失败");
                            }
                            $("#"+$obj_id).removeClass("forbid_submit");
                            if ($("#"+$obj_id).find("span").length > 0) {
                                $("#"+$obj_id).find("span").hide();
                            }
                        }
                        
                    },
                    error: function() {
                        layer.msg("系统繁忙，请稍后再试！");
                        $("#"+$obj_id).removeClass("forbid_submit");
                        if ($("#"+$obj_id).find("span").length > 0) {
                            $("#"+$obj_id).find("span").hide();
                        }
                    }
                });
                
                
            }
        });   
        
        
    });
    
});
</script>
<!--{/if}-->
</body>
</html>