edit.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
  3. <head>
  4. <th:block th:include="include :: header('编辑用户信息')" />
  5. </head>
  6. <body class="white-bg">
  7. <div class="wrapper wrapper-content animated fadeInRight ibox-content">
  8. <form class="form-horizontal m" id="form-notice-edit" th:object="${user}">
  9. <input id="uid" name="uid" th:field="*{uid}" type="hidden">
  10. <div class="form-group">
  11. <label class="col-sm-2 control-label">昵称:</label>
  12. <div class="col-sm-10">
  13. <input id="nick" name="nick" th:field="*{nick}" class="form-control" type="text" required>
  14. </div>
  15. </div>
  16. <div class="form-group">
  17. <label class="col-sm-2 control-label">性别:</label>
  18. <div class="col-sm-10">
  19. <select name="gender" id="gender" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
  20. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{gender}"></option>
  21. </select>
  22. </div>
  23. </div>
  24. <div class="form-group">
  25. <label class="col-sm-2 control-label">手机号码:</label>
  26. <div class="col-sm-10">
  27. <p id="editPhone" th:text="*{phone}"></p>
  28. <a href="javascript:void(0)" id="removePhone">解绑</a>
  29. </div>
  30. </div>
  31. <div class="form-group">
  32. <label class="col-sm-2 control-label">用户头像图:</label>
  33. <div class="col-sm-10">
  34. <img src="" id="addImgUrl" style="width:70px;height:70px;" alt="" th:src="*{avatar}">
  35. <input type="file" id="addUploadFile" name="uploadFile"
  36. accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
  37. <button class="btn btn-success" type="button" id="uploadBtn">上传</button>
  38. <input type="hidden" id="avatar" name="avatar" th:field="*{avatar}" class="form-control validate[required]"/>
  39. </div>
  40. </div>
  41. <div class="form-group">
  42. <label class="col-sm-2 control-label">修改卿卿号:</label>
  43. <div class="col-sm-10">
  44. <input id="erbanNo" name="erbanNo" th:field="*{erbanNo}" class="form-control" type="text" required>
  45. </div>
  46. </div>
  47. </form>
  48. </div>
  49. <th:block th:include="include :: footer" />
  50. <th:block th:include="include :: summernote-js" />
  51. <script type="text/javascript">
  52. var prefix = ctx + "users/user";
  53. var cropper;
  54. $(function() {
  55. $('#removePhone').on('click', function () {
  56. $.ajax({
  57. type: "post",
  58. url: prefix + "/untiedPhone",
  59. data: {
  60. uid: $('#uid').val(),
  61. erBanNo: $('#editErbanNo').val()
  62. },
  63. dataType: 'json',
  64. beforeSend: function () {
  65. $.modal.loading("正在处理中,请稍后...");
  66. $.modal.disable();
  67. },
  68. success: function(result) {
  69. if (typeof callback == "function") {
  70. callback(result);
  71. }
  72. $.operate.successCallback(result);
  73. }
  74. })
  75. });
  76. });
  77. $('#uploadBtn').on('click',function () {
  78. var formdata = new FormData();
  79. formdata.append("file", $('#addUploadFile').get(0).files[0]);
  80. $.ajax({
  81. url: ctx + "file/upload",
  82. data: formdata,
  83. type: "post",
  84. processData: false,
  85. contentType: false,
  86. success: function(result) {
  87. $('#addImgUrl').attr('src',result.data);
  88. $("input[name='avatar']").val(result.data);
  89. }
  90. })
  91. });
  92. $("#form-notice-edit").validate({
  93. focusCleanup: true
  94. });
  95. function edit() {
  96. var nick = $("input[name='nick']").val();
  97. var gender = $('#gender').val();
  98. var avatar = $("input[name='avatar']").val();
  99. var erbanNo = $("input[name='erbanNo']").val();
  100. var uid = $("input[name='uid']").val();
  101. var phone = $('#editPhone').html();
  102. $.ajax({
  103. cache : true,
  104. type : "POST",
  105. url : ctx + "users/user/edit",
  106. data : {
  107. "nick": nick,
  108. "gender": gender,
  109. "avatar": avatar,
  110. "erbanNo": erbanNo,
  111. "uid": uid,
  112. "phone" : phone,
  113. "avatar" : avatar
  114. },
  115. async : false,
  116. error : function(request) {
  117. $.modal.alertError("系统错误");
  118. },
  119. success : function(data) {
  120. $.operate.successCallback(data);
  121. }
  122. });
  123. }
  124. function submitHandler() {
  125. if ($.validate.form()) {
  126. edit();
  127. }
  128. }
  129. </script>
  130. </body>
  131. </html>