<?php
require_once("../check.php");
$weixin = $u['weixin'];
$sex = $u['sex'];
if($sex=="男"){
    $nan = "selected";
    $nv = null;
}elseif($sex=="女"){
    $nv = "selected";
    $nan = null;
}
if($alipay!=null){
    $disabled = "disabled";
}else{
    $disabled = null;
}
?>
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="../js/jquery-1.11.1.min.js"></script>
<script src="../jquerymoblie/jquery.mobile-1.4.1.min.js"></script>
<link rel="stylesheet" href="../jquerymoblie/jquery.mobile-1.4.1.min.css"/>
<style>
.ui-page-theme-a .ui-btn.ui-btn-active, html .ui-bar-a .ui-btn.ui-btn-active, html .ui-body-a .ui-btn.ui-btn-active, html body .ui-group-theme-a .ui-btn.ui-btn-active, html head+body .ui-btn.ui-btn-a.ui-btn-active, .ui-page-theme-a .ui-checkbox-on:after, html .ui-bar-a .ui-checkbox-on:after, html .ui-body-a .ui-checkbox-on:after, html body .ui-group-theme-a .ui-checkbox-on:after, .ui-btn.ui-checkbox-on.ui-btn-a:after, .ui-page-theme-a .ui-flipswitch-active, html .ui-bar-a .ui-flipswitch-active, html .ui-body-a .ui-flipswitch-active, html body .ui-group-theme-a .ui-flipswitch-active, html body .ui-flipswitch.ui-bar-a.ui-flipswitch-active, .ui-page-theme-a .ui-slider-track .ui-btn-active, html .ui-bar-a .ui-slider-track .ui-btn-active, html .ui-body-a .ui-slider-track .ui-btn-active, html body .ui-group-theme-a .ui-slider-track .ui-btn-active, html body div.ui-slider-track.ui-body-a .ui-btn-active{
 background-color:#E9E9E9;

 border-color:red;
 color: red;
 text-shadow: 0 0px 0 #000;
}
#alert{
    display:none;
    margin-top:100px;
    color:#FFFF00;
    z-index:100;
    position: absolute;
    width:100%;
    font-size:14px;
    height:60px;
    line-height:60px;
    background-color: #FF671E;
    border-radius:10px;
    text-align:center;
}
#menu{
    width:100%;
    height:35px;
    margin-left:auto;
    margin-right:auto;
}
#menu .left,.right{
    float:left;
    width:50%;
    height:35px;
    line-height:35px;
    border-radius:6px;
    text-align:center;
}

#left{
    display:none;
}

</style>
<script>
$(function(){
    
    $("#menu .right").css("backgroundColor","#FF0000");
    $("#menu .right").css("color","#FFFFFF");
    
    
    $("#menu .left").click(function(){
    
    $("#left").show();
    $("#right").hide();

    $(this).css("backgroundColor","#FF0000");
    $(this).css("color","#FFFFFF");
    
    $("#menu .right").css("background","none");
    $("#menu .right").css("color","#000000");
    });
    
        
    $("#menu .right").click(function(){
    $("#left").hide();
    $("#right").show();

    $(this).css("backgroundColor","#FF0000");
    $(this).css("color","#FFFFFF");
    
    $("#menu .left").css("background","none");
    $("#menu .left").css("color","#000000");
    });
    
    
    $("#passbotton").click(function(){
    var pass1 = $("#pass1").val();  
    var pass2 = $("#pass2").val();  
    var pass3 = $("#pass3").val();
    if(pass1==""){
        alert("旧密码不能为空!");
        return false;
    }
    if(pass2==""){
        alert("请填写新密码!");
        return false;
    }
    if(pass2 != pass3){
        alert("两次新密码不一致!");
        return false;
    }
    $.post("update_userpass.php",{
       pass1:pass1,
       pass2:pass2,
       pass3:pass3 
    },function(p1,p2){
        if(p1=="1"){
            alert('旧密码有误,请重新输入!');
            return false;
        }
        if(p1=="ok"){
            alert('成功已修改!');
            $("#pass1").val('');
            $("#pass2").val('');
            $("#pass3").val('');
            return false;
        }else{
            alert('系统出错!');
            return false;
        }
        
        
    });
        
        
        
        
        
    });
    
    
    $("#submit").click(function(){
        var name = $("#name").val();
        var weixin = $("#weixin").val();
        var alipay = $("#alipay").val();
        if((name=="") || (weixin=="") || (alipay=="")){
            
            alert('所有选项不能为空!');
            return false;
        }
        
        
        var sex = $("#sex").val();
        $.post("2-baocun.php",{
            name:name,
            weixin:weixin,
            alipay:alipay,
            sex:sex
        },function(a,b){
            if(a=="ok"){
                $("#alert").show();
                $("#alert").fadeToggle(3000);
            }
        });
        
        
    });
    
    
});
</script>
<div id="alert">资料已保存!</div>
<div data-role="page" id="pageone">
  <div data-role="header">
    <h1>个人资料</h1>
  </div>
  <div data-role="content">
  <div id="menu"><div class="left">修改资料</div><div class="right">修改密码</div></div>
  
  <div id="left">
      <input type="text" value="<?php echo $weixin;?>"  id="weixin" placeholder="微信号码"/>
      <input type="text" value="<?php echo $name;?>"  id="name" placeholder="收款人姓名"/>
      <input type="text" value="<?php echo $alipay;?>" id="alipay" placeholder="支付宝收款账号"/>      
      <select name="switch" id="sex" data-role="slider">
      <option value="男" <?php echo $nan;?> >男性</option>
      <option value="女" <?php echo $nv;?> >女性</option>
    </select><br />
    <input type="submit" id="submit" data-inline="true" value="提交保存" <?php echo $disabled;?> />
      <div style="font-size: 12px;color: #8E8E8E;margin-top: 5px;">提示:个人资料一经设置不得修改!</div>
  </div>
  
  
    <div id="right">
      <input type="text" value=""  id="pass1" placeholder="请输入旧密码"/>
      <input type="text" value=""  id="pass2" placeholder="请输入新密码"/>
      <input type="text" value="" id="pass3" placeholder="再次确认新密码"/>      
    <input type="button" id="passbotton" data-inline="true" value="确认修改密码" />
  </div>
  
  
  
  
  
  
  
  </div></div>