resetPwd.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <el-form ref="form" :model="pwd" :rules="rules" label-width="80px">
  3. <el-form-item label="旧密码" prop="oldPassword">
  4. <el-input v-model="pwd.oldPassword" type="text" class="no-autofill-pwd"/>
  5. </el-form-item>
  6. <el-form-item label="新密码" prop="newPassword">
  7. <el-input v-model="pwd.newPassword" type="text" class="no-autofill-pwd"/>
  8. </el-form-item>
  9. <el-form-item label="确认密码" prop="confirmPassword">
  10. <el-input v-model="pwd.confirmPassword" type="text" class="no-autofill-pwd"/>
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" size="mini" @click="submit">保存</el-button>
  14. <el-button type="danger" size="mini" @click="close">关闭</el-button>
  15. </el-form-item>
  16. </el-form>
  17. </template>
  18. <script>
  19. import { mapGetters } from 'vuex'
  20. import {doEncrypt, doDecryptStr,doSign,doVerifySignature,userinfoEncrypt,userinfoDecrypt} from '@/utils/smutil'
  21. import { debounce } from 'lodash'
  22. import {removeToken} from "@/utils/auth";
  23. export default {
  24. data() {
  25. const equalToPassword = (rule, value, callback) => {
  26. if (this.pwd.newPassword !== value) {
  27. callback(new Error("新密码两次输入的密码不一致"));
  28. } else {
  29. callback();
  30. }
  31. };
  32. return {
  33. user: {},
  34. pwd: {
  35. oldPassword: undefined,
  36. newPassword: undefined,
  37. confirmPassword: undefined
  38. },
  39. // 表单校验
  40. rules: {
  41. oldPassword: [
  42. { required: true, message: "旧密码不能为空", trigger: "blur" }
  43. ],
  44. newPassword: [
  45. { required: true, message: "新密码不能为空", trigger: "blur" },
  46. { min: 8, max: 20, message: "长度在 8 到 20 个字符", trigger: "blur" }
  47. ],
  48. confirmPassword: [
  49. { required: true, message: "确认密码不能为空", trigger: "blur" },
  50. { required: true, validator: equalToPassword, trigger: "blur" }
  51. ]
  52. },
  53. //字母连续规则
  54. // strReg : /(a(?=b)|b(?=c)|c(?=d)|d(?=e)|e(?=f)|f(?=g)|g(?=h)|h(?=i)|i(?=j)|j(?=k)|k(?=l)|l(?=m)|m(?=n)|n(?=o)|o(?=p)|p(?=q)|q(?=r)|r(?=s)|s(?=t)|t(?=u)|u(?=v)|v(?=w)|w(?=x)|x(?=y)|y(?=z)|z(?=a)){3}[a-z]/i,
  55. // strResverReg : /(a(?=z)|z(?=y)|y(?=x)|x(?=w)|w(?=v)|v(?=u)|u(?=t)|t(?=s)|s(?=r)|r(?=q)|q(?=p)|p(?=o)|o(?=n)|n(?=m)|m(?=l)|l(?=k)|k(?=j)|j(?=i)|i(?=h)|h(?=g)|g(?=f)|f(?=e)|e(?=d)|d(?=c)|c(?=b)|b(?=a)){3}[a-z]/i,
  56. //数字连续规则
  57. // numReg : /(0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)|9(?=0)){3}\d/,
  58. // numResverReg : /(0(?=9)|9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){3}\d/,
  59. //键盘字母横向连续规则
  60. // keyboardHorizontalReg : /(q(?=w)|w(?=e)|e(?=r)|r(?=t)|t(?=y)|y(?=u)|u(?=i)|i(?=o)|o(?=p)|p(?=q)|a(?=s)|s(?=d)|d(?=f)|f(?=g)|g(?=h)|h(?=j)|j(?=k)|k(?=l)|l(?=a)|z(?=x)|x(?=c)|c(?=v)|v(?=b)|b(?=n)|n(?=m)|m(?=z)){3}[a-z]/i,
  61. // keyboardHorizontalResverReg : /(p(?=o)|o(?=i)|i(?=u)|u(?=y)|y(?=t)|t(?=r)|r(?=e)|e(?=w)|w(?=q)|q(?=p)|l(?=k)|k(?=j)|j(?=h)|h(?=g)|g(?=f)|f(?=d)|d(?=s)|s(?=a)|a(?=l)|m(?=n)|n(?=b)|b(?=v)|v(?=c)|c(?=x)|x(?=z)|z(?=m)){3}[a-z]/i,
  62. //多个相同字母、数字规则
  63. // sameReg : /([0-9a-zA-Z])\1{3}/,
  64. // keyboardSlopeArr : ["1qaz", "2wsx", "3edc", "4rfv", "5tgb", "6yhn", "7ujm", "8ik,", "9ol.", "0p;/", "/;p0", ".lo9", ",ki8", "mju7", "nhy6", "bgt5", "vfr4", "cde3", "xsw2", "zaq1", "4esz", "5rdx", "6tfc", "7ygv", "8uhb", "9ijn", "0okm", "-pl,", "=[;.", ".;[=", ",lp-", "mko0", "nji9", "bhu8", "vgy7", "cft6", "xdr5", "zse4"],
  65. // keyboardSlopeShiftArr : ["!qaz", "@wsx", "#edc","$rfv", "%tgb", "^yhn", "&ujm", "*ik<", "(ol>", ")p:?", "?:p)", ">lo(", "<ki*", "mju&", "nhy^", "bgt%", "vfr$", "cde#", "xsw@", "zaq!", "$esz", "%rdx", "^tfc", "&ygv", "*uhb", "(ijn", ")okm", "_pl<", "+{:>", ">:{+", "<lp_", "mko)", "nji(", "bhu*", "vgy&", "cft^", "xdr%", "zse$"],
  66. // lastReg: /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&*`~()-+=]+$)(?![0-9\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]{8,20}$/
  67. };
  68. },
  69. methods: {
  70. // 表单重置
  71. pwdReset() {
  72. this.pwd={
  73. oldPassword: undefined,
  74. newPassword: undefined,
  75. confirmPassword: undefined
  76. }
  77. },
  78. submit:debounce(function(){
  79. this.$refs["form"].validate(async valid => {
  80. if (valid) {
  81. // 密码验证规则
  82. // if (this.sameReg.test(this.pwd.newPassword)) {
  83. // this.$message.error('密码不能含有连续4位相同的数字或字母')
  84. // return
  85. // } else if (this.strResverReg.test(this.pwd.newPassword.toLowerCase())) {
  86. // this.$message.error('密码不能含有4位连续的字母')
  87. // return
  88. // } else if (this.strReg.test(this.pwd.newPassword.toLowerCase())) {
  89. // this.$message.error('密码不能含有4位连续的字母')
  90. // return
  91. // } else if (this.numReg.test(this.pwd.newPassword)) {
  92. // this.$message.error('密码不能含有4位连续的数字')
  93. // return
  94. // } else if (this.numResverReg.test(this.pwd.newPassword)) {
  95. // this.$message.error('密码不能含有4位连续的数字')
  96. // return
  97. // } else if (this.keyboardHorizontalReg.test(this.pwd.newPassword)) {
  98. // this.$message.error('密码不能含有4位横向连续的字母')
  99. // return
  100. // } else if (this.keyboardHorizontalResverReg.test(this.pwd.newPassword)) {
  101. // this.$message.error('密码不能含有4位横向连续的字母')
  102. // return
  103. // } else if (this.keyboardSlopeArr.some(v => this.pwd.newPassword.toLowerCase().indexOf(v) > -1)) {
  104. // this.$message.error('密码不能含有4位键盘斜向连续的字符')
  105. // return
  106. // } else if (this.keyboardSlopeShiftArr.some(v => this.pwd.newPassword.toLowerCase().indexOf(v) > -1)) {
  107. // this.$message.error('密码不能含有4位键盘斜向连续的字符')
  108. // return
  109. // } else if (!this.lastReg.test(this.pwd.newPassword)) {
  110. // this.$message.error('密码不满足8~20位大写字母、小写字母、数字、特殊字符三种以上的组合')
  111. // return
  112. // }
  113. let sysTime
  114. let lk
  115. await this.$axios.get('/sysPolicyController/getLicenseKey').then((res) => {
  116. sysTime = res.data.sysTime
  117. lk = res.data.lk
  118. }).catch((error) => {
  119. })
  120. // 用户信息解密
  121. let decryptUserInfo = userinfoDecrypt(localStorage.getItem('active'))
  122. this.user = JSON.parse(decryptUserInfo).sysUser
  123. const param = {
  124. id: this.user.id,
  125. oldPassword: this.pwd.oldPassword,
  126. newPassword: this.pwd.newPassword,
  127. confirmPassword: this.pwd.confirmPassword,
  128. sysTime: sysTime,
  129. lk: lk
  130. }
  131. await this.$axios.post('/sysUserController/updatePassword', param).then((res) => {
  132. if (res.code==0){
  133. this.pwdReset()
  134. this.$message.success('密码修改成功,请重新登录!')
  135. this.$axios.post(
  136. '/logout',{}
  137. ).then((res) => {
  138. removeToken()
  139. //注销返回自己的登录页
  140. this.$router.push(`/login?redirect=${this.$route.fullPath}`)
  141. })
  142. }
  143. if (res.code==1){
  144. this.$message.error(res.data)
  145. }
  146. }).catch((error) => {
  147. // this.$message.error(error)
  148. })
  149. }
  150. });
  151. },1000),
  152. close() {
  153. this.$tab.closePage();
  154. }
  155. }
  156. };
  157. </script>
  158. <style rel="stylesheet/scss" lang="scss">
  159. .no-autofill-pwd{
  160. text-security:disc!important;
  161. -webkit-text-security:disc!important;
  162. }
  163. </style>