profile.jsp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: Administrator
  4. Date: 2018/4/10 0010
  5. Time: 14:12
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
  9. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  10. <html>
  11. <head>
  12. <title>用户详情页</title>
  13. <script type="text/javascript" src="${base}/rs/js/jquery-1.8.3.min.js"></script>
  14. </head>
  15. <body>
  16. <div>
  17. <div>
  18. 头像 <img alt="用户头像" src="${base}/user/profile/avatar" />
  19. <p />
  20. <form action="${base}/user/profile/avatar" method="post" enctype="multipart/form-data">
  21. 头像文件 <input type="file" name="file" />
  22. <button type="submit">更新头像</button>
  23. </form>
  24. <span style="color: #f00">
  25. <%
  26. if (session.getAttribute("upload-error-msg") != null) {
  27. String msg = session.getAttribute("upload-error-msg").toString();
  28. out.print(msg);
  29. session.removeAttribute("upload-error-msg");
  30. }
  31. %>
  32. </span>
  33. <p />
  34. </div>
  35. </div>
  36. <div>
  37. <form action="#" id="user_profile" method="post">
  38. <div>
  39. id: <c:out value="${obj.userId}"></c:out><p />
  40. </div>
  41. <div>
  42. 昵称:<input name="nickname" value="${obj.nickname}" /><p />
  43. </div>
  44. <div>
  45. 邮箱:<input name="email" value="${obj.email}"><p />
  46. </div>
  47. <div>
  48. 邮箱验证状态:<c:out value="${obj.emailChecked}"></c:out><p />
  49. <c:if test="${!obj.emailChecked}">
  50. <button type="button" onclick="send_email_check(); return false;">发送验证邮件</button>
  51. <script>
  52. function send_email_check() {
  53. $.ajax({
  54. url: base + "/user/profile/active/mail",
  55. type: "POST",
  56. dataType: "json",
  57. success: function (data) {
  58. if (data.ok) {
  59. alert("发送成功");
  60. } else {
  61. alert(data.msg);
  62. }
  63. }
  64. })
  65. }
  66. </script>
  67. </c:if>
  68. </div>
  69. <div>
  70. 性别:<input name="gender" value="${obj.gender}"><p />
  71. </div>
  72. <div>
  73. 个性签名:<input name="description" value="${obj.description}"><p />
  74. </div>
  75. <div>
  76. 地理位置:<input name="location" value="${obj.location}"><p />
  77. </div>
  78. </form>
  79. <button type="button" id="user_profile_btn">更新</button>
  80. </div>
  81. <script>
  82. var base = '${base}';
  83. $.fn.serializeObject = function () {
  84. var o = {};
  85. var a = this.serializeArray();
  86. $.each(a, function () {
  87. if (o[this.name] !== undefined) {
  88. if (! o[this.name].push) {
  89. o[this.name] = [ o[this.name] ];
  90. }
  91. o[this.name].push(this.value || '');
  92. } else {
  93. o[this.name] = this.value || '';
  94. }
  95. });
  96. return o;
  97. }
  98. $(function () {
  99. $('#user_profile_btn').click(function () {
  100. $.ajax({
  101. url: base + '/user/profile/update',
  102. type: 'POST',
  103. data: JSON.stringify($('#user_profile').serializeObject()),
  104. success: function () {
  105. location.reload();
  106. }
  107. });
  108. });
  109. });
  110. </script>
  111. </body>
  112. </html>