UserManage.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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="原始密码" @input="changeErr">
  29. <br/>
  30. <input v-model="form.newPassword" class="login_input_password new" type="password" placeholder="新密码(6-16个字符,区分大小写)" @keydown="keydown($event)" @input="changeErr">
  31. <br/>
  32. <input v-model="form.newPasswordConfirm" class="login_input_password confirm" type="password" placeholder="确认新密码" @keydown="keydown($event)" @input="changeErr">
  33. <br/>
  34. <div v-show="isRight">
  35. <div class="error-mess error-mess-signup mb-5px" >
  36. <span id="error-message error-tip ">{{errMsg}}</span>
  37. </div>
  38. </div>
  39. <button class="logging" @click="vailidate">确认</button>
  40. </div>
  41. </div>
  42. </div>
  43. </template>
  44. <script>
  45. import { Message } from 'element-ui';
  46. export default {
  47. data() {
  48. return {
  49. changePsd: false,
  50. username: "",
  51. form: {
  52. password:'',
  53. newPassword: '',
  54. newPasswordConfirm:''
  55. },
  56. errMsg:'',
  57. isRight: false,
  58. }
  59. },
  60. watch:{
  61. dialogVisiable(){
  62. this.isRight = false
  63. this.errMsg = ''
  64. }
  65. },
  66. methods: {
  67. // 点击注册前置校验
  68. vailidate() {
  69. const reg = new RegExp(/\s/)
  70. if(this.form.newPassword !== this.form.newPasswordConfirm) {
  71. this.isRight=true
  72. this.errMsg = '密码不一致'
  73. }else if(this.form.newPassword.length < 6) {
  74. this.isRight=true
  75. this.errMsg = '密码位数不能少于6位'
  76. }else if(this.form.newPassword.length> 16){
  77. this.isRight=true
  78. this.errMsg = '密码位数不能大于16位'
  79. }else if(reg.test(this.form.newPassword)){
  80. this.isRight=true
  81. this.errMsg = '新密码中不能存在空格'
  82. }else {
  83. this.errMsg = ''
  84. this.handlerResetPsw()
  85. }
  86. },
  87. handlerResetPsw() {
  88. this.$axios.post('members/modifyPassword', this.form).then((res)=> {
  89. if(res.code === 200) {
  90. // console.log(this.form)
  91. this.$emit('close')
  92. this.isRight = false
  93. this.errMsg = ''
  94. }else{
  95. this.isRight = true
  96. this.errMsg = res.data.msg
  97. }
  98. })
  99. },
  100. changepwdModal() {
  101. this.changePsd = true
  102. },
  103. handlerChangeUserName() {
  104. this.$axios.get(`/members/modifyNickname?name=${this.username}`).then((res)=> {
  105. if(res.code === 200) {
  106. this.getUserInfo()
  107. }else{
  108. Message.error(res.data.msg)
  109. this.getUserInfo()
  110. this.username = this.$store.state.userInfo.name
  111. }
  112. })
  113. },
  114. getUserInfo() {
  115. this.$axios.get('members/getMemberInfo').then((res)=> {
  116. if(res.code === 200) {
  117. this.$store.commit('setUser',res.result.memberInfo)
  118. }
  119. })
  120. },
  121. resetInterfaceStatus() {
  122. this.changePsd = false
  123. this.form.password = ''
  124. this.form.newPassword = ''
  125. this.form.newPasswordConfirm = ''
  126. },
  127. //不允许输入空格
  128. keydown(event){
  129. if(event.keyCode == 32){
  130. event.returnValue = false
  131. this.errMsg = '请勿输入空格'
  132. this.isRight = true
  133. }
  134. },
  135. changeErr(){
  136. this.errMsg = ''
  137. this.isRight = false
  138. },
  139. },
  140. props:["dialogVisiable"],
  141. mounted() {
  142. this.username = this.$store.state.userInfo.name
  143. },
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. .accountmanage-tittle {
  148. color: rgb(255, 79, 79);
  149. text-align: center;
  150. margin: 0;
  151. p {
  152. font-size: 20px;
  153. line-height: 64px;
  154. }
  155. }
  156. .accountmanage-content {
  157. .changeheader {
  158. text-align: center;
  159. margin: 0 24px;
  160. span img {
  161. width: 64px;
  162. border-radius: 35px;
  163. }
  164. .headers {
  165. margin-top: 8px;
  166. padding-bottom: 24px;
  167. border-bottom: 1px solid rgb(240, 240, 240);
  168. img {
  169. width: 36px;
  170. border-radius: 35px;
  171. margin: 8px 2px 0px 2px;
  172. }
  173. }
  174. }
  175. .row-name {
  176. border-top: 1px solid rgb(240, 240, 240);
  177. margin: 0 24px;
  178. height: 64px;
  179. line-height: 64px;
  180. position: relative;
  181. margin-top: 25px;
  182. span {
  183. color: rgb(153, 153, 153);
  184. font-size: 14px;
  185. float: left;
  186. width: 10%;
  187. }
  188. input {
  189. width: 88%;
  190. float: right;
  191. height: 30px;
  192. line-height: 30px;
  193. text-align: right;
  194. border: 0px;
  195. margin-top: 12px;
  196. border: none;
  197. outline: medium;
  198. &:focus {
  199. text-align: right;
  200. border: 1px;
  201. }
  202. }
  203. p {
  204. position: absolute;
  205. right: 0px;
  206. bottom: 0px;
  207. height: 20px;
  208. width: 100%;
  209. color: rgb(255, 79, 79);
  210. font-size: 14px;
  211. line-height: 20px;
  212. text-align: right;
  213. display: none;
  214. }
  215. }
  216. .changepwd {
  217. color: rgb(51, 51, 51);
  218. height: 64px;
  219. font-size: 14px;
  220. cursor:pointer;
  221. margin: 0 24px;
  222. line-height: 64px;
  223. border-top: 1px solid rgb(240, 240, 240);
  224. background: url(http://cn-file.17pdf.com/website/account/ic_cebian_normal.png) right 50% no-repeat;
  225. }
  226. }
  227. // .changepwd-content {
  228. // margin: 20px 0px;
  229. // }
  230. .login_content {
  231. text-align: center;
  232. font-size: 14px;
  233. .error-mess {
  234. position: relative;
  235. font-size: 14px;
  236. // display: none;
  237. span{
  238. display: inline-block;
  239. background: #808080;
  240. color: rgb(255, 255, 255);
  241. padding: 5px 15px;
  242. border-radius: 4px;
  243. }
  244. }
  245. .error-mess-signup {
  246. position: initial;
  247. clear: both;
  248. margin-top: 15px;
  249. }
  250. .login_input_password {
  251. height: 60px;
  252. width: 360px;
  253. border-width: 0 0 1px 0;
  254. border-color: rgb(238, 238, 238);
  255. padding-left: 42px;
  256. padding-top: 16px;
  257. line-height: 44px;
  258. outline:none;
  259. background: url(http://cn-file.17pdf.com/website/account/ic_login_inputpassword.png) no-repeat 0px 28px;
  260. &.new {
  261. background: url(http://cn-file.17pdf.com/website/account/ic_lock_new.png) no-repeat 0px 28px;
  262. }
  263. &.confirm {
  264. background: url(http://cn-file.17pdf.com/website/account/ic_lock_sure.png) no-repeat 0px 28px;
  265. }
  266. }
  267. .login_input_password:-webkit-autofill {
  268. box-shadow: 0 0 0px 1000px white inset;
  269. }
  270. .logging {
  271. width: 360px;
  272. height: 48px;
  273. font-size: 16px;
  274. color: rgb(255, 255, 255);
  275. border: none;
  276. background-color: rgb(255, 79, 79);
  277. margin-bottom: 40px;
  278. border-radius: 4px;
  279. outline:none;
  280. }
  281. }
  282. </style>