info_edit.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. {extend name="common/base"/}
  2. {block name="style"}
  3. <link rel="stylesheet" href="{__CSS__}/user.css?v={:get_system_config('web','version')}" media="all">
  4. {/block}
  5. <!-- 主体 -->
  6. {block name="body"}
  7. {include file="common/header" /}
  8. <div class="user">
  9. <div class="user-home"><a href="/">首页</a> - 个人中心</div>
  10. <div class="user-box clearfix">
  11. <div class="l user-menu">
  12. {include file="common/usermenu" /}
  13. </div>
  14. <div class="r user-right">
  15. <div class="user-detail">
  16. <div class="user-detail-h3">编辑基本资料</div>
  17. <form id="userInfo" autocomplete="off">
  18. <table class="user-detail-table">
  19. <tr>
  20. <td class="td-gay" width="12%">真实姓名</td>
  21. <td width="38%">
  22. <input type="hidden" name="id" value="{$userInfo.id}">
  23. <input type="text" name="name" value="{$userInfo.name}" style="width:99%;"
  24. placeholder="请输入您的真实姓名" />
  25. </td>
  26. <td class="td-gay" width="12%">性别</td>
  27. <td width="38%">
  28. <label style="margin-right: 30px;"><input type="radio" name="sex" value="1" {eq
  29. name="userInfo.sex" value="1" } checked{/eq} />男</label>
  30. <label></label><input type="radio" name="sex" value="2" {eq name="userInfo.sex" value="2" }
  31. checked{/eq} />女</label>
  32. </td>
  33. </tr>
  34. <tr>
  35. <td class="td-gay">所在城市</td>
  36. <td>
  37. <input type="text" name="city" value="{$userInfo.city}" style="width:99%;"
  38. placeholder="请输入您所在城市" />
  39. </td>
  40. <td class="td-gay">出生日期</td>
  41. <td>
  42. <input type="text" id="birthday" name="birthday" readonly value="{$userInfo.birthday}" style="width:99%;" placeholder="请选择出生日期" />
  43. </td>
  44. </tr>
  45. <tr>
  46. <td class="td-gay">电子邮箱</td>
  47. <td>
  48. <input type="text" name="email" value="{$userInfo.email}" style="width:99%;"
  49. placeholder="请输入您的电子邮箱" />
  50. </td>
  51. <td class="td-gay">手机号码</td>
  52. <td>
  53. <input type="text" name="mobile" value="{$userInfo.mobile}" style="width:99%;" placeholder="请输入手机号码" />
  54. </td>
  55. </tr>
  56. <tr>
  57. <td class="td-gay">个人简介</td>
  58. <td colspan="3">
  59. <textarea name="desc" rows="3" class="input-textarea"
  60. placeholder="请输入300字以内的个人简介">{$userInfo.desc}</textarea>
  61. </td>
  62. </tr>
  63. <tr>
  64. <td class="td-gay">公司名称</td>
  65. <td colspan="3">
  66. <input type="text" name="company" value="{$userInfo.company}" style="width:99%;"
  67. placeholder="请输入您的公司名称" />
  68. </td>
  69. </tr>
  70. <tr>
  71. <td class="td-gay">公司所在地区</td>
  72. <td colspan="3">
  73. <input type="text" name="address" value="{$userInfo.address}" style="width:99%;"
  74. placeholder="请输入公司所在地" />
  75. </td>
  76. </tr>
  77. <tr>
  78. <td class="td-gay">所在部门</td>
  79. <td>
  80. <input type="text" name="depament" value="{$userInfo.depament}" style="width:99%;"
  81. placeholder="请输入所在部门" />
  82. </td>
  83. <td class="td-gay">担任职位</td>
  84. <td>
  85. <input type="text" name="position" value="{$userInfo.position}" style="width:99%;"
  86. placeholder="请输入担任职位" />
  87. </td>
  88. </tr>
  89. </table>
  90. </form>
  91. <div class="user-detail-edit">
  92. <span class="edit-save">保存</span>
  93. <span class="edit-cancel">取消</span>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. {/block}
  100. <!-- /主体 -->
  101. <!-- 脚本 -->
  102. {block name="script"}
  103. <script language="javascript" src="{__JS__}/laydate/laydate.js"></script>
  104. <script>
  105. //判断E-mail格式是否正确
  106. function isEmail(str) {
  107. var string = str.replace(/\s/g, "");
  108. var patn = /^[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]*)*@[a-zA-Z0-9\-]+([\.][a-zA-Z0-9\-]+)+$/;
  109. if (!patn.test(string)) return false;
  110. return true;
  111. }
  112. //判断收集格式是否正确
  113. function isMobile(str) {
  114. var patn = /^(13|14|15|16|17|18|19)\d{9}$/;
  115. if (!patn.test(str)) return false;
  116. return true;
  117. }
  118. laydate.render({
  119. elem: '#birthday'
  120. });
  121. //取消
  122. $('.edit-cancel').on('click', function () {
  123. window.location.href = '/home/user/index';
  124. });
  125. //保存用户信息
  126. $('.edit-save').on('click', function () {
  127. var truename = $('[name="name"]').val(),
  128. email = $('[name="email"]').val(),
  129. mobile = $('[name="mobile"]').val();
  130. if (truename == '') {
  131. layer.msg('真实姓名不能为空');
  132. return;
  133. }
  134. if (email != '' && !isEmail(email)) {
  135. layer.msg('输入的电子邮箱格式错误');
  136. return;
  137. }
  138. if (mobile != '' && !isMobile(mobile)) {
  139. layer.msg('输入的手机号码格式错误');
  140. return;
  141. }
  142. $.ajax({
  143. url: "/home/user/edit_submit",
  144. data: $('#userInfo').serialize(),
  145. type: 'post',
  146. async: false,
  147. success: function (res) {
  148. layer.msg(res.msg);
  149. if (res.code === 0) {
  150. setTimeout(function () {
  151. window.location.href = "{:url('/home/user/index')}";
  152. }, 1500);
  153. }
  154. }
  155. })
  156. });
  157. </script>
  158. {/block}
  159. <!-- /脚本 -->