UserManage.vue 7.8 KB

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