UserManage.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div>
  3. <div v-if="!changePsd">
  4. <div class="accountmanage-tittle">
  5. <p>账号管理</p>
  6. </div>
  7. <div class="accountmanage-content">
  8. <div class="changeheader flex justify-center">
  9. <span><img src="http://user-file.17pdf.com/avatars/2020/11/16/0577b907be980556bdafa23fb0be0732-jpg.jpg"></span>
  10. <div class="headers">
  11. </div>
  12. </div>
  13. <div class="row-name">
  14. <span>昵称</span>
  15. <input v-model="username" @blur="handlerChangeUserName">
  16. <!-- <p class="err-prompt">用户名已经存在</p> -->
  17. </div>
  18. <div class="changepwd" @click="changepwdModal()">
  19. 修改密码
  20. </div>
  21. </div>
  22. </div>
  23. <div v-else>
  24. <div class="accountmanage-tittle">
  25. <p>修改密码</p>
  26. </div>
  27. <div class="login_content changepwd-content">
  28. <input v-model="form.password" class="login_input_password" type="password" placeholder="原始密码">
  29. <br/>
  30. <input v-model="form.newPassword" class="login_input_password new" type="password" placeholder="新密码(6-16个字符,区分大小写)">
  31. <br/>
  32. <input v-model="form.newPasswordConfirm" class="login_input_password confirm" type="password" placeholder="确认新密码">
  33. <br/>
  34. <div class="error-mess error-mess-signup" >
  35. <span id="error-message error-tip">{{errMsg}}</span>
  36. </div>
  37. <button class="logging" @click="vailidate">确认</button>
  38. </div>
  39. </div>
  40. </div>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. changePsd: false,
  47. username: this.$store.state.userInfo?.memberInfo?.name,
  48. form: {
  49. password:'',
  50. newPassword: '',
  51. newPasswordConfirm:''
  52. },
  53. errMsg:''
  54. }
  55. },
  56. methods: {
  57. // 点击注册前置校验
  58. vailidate() {
  59. if(this.form.newPassword !== this.form.newPasswordConfirm) {
  60. this.errMsg = '密码不一致'
  61. }else if(this.form.newPassword.length < 6) {
  62. this.errMsg = '密码位数不能少于6位'
  63. }else if(this.form.newPassword.length> 16){
  64. this.errMsg = '密码位数不能大于16位'
  65. }else {
  66. this.errMsg = ''
  67. this.handlerResetPsw()
  68. }
  69. },
  70. handlerResetPsw() {
  71. this.$axios.post('members/modifyPassword', this.form).then((res)=> {
  72. if(res.code === 200) {
  73. this.$emit('close')
  74. }
  75. })
  76. },
  77. changepwdModal() {
  78. this.changePsd = true
  79. },
  80. handlerChangeUserName() {
  81. this.$axios.get(`/members/modifyNickname?name=${this.username}`).then((res)=> {
  82. if(res.code === 200) {
  83. this.getUserInfo()
  84. }
  85. })
  86. },
  87. getUserInfo() {
  88. this.$axios.get('members/getMemberInfo').then((res)=> {
  89. if(res.code === 200) {
  90. this.$store.commit('setUser',res.result.memberInfo)
  91. }
  92. })
  93. },
  94. resetInterfaceStatus() {
  95. this.changePsd = false
  96. this.form.password = ''
  97. this.form.newPassword = ''
  98. this.form.newPasswordConfirm = ''
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .accountmanage-tittle {
  105. color: rgb(255, 79, 79);
  106. text-align: center;
  107. margin: 0;
  108. p {
  109. font-size: 20px;
  110. line-height: 64px;
  111. }
  112. }
  113. .accountmanage-content {
  114. .changeheader {
  115. text-align: center;
  116. margin: 0 24px;
  117. span img {
  118. width: 64px;
  119. border-radius: 35px;
  120. }
  121. .headers {
  122. margin-top: 8px;
  123. padding-bottom: 24px;
  124. border-bottom: 1px solid rgb(240, 240, 240);
  125. img {
  126. width: 36px;
  127. border-radius: 35px;
  128. margin: 8px 2px 0px 2px;
  129. }
  130. }
  131. }
  132. .row-name {
  133. border-top: 1px solid rgb(240, 240, 240);
  134. margin: 0 24px;
  135. height: 64px;
  136. line-height: 64px;
  137. position: relative;
  138. margin-top: 25px;
  139. span {
  140. color: rgb(153, 153, 153);
  141. font-size: 14px;
  142. float: left;
  143. width: 10%;
  144. }
  145. input {
  146. width: 88%;
  147. float: right;
  148. height: 30px;
  149. line-height: 30px;
  150. text-align: right;
  151. border: 0px;
  152. margin-top: 12px;
  153. border: none;
  154. outline: medium;
  155. &:focus {
  156. text-align: right;
  157. border: 1px;
  158. }
  159. }
  160. p {
  161. position: absolute;
  162. right: 0px;
  163. bottom: 0px;
  164. height: 20px;
  165. width: 100%;
  166. color: rgb(255, 79, 79);
  167. font-size: 14px;
  168. line-height: 20px;
  169. text-align: right;
  170. display: none;
  171. }
  172. }
  173. .changepwd {
  174. color: rgb(51, 51, 51);
  175. height: 64px;
  176. font-size: 14px;
  177. cursor:pointer;
  178. margin: 0 24px;
  179. line-height: 64px;
  180. border-top: 1px solid rgb(240, 240, 240);
  181. background: url(http://cn-file.17pdf.com/website/account/ic_cebian_normal.png) right 50% no-repeat;
  182. }
  183. }
  184. // .changepwd-content {
  185. // margin: 20px 0px;
  186. // }
  187. .login_content {
  188. text-align: center;
  189. font-size: 14px;
  190. .error-mess {
  191. position: relative;
  192. font-size: 14px;
  193. display: none;
  194. span{
  195. display: inline-block;
  196. background: #808080;
  197. color: rgb(255, 255, 255);
  198. padding: 5px 15px;
  199. border-radius: 4px;
  200. }
  201. }
  202. .error-mess-signup {
  203. position: initial;
  204. clear: both;
  205. margin-top: 15px;
  206. }
  207. .login_input_password {
  208. height: 60px;
  209. width: 360px;
  210. border-width: 0 0 1px 0;
  211. border-color: rgb(238, 238, 238);
  212. padding-left: 42px;
  213. padding-top: 16px;
  214. line-height: 44px;
  215. outline:none;
  216. background: url(http://cn-file.17pdf.com/website/account/ic_login_inputpassword.png) no-repeat 0px 28px;
  217. &.new {
  218. background: url(http://cn-file.17pdf.com/website/account/ic_lock_new.png) no-repeat 0px 28px;
  219. }
  220. &.confirm {
  221. background: url(http://cn-file.17pdf.com/website/account/ic_lock_sure.png) no-repeat 0px 28px;
  222. }
  223. }
  224. .login_input_password:-webkit-autofill {
  225. box-shadow: 0 0 0px 1000px white inset;
  226. }
  227. .logging {
  228. width: 360px;
  229. height: 48px;
  230. font-size: 16px;
  231. color: rgb(255, 255, 255);
  232. border: none;
  233. background-color: rgb(255, 79, 79);
  234. margin-bottom: 40px;
  235. border-radius: 4px;
  236. outline:none;
  237. }
  238. }
  239. </style>